在CakePHP中配置多个应用程序使用通用控制器模型视图?

时间:2012-09-26 09:57:44

标签: cakephp cakephp-1.3

在CakePHP中为通用控制器,模型和视图开发多个应用程序的最佳方法是什么?有没有人有想法开发这种类型的应用程序?

2 个答案:

答案 0 :(得分:1)

这就是插件的用途 - 您可以创建一组控制器,模型,视图(以及更多),将它们打包在一起,然后将它们部署到所有应用程序。请参阅the CakePHP cookbook for specifics

使用此方法会为您的网址添加额外的插件部分,可以通过提供路由规则来修复。

答案 1 :(得分:-1)

有两种方法可以做到这一点。

  1. 将常用控制器,模型和视图打包为插件
  2. 将您的公共代码放在一组单独的目录中,并使用bootstrap.php中的App::build()来包含这些目录:
  3.  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/')
      ));
    
相关问题