2017-01-26 182 views
0

,照着所有的說明... https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0升級到5.3 laravel - 問題與路線::從5.1升級到5.3前綴

現在我越來越

BadMethodCallException in Macroable.php line 74: 
Method prefix does not exist. 
in Macroable.php line 74 
at Router->__call('prefix', array('api')) in Facade.php line 237 
at Facade::__callStatic('prefix', array('api')) in RouteServiceProvider.php line 58 
at RouteServiceProvider->mapApiRoutes() in RouteServiceProvider.php line 32 
at RouteServiceProvider->map() 
at call_user_func_array(array(object(RouteServiceProvider), 'map'), array()) in Container.php line 508 
at Container->call(array(object(RouteServiceProvider), 'map')) in RouteServiceProvider.php line 69 
at RouteServiceProvider->loadRoutes() in RouteServiceProvider.php line 30 
at RouteServiceProvider->boot() in RouteServiceProvider.php line 23 
at RouteServiceProvider->boot() 
at call_user_func_array(array(object(RouteServiceProvider), 'boot'), array()) in Container.php line 508 
at Container->call(array(object(RouteServiceProvider), 'boot')) in Application.php line 769 
at Application->bootProvider(object(RouteServiceProvider)) in Application.php line 752 
at Application->Illuminate\Foundation\{closure}(object(RouteServiceProvider), '16') 
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(NotificationServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(ConfigServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(DatabaseServiceProvider), object(BraintreeServiceProvider), object(BroadcastServiceProvider), object(FlashServiceProvider), object(ExcelServiceProvider), object(CashierServiceProvider), object(EntrustServiceProvider), object(AnalyticsServiceProvider), object(JWTAuthServiceProvider), object(ApidocsServiceProvider), object(ServiceProvider), object(GeoIPServiceProvider), object(PdfServiceProvider), object(LaravelPhoneServiceProvider)), object(Closure)) in Application.php line 753 
at Application->boot() in BootProviders.php line 17 
at BootProviders->bootstrap(object(Application)) in Application.php line 203 
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 254 
at Kernel->bootstrap() in Kernel.php line 145 
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117 
at Kernel->handle(object(Request)) in index.php line 52 
  • 跑作曲家轉儲-autoload
  • ran作曲家更新(只是爲了獲得最新和最好的)
  • 我還能做什麼?

RouteServiceProvider的代碼是從laravel精確複製的。 不確定爲什麼它沒有加載!該方法無法識別,但我可以在Router類中看到它。

{ 「名稱」: 「laravel/laravel」, 「描述」: 「的Laravel框架。」, 「關鍵字」:[ 「框架」, 「laravel」], 「許可證」:「MIT 「 」類型「: 」項目「, 」需要「:{ 」laravel /框架「: 」5.3 「, 」laravelcollective/HTML。「: 」〜5.0「, 」laracasts /閃光「:」 〜1.3「, 」maatwebsite/excel「:」〜2.1「, 」guzzlehttp/guzzle「:」〜6.2「, 」doctrine/dbal「:」〜2.5「, 」laravel/cashier「:」〜7.0 「, 」聯盟/ flysystem-aws -s3-v3「:」〜1.0「, 」zizaco/entrust「:」1.7.0「, 」barryvdh/laravel-ide-helper「:」^ 2.2「, 」blueimp/jquery-file-upload「 :「^ 9.14」, 「ipunkt/laravel-analytics」:「^ 1.3」, 「braintree/braintree_php」:「^ 3.21」, 「tymon/jwt-auth」:「0.5。 「 」F2M2/apidocs「: 」〜2.0「, 」barryvdh/laravel-CORS「: 」0.8 *「, 」pulkitjalan/geoip的。「: 」〜2.4「, 」 AWS/AWS-sdk- php-laravel「:」^ 3.1「, 」vsmoraes/laravel-pdf「:」^ 1.0「, 」propaganistas/laravel-phone「:」^ 2.8「, 」activecampaign/api-php「:」〜2.0 「 }, 」需要-dev的「:{ 」的PHPUnit/PHPUnit的「: 」〜4.0「, 」phpspec/phpspec「: 」〜2.1「, 」ozankurt/repoist「: 」^ 1.0「, 」 symfony/dom-crawler「:」〜3.1「, 」symfony/css-selector「:」〜3.1「 }, 」autoload「:{ 「類映射」:[ 「數據庫」 ], 「PSR-4」:{ 「APP \」: 「應用程序/」 } }, 「自動加載-dev的」:{ 「類映射」:[ 「測試/ TestCase.php」 ] }, 「腳本」:{ 「根後封裝安裝」:[ 「PHP -r \」 file_exists( 'ENV')||複製('。env.example','。ENV'); \ 「」 ], 「後創建項目-CMD」: 「PHP工匠鍵:產生」 ], 「安裝後-CMD」: 「照亮\基金會\ ComposerScripts ::安裝後 「 」PHP人員優化「 ], 」更新後-CMD「:[ 」照亮\基金會\ ComposerScripts :: postUpdate「, 」PHP人員優化「 ] }, 」 配置「:{ 」preferred-install「:」dist「 } }

