CakePHP v3.x如何在没有数据库连接的情况下进行烘焙

时间:2015-10-22 02:32:23

标签: php cakephp cakephp-3.0 cakephp-bake

我使用CakePHP v3.x并且我的应用程序没有任何型号,但我想支持几个视图或控制器。

$ bin/cake bake template Reports

我试过了: *使用带有false或空字符串的--connection选项 *从app.php中删除Datasources *离开Datasources但将Datasources['default']设为false

所有这些都会导致错误:

Welcome to CakePHP v3.1.2 Console
---------------------------------------------------------------
App : src
Path: /Applications/MAMP/htdocs/listings/src/
PHP : 5.6.10
---------------------------------------------------------------
Exception: The datasource configuration "default" was not found. in [/Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Datasource/ConnectionManager.php, line 187]
2015-10-22 02:30:48 Error: [Cake\Datasource\Exception\MissingDatasourceConfigException] The datasource configuration "default" was not found.
Exception Attributes: array (
  'name' => 'default',
)
Stack Trace:
#0 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/ORM/Locator/TableLocator.php(164): Cake\Datasource\ConnectionManager::get('default')
#1 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/ORM/TableRegistry.php(109): Cake\ORM\Locator\TableLocator->get('Reports', Array)
#2 /Applications/MAMP/htdocs/listings/vendor/cakephp/bake/src/Shell/Task/TemplateTask.php(282): Cake\ORM\TableRegistry::get('Reports')
#3 /Applications/MAMP/htdocs/listings/vendor/cakephp/bake/src/Shell/Task/TemplateTask.php(147): Bake\Shell\Task\TemplateTask->_loadController()
#4 [internal function]: Bake\Shell\Task\TemplateTask->main('Reports')
#5 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/Shell.php(447): call_user_func_array(Array, Array)
#6 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/Shell.php(442): Cake\Console\Shell->runCommand(Array, false)
#7 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(212): Cake\Console\Shell->runCommand(Array, true, Array)
#8 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(179): Cake\Console\ShellDispatcher->_dispatch(Array)
#9 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(126): Cake\Console\ShellDispatcher->dispatch(Array)
#10 /Applications/MAMP/htdocs/listings/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#11 {main}

1 个答案:

答案 0 :(得分:0)

我怀疑这会很快发挥作用。您可以在Github上创建功能请求类型票证但不太可能发生,因为bake使用数据库架构来读取字段并根据架构构建所有内容。

Table类从Cake2取代了Model,不再允许$useTable = false。因为表需要DB表。对于少模型see this link