I have an enCrypt and deCrypt class which I want to use in my whole Zend Framework project without having to declare it on every need, but just once. Where should this be done? Thank you for any help…
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.
Zend Framework is quite flexible in implementing things.
You could create an instance in a bootstrap file and save it to the registry; whenever you need to call the class just get it from registry?
You could have every controller extend Zend_Controller_Action and put the two functions into this class (only ideal if you’re calling the classes from the controller).
Or, what I did, was make my functions static, register my own library (in your application config.ini file, enter the line:
autoloaderNamespaces[] = "MyPrefix_", then create a folder in the library folder called MyPrefix) and drop my class in there. When I need it I call$encryptedString = MyPrefix_Crypt::encrypt($string);and$string = MyPrefix_Crypt::decrypt($encryptedString);Hope this helps 🙂