36
votes

After installing laravel we get an error:

Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in C:\xampp\htdocs\laravel\public\index.php on line 50

6
I still have this problem, and we cannot put our laravel application live. We are using php 5.6. for apache and for command line. "php -v" gives "5.6"John Little
Did you create key?Agil

6 Answers

45
votes

Laravel 5.1 uses the ::class property to get string representations of a fully qualified classname. The error you're seeing is caused by this line

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

This language feature has been introduced in PHP 5.5 which is a requirement of Laravel 5.1. Your installed PHP version is probably older than 5.5. Try to update your PHP binary.


In case you are interested in why ::class is used, take a look at this answer

7
votes

Same thing happened to me also. I found that web server was using my old PHP version 5. To solve it for me, I did this -

sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart
4
votes

Your php version is too low. Try version 7.0 or later php.

2
votes

Your PHP version on your Xampp is lower than 5.5.9 as specified in the Laravel 5.1 doc.

Simply uninstall your current Xampp software and download a fresh copy at Apache website with this specification 5.6.12 / PHP 5.6.12 .

Do not forget to collaborate with your host provider to ensure that your hosting account runs the required PHP version (>=5.5.9) during the deployment of your Laravel 5.1 app online.

0
votes

I was facing the same error but error was in app/User.php line 10. Actually, line 10 was ok but before line 10 I was missing some php syntax.

After correct the php syntax error It was fixed. So you have to check C:\xampp\htdocs\laravel\public\index.php on line 49 carefully I am sure there is something wrong. Just try to correct. It will be fixed.

-1
votes

Go to line 50 and check that there is a semi colon that terminates the code