Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE

Tags:

laravel-5

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

like image 850
rajkishor saw Avatar asked Aug 25 '15 13:08

rajkishor saw


4 Answers

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

like image 146
lukasgeiter Avatar answered Oct 15 '22 02:10

lukasgeiter


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 
like image 35
vinay saini Avatar answered Oct 15 '22 01:10

vinay saini


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

like image 26
风声猎猎 Avatar answered Oct 15 '22 00:10

风声猎猎


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.

like image 22
The Oracle Avatar answered Oct 15 '22 02:10

The Oracle