Skip to main content
Tutorial Free

Deployment tip: unexpected 'class' error in public/index.php

December 06, 2015
1 min read
I've unexpectedly encountered a situation which might be useful to someone deploying projects. When it's time to move projects from local environment to production (or staging) server, a lot of weird things might happen there. One of them is a parse error in public/index.php file. Basically, when trying to load your Laravel 5.1 project in the browser, you might see this: 1206_laraveldaily_class01 And if we look at the line 50 of public/index.php, it's this:
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
Looks like a normal PHP syntax, right? What could be wrong here? The thing is that syntax of ::class appeared only in version 5.5: see documentation. So if you see this error on your (or your client's server), it means that there's an older PHP version there. In my case, it was 5.4.40. With that, it's useful to remember the requirements for specifically Laravel 5.1 version: - PHP >= 5.5.9 - OpenSSL PHP Extension - PDO PHP Extension - Mbstring PHP Extension - Tokenizer PHP Extension For Laravel 5.0 it was all the same except PHP version: - PHP >= 5.4 Hope that small but real-life story helps someone. Happy deployment!

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.