17
votes

I am currently developing an app with Laravel 5 and suddenly the artisan stoped working!

I can't use a single command on it, it always return the error:

      [Symfony\Component\Debug\Exception\FatalErrorException]
      syntax error, unexpected ',', expecting variable (T_VARIABLE)

I tried to update via composer but when the artisan tries to clear-complie

Command: composer update

> php artisan clear-compiled

  [Symfony\Component\Debug\Exception\FatalErrorException]
  syntax error, unexpected ',', expecting variable (T_VARIABLE)

Has anyone ever had this error before?

My Php version is 5.6.8

7
Didn't you recently moved to another web server ? What is your php version ?Eimantas Gabrielius
remove full vendor folder and then run the "composer update" command againImtiaz Pabel
Anywhere in your app.php or a configuration file is a error. What does laravel.log log?baao
Looks like you either added , somewhere which is creating a syntax error or it's your php version. cd to your website directory and run find . -name \*.php -exec php -l "{}" \; in your terminal. If it comes up with a lot of things, it's probably your php version.user1669496
@EimantasGabrielius My Php version is 5.6.8 and I didn't move to another web server .gabahulk

7 Answers

24
votes

I've found the error!

I had a syntax error on my routes.php file...

function($id,**name**,**value**)

Forgot the $ sign and thus it found a unexpected ','.

Thank you all for the help!

11
votes

Try this command:

php -S localhost:8000 -t public

Then execute it on browser, it will produce the error, just look at the error, and fix it.

3
votes

Instead of executing the commands using command prompt. It will be easy to look at LOG file found at location/directory

storage/logs/laravel.log

I am sure, you can easily check the log file and fix the syntax error.

1
votes

I recently ran into this same error, although the error was probably a different cause from yours. Turns out we had recently updated to PHP 7 and I hadn't upgraded yet. The issue was caused by a return type being set on a function, which wasn't supported in my local version of php. Ran an update on Homestead, which upgraded my PHP version and fixed the issue.

1
votes

Try running with the verbose argument, like so:

php artisan ... --verbose
0
votes

None of these solutions will always work.

php artisan tinker --verbose will often not give you the stack trace which will show the source of the error.

running in the browser will also not always give the error.

The solution is simple : look in storage/logs/laravel.log there the full stack trace will show

For ease of finding (if file is huge), open the file, delete all contents, run tinker and when come back only the specific error info will be there.

Hope this helps someone else

-1
votes

I have received the same error in routes.php. I have given the wrong Route.

I put Route::get('/admin' , AdminController@index); instead of Route::get('/admin' , 'AdminController@index');

I forgot single quotes. Please check yours.