RouteServiceProvider

<?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')); 
    } 
} 

另一個測試 我換前綴和中間件調用和得到這個錯誤...

交換ORDER

protected function mapApiRoutes() 
{ 
    Route::middleware('api')->prefix('api') 
     ->namespace($this->namespace) 
     ->group(base_path('routes/api.php')); 
} 

ERROR

FatalThrowableError in Router.php line 859: 
Type error: Too few arguments to function Illuminate\Routing\Router::middleware(), 1 passed in /var/www/vhosts/camp-native/API-v.2-master/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 237 and exactly 2 expected 
in Router.php line 859 
at Router->middleware('api') in Facade.php line 237 
at Facade::__callStatic('middleware', array('api')) in RouteServiceProvider.php line 58 
at RouteServiceProvider->mapApiRoutes() in RouteServiceProvider.php line 32 
at RouteServiceProvider->map() 
at call_user_func_array(array(object(RouteServiceProvider), 'map'), array()) in Container.php line 508 
at Container->call(array(object(RouteServiceProvider), 'map')) in RouteServiceProvider.php line 69 
at RouteServiceProvider->loadRoutes() in RouteServiceProvider.php line 30 
at RouteServiceProvider->boot() in RouteServiceProvider.php line 23 
at RouteServiceProvider->boot() 
at call_user_func_array(array(object(RouteServiceProvider), 'boot'), array()) in Container.php line 508 
at Container->call(array(object(RouteServiceProvider), 'boot')) in Application.php line 769 
at Application->bootProvider(object(RouteServiceProvider)) in Application.php line 752 
at Application->Illuminate\Foundation\{closure}(object(RouteServiceProvider), '16') 
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(NotificationServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(ConfigServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(DatabaseServiceProvider), object(BraintreeServiceProvider), object(BroadcastServiceProvider), object(FlashServiceProvider), object(ExcelServiceProvider), object(CashierServiceProvider), object(EntrustServiceProvider), object(AnalyticsServiceProvider), object(JWTAuthServiceProvider), object(ApidocsServiceProvider), object(ServiceProvider), object(GeoIPServiceProvider), object(PdfServiceProvider), object(LaravelPhoneServiceProvider)), object(Closure)) in Application.php line 753 
at Application->boot() in BootProviders.php line 17 
at BootProviders->bootstrap(object(Application)) in Application.php line 203 
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 254 
at Kernel->bootstrap() in Kernel.php line 145 
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117 
at Kernel->handle(object(Request)) in index.php line 52 
+0

我現在也面臨完全相同的問題,我從5.1升級到5.2,它工作得很好,只有很少的補丁,然後我不得不升級到5.3之後有一些問題,這似乎是第一次。祝你好運? – BlackBurn027

回答

2

該鏈接是從5.2升級到5.3,因此您可能還需要檢查5.1到5.2。

看起來可能是缺少的API路由和中間件。您所查找的API和部分與裁判該更新鏈接:

'api' => [ 
    'throttle:60,1', 
    'bindings', 
], 

app/Providors/RouteServiceProvider您尋找somethign像內:

protected function mapApiRoutes() 
     { 
      Route::prefix('api') 
      ->middleware('api') 
      ->namespace($this->namespace) 
      ->group(base_path('routes/api.php')); 
    } 

希望這有助於,可能是一個線索?

+0

鏈接是所有的升級,只需要進一步向下滾動;) – Artistan

+0

我遵循所有的說明和api路由被定義爲詳細。任何其他想法? – Artistan

+2

收集應用程序\ Providers \ RouteServiceProvider ::類, 是在config/app.php providors列表中?您也可以在您的問題中添加整個RouteServiceProvider,以便我們可以檢查全新安裝,因爲這是我有時會檢查更新的 –