2015-04-14 38 views
1

我有點新來laravel,並遇到了一些我不知道如何解決,甚至從哪裏開始尋找。任何人都可以解釋這一點嗎?laravel artisan錯誤列出路線時

當我運行php artisan route:list

我得到:

[Symfony\Component\Debug\Exception\FatalErrorException] 
syntax error, unexpected ',' 

我只是做了一些改動,以routes.php文件。自從評論出來並清除了緩存後,這仍然表明,無論如何。

更新 - routes.php文件

<?php 

/* 
|-------------------------------------------------------------------------- 
| Application Routes 
|-------------------------------------------------------------------------- 
| 
| Here is where you can register all of the routes for an application. 
| It's a breeze. Simply tell Laravel the URIs it should respond to 
| and give it the controller to call when that URI is requested. 
| 
*/ 
/** 
* Blade adjustments to make it work with Angular.js 
*/ 
Blade::setContentTags('<%', '%>'); // for variables and all things Blade 
Blade::setEscapedContentTags('<%%', '%%>'); // for escaped data 

/** 
* Send requests to Angular.js (may need rethinking eventually because this is 
* essentially a whitelist) 
*/ 
Route::get('/{page?}', function($name = 'dash') { 
    return View::make('index'); 
})->where('page', '(dash|todo|help|settings)'); 

// Commented out to make Angular.js pages work 
//Route::get('/', '[email protected]'); 
//Route::get('home', '[email protected]'); 

/** 
* Page View Routes 
* Author: Anthony Sinclair 
* Date: 31/03/2015 
*/ 
/** User GET for new Users created via the UI */ 
Route::get('user/new', '[email protected]'); 
/** User POST for catching Users created via the UI */ 
Route::post('user/new', '[email protected]'); 

/** 
* RESTful API routes 
* Author: Anthony Sinclair 
* Date: 30/03/2015 
*/ 
Route::group(array('prefix' => 'api/v1', 'before'=>'auth'), function(){ 
    /** User based API call routing */ 
    Route::resource('user', 'UserController'); 
    /** People based API call routing */ 
    Route::resource('recipient', 'PeopleController'); 
    /** Survey based API call routing */ 
    Route::resource('survey', 'SurveyController'); 
    /** Survey Response based API call routing */ 
    Route::resource('response', 'SurveyResponseController'); 
    Route::resource('response/token/{survey_token}', '[email protected]'); 
    /** Survey Instigator - The sending of Surveys */ 
    Route::resource('send/{survey_id}', '[email protected]'); 
}); 

/** Nps based API call routing */ 
Route::get('/api/v1/nps/{survey_id}', '[email protected]'); 
Route::get('/api/v1/nps/{survey_id}/{filter}', '[email protected]'); 
Route::get('/api/v1/nps/{survey_id}/{filter}/{modifier}', '[email protected]'); 

Route::get('/api/v1/nps/response/{survey_id}/{recipient_id}/{nps_score}', '[email protected]'); 

Route::controllers([ 
    'auth' => 'Auth\AuthController', 
    'password' => 'Auth\PasswordController' 
]); 

即使檢查我的routes.php文件的內容 - 未顯示任何錯誤:

php -l app\http\routes.php 
No syntax errors detected in app\http\routes.php 
+0

你的route.php中有什麼? –

+0

@sgt - 更新我的問題與routes.php內容 – LokiSinclair

+0

錯誤發生在哪裏?例外中應該提到文件和行號。 – lukasgeiter

回答

2

及早去storage/framework和刪除routes.php。我懷疑語法錯誤可能已被緩存。

+0

工匠是否明確編譯不這樣做? – LokiSinclair

+0

@LokiSinclair沒有'artisan route:clear' does – lukasgeiter

+1

運行artisan時,應用程序被引導,並且路徑被加載。如果存在語法錯誤,則停止執行,並且命令永遠不會運行 – Dencker

0

我有這個錯誤,但只有當我的本地計算機上運行。如果我在服務器上運行route:list,它工作正常。問題是我的電腦使用PHP v5.6,服務器使用PHP v7.0。

我在控制器中使用了新的??操作符,所以它拋出了一個語法錯誤,導致PHP v5.6不理解該操作符。