2012-09-26 31 views

回答

1

這是插件的用途 - 您可以創建一組控制器,模型,視圖(以及更多),將它們打包在一起,然後將它們部署到您的所有應用程序中。見the CakePHP cookbook for specifics

使用這種方法會爲您的url添加一個額外的插件部分,這可以通過提供路由規則來解決。

-1

有兩種方法可以做到這一點。

  1. 包您共同控制器,模型&意見作爲一個插件
  2. 把你常用的代碼在一個單獨的目錄組和bootstrap.php中使用App ::編譯(),包括這些目錄:

    App::build(array( 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'), 'models' => array('/full/path/to/models/', '/next/full/path/to/models/'), 'views' => array('/full/path/to/views/', '/next/full/path/to/views/'), 'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'), 'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'), 'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'), 'components' => array('/full/path/to/components/', '/next/full/path/to/components/'), 'helpers' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'), 'vendors' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'), 'shells' => array('/full/path/to/shells/', '/next/full/path/to/shells/'), 'locales' => array('/full/path/to/locale/', '/next/full/path/to/locale/') ));

+0

感謝,但應用::建設CakePHP的1.2不可用,但是我用配置::寫( 'controllerPaths',$ controllerPaths);它的工作正常 – Chirag

相關問題