Laravel 5 new declaration causing an error - laravel-5

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?

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.

Related

Error, Lcobucci\JWT\Signer\InvalidKeyProvided: It was not possible to parse your key

I hope you are doing fine. I was working on Oauth passport laravel, it was working fine on my previouse machine but i had to switch machines.My new machine has php 8 and my laravel project is of 7.30.0 version and my lcobucci/jwt version is 3.3.3. When i try to hit register route on postman i get the following error
Lcobucci\JWT\Signer\InvalidKeyProvided: It was not possible to parse your key, reason: in file C:\Users\user\Documents\GitHub\myproject\vendor\lcobucci\jwt\src\Signer\InvalidKeyProvided.php on line 17
As you can see on https://packagist.org/packages/lcobucci/jwt#3.3.3, that JWT package is officially not compatible with PHP 8. You should upgrade it to a compatible version (at least v4), or downgrade your PHP version to v7
This is coming super late.
For anyone still experiencing this, just generate a new jwt secret.
This command will generate a new key that fits the new requirement
php artisan jwt:secret

How can I force Laravel to use another encryption system other than mcrypt?

I'm updating the my server PHP version from 5.6 to 7.2, and now I can no longer use mcrypt. I'm completely lost as how should I try, but I already tried to changing the cipher from MCRYPT_RIJNDAEL_128 to AES-256-CBC in the file config/app.php, with no avail. So, how can I change it? I have laravel 5.0.

Upgrade laravel from 5.1 to 5.8 and artisan commands are not working in laravel 5.1

I have a project which is developed in laravel 5.1 now which client wants some updates where he want to upgrade laravel version to 5.8 but and to add some new functionality but this is 2nd issue 1st issue this terminal is throwing the error of each when run php srtisan
C:\xampp\zerodocs>php artisan
[ErrorException]
The each() function is deprecated. This message will be suppressed on further calls
The PHP each() function was deprecated in PHP 7.2. It seems you are using PHP 7.2 or higher. You will need to follow the upgrade guides and use composer to upgrade from Laravel 5.1 to 5.8.
https://laravel.com/docs/5.3/upgrade
https://laravel.com/docs/5.4/upgrade
https://laravel.com/docs/5.5/upgrade
https://laravel.com/docs/5.6/upgrade
https://laravel.com/docs/5.7/upgrade
https://laravel.com/docs/5.8/upgrade
Or, you will need switch to a compatible PHP version (e.g., PHP >= 5.5.9 as mentioned in the documentation for Laravel 5.1) to use the application.

cartalyst/converter on laravel 5.6

I'm trying to setup cartalyst/converter on laravel 5.6 Their link is here: https://cartalyst.com/manual/converter/2.0
I'm following official instruction and getting
Call to undefined method Illuminate\Foundation\Application::share()
I feel like Cartalyst\Converter\Laravel\ConverterServiceProvider is not livable.
How else can I install it?
They have "Native" way, but in laravel case where would I put their "native" code?
Illuminate\Foundation\Application::share() method was removed in Laravel 5.4, in favor of the singleton() method.
Do you need to use v2.0 of this package? 3.0 was released specifically to stay up-to-date with Laravel. I suggest using the most recent version instead of the 2.0 branch.
https://cartalyst.com/manual/converter/3.0

Upgrading to Laravel 5.2

having some issues trying to upgrade to Laravel 5.2 from the previous latest version.
On composer update or any artisan class I get the follow error ...
Class validator does not exist
Can not work out whats going on at all.
Any ideas?
Many thanks!
Turns out Whoops was catching a HttpResponseException of which the upgrade docs do say could cause issues. So removed Whoops as problem solved.

Resources