Symfony\Component\Routing\Exception\RouteNotFoundException; Route [home.getstarted] not defined。

4

我是一名新手网站开发者,正在进行我的项目。如果您能帮助我解决这个问题,将会对我有很大的帮助。

我的4个Blade PHP代码中出现了路由错误。第一个错误出现在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);

    }

}

第四个PHP代码在$request = Illuminate\Http\Request::capture()处出现错误。以下是代码:

    | 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);

如何解决这个错误?


你能展示一下你的路由文件吗? - Thibaut
1个回答

1

只需打开终端并转到相同的项目文件夹位置,然后键入:

php artisan route:cache

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

你能否详细解释一下,因为我很难理解这句话的意思:“打开终端并将目录更改为同一项目文件夹位置”。 - Charlene van der Walt
只需在资源管理器中打开项目文件夹,然后在目录选项卡中双击,完整的项目路径将显示出来。删除它,然后输入cmd,使用命令即可。 - Jawad_Yz2k

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接