0

The error is:

Parse error: syntax error, unexpected 'class' , expecting identifier or variable OR '{' OR '$' in c:\xampp\htdocs\laravel\artisan on line 31.

First of all, I haven't made this project but it was running with no problems(it still seems to run ok but I can't run any artisan commands!!). The version of laravel it was running was 5.2 while php was 5.4.31 as it is shown on cmd, although when I run phpinfo() function on xampp it shows 5.6.23. Why is that?

I haven't changed one bit of the code. It started doing this after I had been trying to create another project of laravel in a local folder. Every time I deleted it and installed it again, it kept downloading it on laravel 5.0. What can I do?

I can't update php version because there are a lot of projects that are running on the server and I am afraid I will mess it up.

  • Depends on your environment. Your local hosted version of Laravel is probably different to your system version. How are you serving your app? – CUGreen Jan 13 '17 at 07:53
  • The app that is not working was running from xampp. My project was running locally with artisan serve –  Jan 13 '17 at 08:51
  • Exactly, so your system (CMD) version of php does not meet the requirements. You will need to upgrade it to >5.5. – CUGreen Jan 13 '17 at 08:57
  • The thing is that it was playing perfectly until something changed in the environmental variables when I uninstalled and reinstalled my project!! Also, I already told you the reason why I can't upgrade to a newer version... –  Jan 13 '17 at 09:23

1 Answers1

1

If you open up the artisan file, you will see line 31 is doing this:

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

::class is only available from PHP 5.5 onwards so, tl;dr, you can't run laravel 5.2 on PHP 5.4.

So to solve this, in your windows environment, simply point php to run on your php 5.6 variant and that should solve it.

Lionel Chan
  • 7,894
  • 5
  • 40
  • 69
  • How do I do this? From environment variables->user variables? To what do I change the path? Now it has C:\Users\....\AppData\Roaming\Composer\vendor\bin –  Jan 13 '17 at 08:55
  • Plenty of tutorials online: https://www.google.com.sg/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=xampp%20php%20environment%20variable – Lionel Chan Jan 13 '17 at 08:58
  • I added the path where php.exe is but still nothing changed, php artisan command on cmd shows the same error. –  Jan 13 '17 at 09:09
  • Should I put it in User variables or System variables? Nevermind, it doesn't play either way... HELP? –  Jan 13 '17 at 09:15
  • Try closing your command prompt and start another new cmd window - that should usually help :) [See here for differences between user variables & system variables](http://stackoverflow.com/questions/4477660/what-is-the-difference-between-user-variables-and-system-variables) – Lionel Chan Jan 13 '17 at 09:21
  • Ok, I did it! Thank you very much all! –  Jan 13 '17 at 09:25