user4210231
user4210231

Reputation:

Port a MVC PHP project into CakePHP

I'm new with CakePHP and I want to convert an existing PHP project into CakePHP. This project is already written using MVC, however the structure is not clear, models are not match with databases,different logic... (e.g. When I need to find something I cannot know where to look for.)

My 1st option is to read and understand deeply the code, see the data flow and then re-write most of the code into Cake. => Will take very long time.

I would like to ask, if there is any procedure/steps I could take to make it a little easier, something like keeping the old MVC files and structure, write code to map with Cake, keep the re-write to minimum, etc.

Thank you!

Upvotes: 0

Views: 67

Answers (2)

Lukasstr
Lukasstr

Reputation: 435

You could probably use ur old app as 3th party library in cakephp 3.0. But the cleaner and most likely easier way would be the port of application.

If you did your mvc job good it should be a lot of copy pasting.

Cakephp is convention over configuration so the first step you should probably do is adjusting your database to the cakephp convention: http://book.cakephp.org/3.0/en/intro/conventions.html .

When this is done you can use "cake bake all"(http://book.cakephp.org/3.0/en/bake.html) to generate the whole controller/model/view so you just have to adjust the files and don't have to create everything from scratch.

Upvotes: 0

Kevin Nagurski
Kevin Nagurski

Reputation: 1889

Unfortunately there probably aren't a lot of options beyond thoroughly reading the code and transitioning it to the new structure. If the existing code is properly structured, you should be able to work to transition existing views to Cake views etc and so on.

The best practice would be to write tests before refactoring to make sure that you 100% understand the existing code and don't break anything.

Upvotes: 1

Related Questions