Split controller into many files

Showing 1-6 of 6 messages
Split controller into many files Jonas 4/1/10 3:25 AM
Hello,

Is there some recommended way of splitting a controller into several
files? It's getting a bit too large for my taste but I cannot move the
functionality out to the models. I would rather have the possibility
of putting a separate page in a separate file. Is this possible with
Cake?

It's a booking site btw if it makes any difference.

Regards,
Jonas

Re: Split controller into many files Jeremy Burns 4/1/10 3:27 AM
You could move the functionality to a component? http://book.cakephp.org/view/993/Components

Jeremy Burns
jerem...@me.com

> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.

Re: Split controller into many files euromark 4/1/10 5:27 AM
sure
i did that with the user controller (used to be > 300kb)

e.g. controllers:
account (for changing account infos)
members (pagination and profiles)
overview (user statistics and stuff)
with their own views!

just use
$uses = array('User');
in all controllers to be able to use the same model+table


On 1 Apr., 12:27, Jeremy Burns <jeremybu...@me.com> wrote:
> You could move the functionality to a component?http://book.cakephp.org/view/993/Components
>
> Jeremy Burns
> jeremybu...@me.com

> On 1 Apr 2010, at 11:25, Jonas wrote:
>
>
>
>
>
> > Hello,
>
> > Is there some recommended way of splitting a controller into several
> > files? It's getting a bit too large for my taste but I cannot move the
> > functionality out to the models. I would rather have the possibility
> > of putting a separate page in a separate file. Is this possible with
> > Cake?
>
> > It's a booking site btw if it makes any difference.
>
> > Regards,
> > Jonas
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.

>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake...@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+u...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en

>
> > To unsubscribe, reply using "remove me" as the subject.

Re: Split controller into many files Richard@Home 4/1/10 6:29 AM
300kb sounds very large for even a complex controller.

Don't forget: Fat Model, Skinny Controller

Move all your controller queries into the model as methods, that
should slim down the controllers a bit

> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions.


>
> > > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > > To post to this group, send email to cake...@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+u...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> > > To unsubscribe, reply using "remove me" as the subject.

Re: Split controller into many files Jonas 4/4/10 4:33 AM
My controller is also around 300 kb. I've kind of inherited it, not my
basic design and I don't have time (or permission) to make any changes
like pushing functionality down to the models. The models is also
based upon a 3rd party API so there is a bookingservice which is
modelled in the booking.php model etc.

Is there a performance hit having a large controller? Would I get a
performance hit dividing the controller into components for each web
page and/or splitting the controller into perhaps booking / user /
invoice controllers?

Thanks for any input!

/Jonas

> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers with their CakePHP related questions.


>
> > > > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > > > To post to this group, send email to cake...@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > cake-php+u...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> > > > To unsubscribe, reply using "remove me" as the subject.

Re: Split controller into many files euromark 4/6/10 1:48 AM
actually, the performance hit is minimal!
it was just a cleaner way of grouping the actions (see above)
now they have a clean structure - in the url they are called as well
as in which file they are
and you dont have to use extensive routing to achieve that

so if there is no reason other than performance you might as well
stick to this one controller

> > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpotherswith their CakePHP related questions.


>
> > > > > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > > > > To post to this group, send email to cake...@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > cake-php+u...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> > > > > To unsubscribe, reply using "remove me" as the subject.