2015-12-27 20 views
1

我打算開發一個在composer包中繼承的CakePHP 2插件。該軟件包安裝在「APP/Vendor」目錄中。而我的插件是在「APP /插件」。如何在CakePHP插件中使用composer包

我應該把我的插件文件App::import('Vendor', array('file' => 'autoload'));

回答

3

如果app/Vendor包與composer安裝,自動加載應由

require APP . 'Vendor/autoload.php'; 

app/Config/bootstrap.php照顧。

但是,如果它被下載並複製到/app/Vendor,你應該將其導入手動:

App::import('Vendor', 'packageFolder/filename'); 

這同樣適用於插件。如果您在Plugin/PluginName/composer.json"require":內聲明您的依賴關係,這些將與您的插件一起安裝,並添加到app/Vendor/autoload.php,因此無需手動導入。

如果包下載到/app/Plugin/PluginName/Vendor/,你將不得不通過

App::import('Vendor', 'PluginName.packageFolder/filename'); 
加載它
相關問題