What is the best strategy if you find your controller’s code not readable and messed up because of heavy view logic? Use helper, service or something else?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best practice is to have all the logic encapsulated in services. The code will be more decoupled and easy to maintenance. Decide between small services or big ones is your responsibility, but the best practice is to have services with one defined functionality, moderate size, maintainable and testable
If the logic is to get data from a form, or is related to a form, the best option is use a handler to encapsulate the form logic. You can see a live example of handlers in FOSUserBundle.