shaNnex
shaNnex

Reputation: 1083

Laravel 5 new declaration causing an error

I am using Laravel 5.0.3 for one project few days ago. Now I create another project using the same version but I noticed the declaration (or whatever you call it) has changed from something like:

'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode'

to

\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class

and this is actually causing an FatalError. My idea is that this is something to do with the php version, but I don't want to update just yet.

What options do I have to sort this issue?

Upvotes: 0

Views: 96

Answers (1)

Burak Ozdemir
Burak Ozdemir

Reputation: 5332

It's called class name resolution and a new feature that is implemented in PHP 5.5. The reason that you are getting that error is your PHP version of your PHP interpreter should be lower than PHP 5.5. Don't forget that Laravel 5.1 LTS package requires PHP 5.5.9 version minimum. You can keep your old configuration as 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode' instead of \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class. But first, you should also downgrade your Laravel version from 5.1 to 5. Better and recommended is to upgrade your PHP version as PHP 5.4 will be soon deprecated.

Upvotes: 1

Related Questions