CakePHP 1.3 Loading a component at runtime
-
29-10-2019 - |
Question
I'm required to load a component that contains a class that extends an object from a vendor.
As the vendor is loaded at runtime and the compenent is loaded at the initialisation of the controller, the script crashes.
How can I load this component at runtime and what class/filename convention should I use (CakePHP 1.3)?
Solution
You can use the App:import()
method to load at run time.
<?php
App::import('Component', 'Mailer');
// We need to load the class
$Mailer = new MailerComponent();
?>
From the manual : http://book.cakephp.org/view/936/Importing-Controllers-Models-Components-Behaviors-#Loading-Components-939
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow