Can any one provide me some tips to write reusable code in PHP / CakePHP?
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.
Okay, I’ll bite. You’d code it almost exactly as you would code it in the individual controllers, you just need to replace the parts that vary with variables.
Read through Cake’s source code to learn what variables are there for you to use. Read through more source code, especially of Components and Behaviors, which by definition are reusable, to learn more specific techniques.