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)?

Was it helpful?

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
scroll top