开发者

Code separation in cakePHP

I am developing an application in cakePHP which has two sets of methods : 1) Methods which are called from the mobile phone to process payme开发者_开发知识库nts 2) Methods which handle the website logic.

Now, the problem is that both the methods handling the mobile calls and the website logic are present in the same controller. This has made my code very difficult to manage.

Does anyone have any suggestions on how I can separate my code.

Thanks a lot


In the MVC architecture of CakePHP, each controller should be handling the transactions relating to one specific thing.

From the sounds of it, you should be separating your code into two controllers - one for payment, one for website logic


You could have more than one controller per model which would be the way I would go if there is no commonality across the two sub-applications, although if the number of models involved is significant this could result in many controller files.

On the other hand, if the number of methods is relatively limited, I would prefix the method names and group them together within one controller. I usually do this with ajax methods.

Most important is to be comfortable with whichever way you do it - you will probably be the one that maintains it!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