Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要加载一个组件,该组件包含一个扩展来自供应商的对象的类。
由于供应商在运行时加载并且组件在控制器初始化时加载,因此脚本崩溃。
如何在运行时加载这个组件以及我应该使用什么类/文件名约定(CakePHP 1.3)?
您可以使用该App:import()方法在运行时加载。
App:import()
<?php App::import('Component', 'Mailer'); // We need to load the class $Mailer = new MailerComponent(); ?>
从手册:http ://book.cakephp.org/view/936/Importing-Controllers-Models-Components-Behaviors-#Loading-Components-939