tags:

views:

38

answers:

2

Hi,

I am developing an application in cakePHP which has two sets of methods : 1) Methods which are called from the mobile phone to process payments 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

+1  A: 

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

Jamie Wong
Agreed, the solution lays in your systems design.
DavidYell
+1  A: 

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!

Leo
I agree with the prefixing solution. I suspect that the single controller is the right way to go. If everything is in there in the first place, it probably should be and the question boils down to how to make the methods more discreet. If common logic is separated out to private/protected methods, finder can share what's left.
Rob Wilkerson