Strategy for migrating a large CakePHP project to Laravel

FrodeMMeling posted 4 years ago

Hello Is there anyone that have migrated from CakePHP to Laravel? What is best approach to do this when it is not possible to rewrite everything at once. Application needs to coexist with both frameworks during transition. With CakePHP 3 coming up with lots of changes, the amount of work upgrading to 3.0 may be similar to start using Laravel instead.

hernandev replied 4 years ago

Don't put the app running on two frameworks or some similiar, it will become really painful to maintain, start migrating and put all on laravel when it's done, without half transitions.

Just my 2 cents.

FrodeMMeling replied 4 years ago

This is a pretty large complex business-application. Migration will take several months to complete. It is also in constant development with new features.

I am looking at different approaches:

  • Get Eloquent to work in Cake as a first step
  • Get Laravel router to dispatch CakeControllers and Views so we can migrate businessmodule by businessmodule
  • Also an option is to make an Laravel API of the business-logic.
Ehesp replied 4 years ago

Although this doesn't help with the question, I have to ask - why?

What benefits are you going to get from Laravel that Cake doesn't provide? Sure there might be things which Laravel does better and makes easier, but is the months of development time and money worth that - as you'll be able to do anything in Cake which Laravel can do, just how it's done is different.

I ask this, because a company I also work with thought about doing this but said no as there were no massive benefits for the dev time involved.

FrodeMMeling replied 4 years ago

If you read my first post, you will see that just upgrading our project to cake 3.0 will take many hours, since alot in model layer has changed. So I am not sure the amount of work is that different.

My real question here is if it is possible to wrap a cakeApp inside Laravel in the transision period, or vice versa.

dslawrence replied 4 years ago

Yes, you can have one site running on both frameworks at once without having them step on each other. I've done this before by:

  1. Creating a single config.php at the top level with some globals in it, then modifying the config in Laravel and Cake so that they use those globals (so the database, etc, only need to be entered in one place)
  2. Combining the databases (this is the part where things may go awry--if you have tables that have the same names you'll have problems. In my case only the "users" tables collided, and we found that their fields meshed well when you combined their data)
  3. Create a single "public" folder that laravel/public and cake/app/webroot point to, then have Apache serve that
  4. Have laravel and cakePHP use their own "index.php" files to kick-start themselves, but make public/index.php a file that knows which routes go to which frameworks and routes requests accordingly, like:


if (preg_match("/^\/(user\/|admin|app|content|wall)/", $_SERVER['REQUEST_URI'])) {
} else {
amrigo replied 3 years ago

Hi dslawrence

Could you please provide more in-depth details about the steps ? specially about step 3 and 4 ?

mantasradzevicius replied 3 years ago


3 step could be accomplished with a simple symlink (assuming the os is linux):

-- laravel
--- public/ -> symlink to ../public
-- cakephp
--- webroot/ -> symlink to ../public
-- public/
--- index.php <- as shown in 4 step.

Then apache vhost config webroot should point to project/public.

amrigo replied 3 years ago

great ! thankĀ“s @mantasradzevicious

amrigo replied 3 years ago

@dslawrence How can you get the cakephp session in order to keep the user authenticated from cakePHP to Laravel ?

astroanu replied 3 years ago

May i ask what are the targets you're trying to achieve by migrating to Laravel?

amrigo replied 3 years ago

@astroanu in my case the cakephp app have many modules and the migration to version 3 would not be so fast as the development in Laravel. So i need to migrate module by module to laravel and then turn off cakephp. Only need to discover how to maintain the login routing from cake to laravel or from laravel to cake.

astroanu replied 3 years ago

I see then the method described by @dslawrence would definitely work. It is dirty but will work.

amrigo replied 3 years ago

In my situation i would like that a cakephp session would be valid to generate a login into laravel, just can not see the way this can be done, if it can be done.

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us