laravel artisan 列出路线时出错
laravel artisan error when listing routes
我对 laravel 有点陌生,遇到了一些我不知道如何解决的问题,甚至不知道从哪里开始寻找。谁能解释一下吗?
当我运行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('/', 'DashboardController@index');
//Route::get('home', 'HomeController@index');
/**
* Page View Routes
* Author: Anthony Sinclair
* Date: 31/03/2015
*/
/** User GET for new Users created via the UI */
Route::get('user/new', 'UserController@create');
/** User POST for catching Users created via the UI */
Route::post('user/new', 'UserController@store');
/**
* 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}', 'SurveyResponseController@getResponsesForSurvey');
/** Survey Instigator - The sending of Surveys */
Route::resource('send/{survey_id}', 'SurveyInstigatorController@sendSurvey');
});
/** Nps based API call routing */
Route::get('/api/v1/nps/{survey_id}', 'NpsController@getNpsScore');
Route::get('/api/v1/nps/{survey_id}/{filter}', 'NpsController@getNpsScoreFilteredByMonths');
Route::get('/api/v1/nps/{survey_id}/{filter}/{modifier}', 'NpsController@getNpsScoreFilteredByModifier');
Route::get('/api/v1/nps/response/{survey_id}/{recipient_id}/{nps_score}', 'SurveyResponseController@requestSurveyResponse');
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
尝试转到 storage/framework
并删除 routes.php
。我怀疑语法错误可能已被缓存。
我有这个错误,但只有在我的本地计算机上 运行 时才会出现。如果我 运行 route:list
在服务器上,它工作正常。问题是我的电脑使用的是 PHP v5.6 而服务器使用的是 PHP v7.0.
我在控制器中使用了新的 ??
运算符,因此抛出了语法错误,原因是 PHP v5.6 不理解该运算符。
我对 laravel 有点陌生,遇到了一些我不知道如何解决的问题,甚至不知道从哪里开始寻找。谁能解释一下吗?
当我运行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('/', 'DashboardController@index');
//Route::get('home', 'HomeController@index');
/**
* Page View Routes
* Author: Anthony Sinclair
* Date: 31/03/2015
*/
/** User GET for new Users created via the UI */
Route::get('user/new', 'UserController@create');
/** User POST for catching Users created via the UI */
Route::post('user/new', 'UserController@store');
/**
* 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}', 'SurveyResponseController@getResponsesForSurvey');
/** Survey Instigator - The sending of Surveys */
Route::resource('send/{survey_id}', 'SurveyInstigatorController@sendSurvey');
});
/** Nps based API call routing */
Route::get('/api/v1/nps/{survey_id}', 'NpsController@getNpsScore');
Route::get('/api/v1/nps/{survey_id}/{filter}', 'NpsController@getNpsScoreFilteredByMonths');
Route::get('/api/v1/nps/{survey_id}/{filter}/{modifier}', 'NpsController@getNpsScoreFilteredByModifier');
Route::get('/api/v1/nps/response/{survey_id}/{recipient_id}/{nps_score}', 'SurveyResponseController@requestSurveyResponse');
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
尝试转到 storage/framework
并删除 routes.php
。我怀疑语法错误可能已被缓存。
我有这个错误,但只有在我的本地计算机上 运行 时才会出现。如果我 运行 route:list
在服务器上,它工作正常。问题是我的电脑使用的是 PHP v5.6 而服务器使用的是 PHP v7.0.
我在控制器中使用了新的 ??
运算符,因此抛出了语法错误,原因是 PHP v5.6 不理解该运算符。