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

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!

No comments or questions yet...

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 57 courses (1055 lessons, total 46 h 42 min)
  • 78 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent Premium Tutorials