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

图片转代码服务由CSDN问答提供 功能建议

我将尝试更改我的路径文件位置,但是它的ganerate错误,所以我重置了我的所有项目代码 compalet重置但在其生成后出现此错误。 所以如何解决这个错误。

RouteServicveProvider.php < / p>

 &lt;?php 
namespace App \ Providers; 
use Illuminate \ Support \ Facades \ Route; 
use Illuminate \ Foundation \ Support \ Providers \ RouteServiceProvider  as 
 
 
服务提供者; 
class RouteServiceProvider扩展ServiceProvider 
 {
 / ** 
 *此命名空间应用于控制器路由。
 * 
 *此外,它被设置为URL生成器的根命名空间。
  * 
 * @var string 
 * / 
 nprotected $ namespace ='App \ Http \ Controllers'; 
 / ** 
 *定义路径模型绑定,模式过滤器等
 * 
 * @  return void 
 * / 
public function boot()
 {
 parent :: boot(); 
} 
 / ** 
 *定义应用程序的路由。
 * 
 * @return  void 
 * / 
 npublic function map()
 {
 $ this-&gt; mapApiRoutes(); 
 $ this-  &gt; mapWebRoutes(); 
} 
 / ** 
 *定义应用程序的“web”路由。
 * 
 *这些路由都接收会话状态,CSRF保护等。
 * 
  * @return void 
 * / 
保护函数mapWebRoutes()
 {
 Route :: middleware('web')
  - &gt; namespace($ this-&gt; namespace)
  - &gt; group(base_path  ('routes / web.php')); 
} 
 / ** 
 *定义应用程序的“api”路由。
 * 
 *这些路由通常是无状态的。
 * 
 *  @return void 
 * / 
保护函数mapApiRoutes()
 {
 Route :: prefix('api')
  - &gt;中间件('api')
  - &gt;命名空间($ this-&gt; 命名空间)
  - &gt; group(base_path('routes / api.php')); 
}} 
   
 
 

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

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

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

    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题