donglao4370 2018-02-17 06:48
浏览 235
已采纳

如何在Laravel 5.4中更改路由文件位置?

I will try to change my route file location but its ganerate error so i'm reset all my project code when its compalet reset but after its genrate this error. so how to fix this error.

enter image description here

RouteServicveProvider.php

<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as 
ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
   /**
   * This namespace is applied to your controller routes.
   *
   * In addition, it is set as the URL generator's root namespace.
   *
   * @var string
   */
protected $namespace = 'App\Http\Controllers';
/**
 * Define your route model bindings, pattern filters, etc.
 *
 * @return void
 */
public function boot()
{
   parent::boot();
}
/**
 * Define the routes for the application.
 *
 * @return void
 */
public function map()
{
    $this->mapApiRoutes();
    $this->mapWebRoutes();
}
/**
 * Define the "web" routes for the application.
 *
 * These routes all receive session state, CSRF protection, etc.
 *
 * @return void
 */
protected function mapWebRoutes()
{
    Route::middleware('web')
         ->namespace($this->namespace)
         ->group(base_path('routes/web.php'));
}
/**
 * Define the "api" routes for the application.
 *
 * These routes are typically stateless.
 *
 * @return void
 */
protected function mapApiRoutes()
{
    Route::prefix('api')
         ->middleware('api')
         ->namespace($this->namespace)
         ->group(base_path('routes/api.php'));
}}

C:\wamp64\www\example\vendor\laravel\framework\src\Illuminate\Routing\Router.php

enter image description here

  • 写回答

3条回答 默认 最新

  • dongsuiwo0279 2018-02-17 06:51
    关注

    You have an error in file C:\wamp64\www\example\vendor\laravel\framework\src\Illuminate\Routing\Router.php line 3. And also remove 'F' before

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • dongluan0020 2018-02-17 07:18
    关注

    To change the location of the routes file, you can do the following in your RouteServiceProvider:

    public function boot(): void
    {
        $this->loadRoutes();
    }
    
    /**
     * Register the application routes.
     */
    public function loadRoutes(): void
    {
        Route::group([
            'namespace' => 'App\Http\Controllers'
        ], function () {
            $this->loadRoutesFrom(__DIR__ . '/path/to/routes.php');
        });
    }
    
    评论
  • doujiaozhan4397 2018-02-17 08:32
    关注

    There is just F typing so the error is genrat.

    enter image description here

    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 回答几个问题 关于数据库
  • ¥15 设计程序(标签-STM32|关键词-工作模式)
  • ¥15 51单片机串口通信问题,未完成且要修改
  • ¥15 百鸡问题 c++编程问题(相关搜索:输出数据)
  • ¥30 如何在CMD中设置代理
  • ¥15 我有一块薛定谔的硬盘
  • ¥15 微信小游戏开发2D碰撞检测问题
  • ¥30 MapReduce案例实践(实验过程需要截图加文字)
  • ¥30 链表、二叉树的应用和算法设计
  • ¥15 R语言批量修改csv文件中的某一列