Creating a CakePHP REST api from an existing project

≡放荡痞女 提交于 2020-01-05 10:18:31

问题


I have a webapp which I am planning on converting into a REST api and have decided to use CakePHP for this - the current form is written in ColdFusion.

The database is a couple million records in size with 20 tables or so and a few associative tables that handle the many-to-many situations.

I'm looking for the best method to start the CakePHP solution mainly in regards to the database. Should I import my existing db and just use cake to access its current form? Should I bake a fresh database structure (in order to stay within the cake standards) then figure out how to get my data into the new db, and maintain relationships etc (how?)?

Edit:

There are many users on the existing app, but when the new CakePHP api is setup and ready to go, the old service will be closed to use the new one.

The current app is not designed in an MVC way, are you referring to Models as being synonymous with Tables? There are many existing tables with foreign key relationships but they are not named using the CakePHP standards - so not sure if this will break CakePHP or make its features not as usable.

Time is an issue, but I'd rather take the time now and get it done the correct way, instead of having to re-visit shortly.


回答1:


I largely depends on your situation:

  • Are there people using the old application? - This will mean you can't really create another database for your new app if you want to access new information.

  • Is there really a need to change the relationships of models? - I don't think you should change unless you really need to.

  • Cost - How much time are you willing to spend on the migration?

Note: You can modify almost everything on your model to cope up with the previous database/table structure.



来源:https://stackoverflow.com/questions/16264546/creating-a-cakephp-rest-api-from-an-existing-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!