Shivamyadav's avatar

How to migrate the laravel project from 4.1 to 4.2?

Currently I have assigned a project to migrate it. As this is the first time I am working on the migrating the older project.

Current Working state:

  1. I have installed a new fresh laravel 4.2 project and according to the upgrade guide I have makes the necessary changes and put the copied existing older project with laravel version 4.1.
  2. New fresh project is using the php 7.3 and mysql 9.
  3. I have copied the the older project composer.json to the new project but kept the laravel version to the 4.2 and other things.
  4. Now when I ran any artisan command I get this error Mcrypt PHP extension required.

How to fix it. I have tried to resolve it from the AI too but It seems not working.

Any help would be appreciated.

0 likes
13 replies
Glukinho's avatar

Are you sure it is worth the effort to upgrade from 4.1 to 4.2 taking into account actual Laravel version is 12?

Maybe pay these guys? https://laravelshift.com

3 likes
JussiMannisto's avatar

Laravel 4.1 is ancient and I wouldn't try to migrate it step by step.

  • The intermediate versions won't work with modern PHP versions. Laravel 4 doesn't support PHP 7+.
  • The intermediate versions will require obsolete or completely removed extensions, as you found out with Mcrypt.
  • You'll have to rewrite parts of the app completely along the way. Laravel 4 doesn't even have middleware. It used filters instead, which were removed in L5.

If I were you, I'd create a fresh Laravel 12 project with PHP 8.x, and start moving the business logic from the old app to the new one, piece by piece.

You'll still have to read every upgrade guide along the way, especially the major version ones.

6 likes
Shivamyadav's avatar

Yeah but I need to make sure I follow every steps properly if by mistake I missed any of them then I think I will have to face major issues.

vincent15000's avatar

Why only migrate to 4.2 ? This could be done by following the upgrade guide.

But I suggest you to migrate to Laravel 12.

For such a migration, I suggest you to create a new Laravel application and copy / paste the code from your old application to your new one. Then you will have to change some code to be compatible with the recent PHP versions and with the new structure for the application folder.

2 likes
Shivamyadav's avatar

If you were in my place what's was your approach to migrate the older project to at least Laravel 8

1 like
Snapey's avatar

Start a Laravel 12 project and replicate all the functionality. Don't even try to do a step by step upgrade.

You will face far fewer problems this way, plus you will actually understand the project.

3 likes
Shivamyadav's avatar

Thanks snapey. This weekend I will try it to upgrade it with Laravel 12.

1 like
martinbean's avatar

@shivamyadav How large is the project? Because a project running a version of Laravel as ancient as 4.1 (which was released over a decade ago, in December 2013), it might be just as much effort to start over with Laravel 12. But if you are going to start over, I’d wait a couple of weeks, because Laravel 13 is due for release this quarter, so you’re already going to be a version out of date by the time you finish.

I’d then also be asking my boss if they’re going to set aside time to keep projects up to date so you’re not in this exact same position a couple of years down the line, where you have web applications running on old versions of PHP and Laravel that has since stopped receiving security patches.

1 like
jlrdw's avatar

I agree with @martinbean but to add: When updating / upgrading let's say from 11 to 12 for example.

The actual laravel and framework upgrade is pretty quick to do. But some external packages may not be ready yet. I have found giving packages a month or two to catch up is good.

Almost all questions concerning upgrade problems stem from an external package or library hasn't been updated yet.

Just FYI for reference.

1 like
Snapey's avatar

@jlrdw I take your point and in general it is very valid, but a 4.1 application isn't likely to be running any packages as composer was only just added at V4

Please or to participate in this conversation.