我对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
答案 0 :(得分:3)
尝试转到storage/framework
并删除routes.php
。我怀疑语法错误可能已被缓存。
答案 1 :(得分:0)
我遇到此错误,但只有在本地计算机上运行时才会出现此问题。如果我在服务器上运行route:list
,它运行正常。问题是我的计算机使用的是PHP v5.6,服务器使用的是PHP v7.0。
我在控制器中使用了新的??
运算符,因此抛出语法错误导致PHP v5.6无法理解该运算符。