Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split CakePHP's controller into several files

I have CakePHP controller with lot's of code in it... What is best practice to split controllers into several files?

Thank you in advance!

like image 781
user198003 Avatar asked Dec 04 '25 20:12

user198003


1 Answers

You have to separate your logic:

  • User different controllers for tasks related to different models (e.g. products_controller.php, carts_controller.php).
  • Separate the business logic into the model (fat model approach).
  • Separate re-used controller logic in components.
  • Make your code DRY (Don't repeat yourself)
like image 134
Mark Avatar answered Dec 07 '25 15:12

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!