【问题标题】:Symfony\Component\Routing\Exception\RouteNotFoundException; Route [home.getstarted] not definedSymfony\Component\Routing\Exception\RouteNotFoundException;路线 [home.getstarted] 未定义
【发布时间】:2021-11-24 16:10:14
【问题描述】:

我是网络开发的新手,我正在做这个作为我的项目。您在解决这个问题上的帮助将大有帮助。

我的刀片 PHP 代码的 4 个出现此路由错误。第一个错误出现在第 429 行。如何更正?

  ** * Get the URL to a named route.

 *

 * @param  string  $name

 * @param  mixed  $parameters

 * @param  bool  $absolute

 * @return string

 *

 * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException

 */

public function route($name, $parameters = [], $absolute = true)

{

    if (! is_null($route = $this->routes->getByName($name))) {

        return $this->toRoute($route, $parameters, $absolute);

    }



    throw new RouteNotFoundException("Route [{$name}] not defined.");

}



/**

 * Get the URL for a given route instance.

 *

 * @param  \Illuminate\Routing\Route  $route

 * @param  mixed  $parameters

 * @param  bool  $absolute

 * @return string

 *

 * @throws \Illuminate\Routing\Exceptions\UrlGenerationException

 */

public function toRoute($route, $parameters, $absolute)

{

    $parameters = collect(Arr::wrap($parameters))->map(function ($value, $key) use ($route) {**

这是第二个出现错误的 PHP 代码:<form action="{{ route('home.getstarted') }}" method="post" class="getStartedForm">

</nav>

                    </div>

                    <div class="input-section recepiet">

                        <div class="money-input-field">

                            <input type="number" id="final_amount" placeholder="83,876">

                            <span>{{ __('Recipient Gets') }}</span>

                        </div>

                        <div class="money-currency">

                            <a href="#" data-bs-toggle="dropdown" aria-expanded="false"><span><img id="country_flag" src="" alt=""> <span id="currency_name"> </span>&nbsp <span class="iconify" data-icon="dashicons:arrow-down-alt2" data-inline="fa

                            <ul class="dropdown-menu dropdown-menu-end currency" id="currencyList">

                            </ul>

                            <input type="hidden" name="currency_name" id="currency_symbol">

                        </div>

                    </div>

                    <div class="calculation-checkout-btn">

                        <form action="{{ route('home.getstarted') }}" method="post" class="getStartedForm">

                            @csrf

                            <input type="hidden" value="" name="charge">

                            <input type="hidden" value="" name="currency">

                            <input type="hidden" value="" name="amount">

                            <input type="hidden" value="" name="withdrawmethod">

                            <button type="submit" id="getStarted">{{ __('Get Started') }}</button>

                        </form>


                    </div>

                </div>

            </div>

        </div>

    </div>

</div>

第三个PHP代码,第25行报错

<?php

namespace App\Http\Middleware;

use Closure;

class Localization

{

    /**

     * Handle an incoming request.

     *

     * @param  \Illuminate\Http\Request  $request

     * @param  \Closure  $next

     * @return mixed

     */

    public function handle($request, Closure $next)

    {

        if (\Session::has('locale')==true) {

            \App::setlocale(\Session::get('locale'));

        }

        else{

            \Session::put('locale',env('DEFAULT_LANG','en'));

            \App::setlocale(\Session::get('locale'));

        }

        return $next($request);

    }

}

$request = Illuminate\Http\Request::capture() 中有错误的 Forth PHP 代码。下面是代码:

    | We need to illuminate PHP development, so let us turn on the lights.

| This bootstraps the framework and gets it ready for use, then it

| will load up this application so that we can run it and send

| the responses back to the browser and delight our users.

|

*/

 

$app = require_once __DIR__.'/script/bootstrap/app.php';

 

/*

|--------------------------------------------------------------------------

| Run The Application

|--------------------------------------------------------------------------

|

| Once we have the application, we can handle the incoming request

| through the kernel, and send the associated response back to

| the client's browser allowing them to enjoy the creative

| and wonderful application we have prepared for them.

|

*/

 

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

 

$response = $kernel->handle(

    $request = Illuminate\Http\Request::capture()

);

 

$response->send();

 

$kernel->terminate($request, $response);

可以做些什么来纠正这个错误?

【问题讨论】:

  • 你能显示你的路线文件吗?

标签: php laravel laravel-5


【解决方案1】:

只需打开终端并将目录更改为相同的项目文件夹位置,然后键入:

php artisan route:cache

所有新路由都将被缓存,新路由将可访问

【讨论】:

  • 您能否解释一下,因为我很难理解这意味着“打开终端并将目录更改为相同的项目文件夹位置”。
  • 只需在资源管理器中的目录选项卡中打开项目文件夹向上双击然后项目的完整路径将显示删除它然后键入cmd然后使用命令
猜你喜欢
  • 2022-12-16
  • 2022-01-05
  • 2021-09-10
  • 2019-08-02
  • 2021-05-28
  • 2020-05-15
  • 1970-01-01
相关资源
最近更新 更多