in CakePHP book example here
I try:
cake bake all
then I choose 1 for Group
but i get an error
Notice: Undefined property: ModelTask::$useDbConfig in
/opt/lampp/htdocs/acl_cake/cake/console/libs/tasks/model.php on line
848
Fatal error: ConnectionManager::getDataSource - Non-existent data
source in
/opt/lampp/htdocs/acl_cake/cake/libs/model/connection_manager.php on
line 109
I solved the problem temporarily by adding
$this->useDbConfig = 'default';
at line 848 of the file cake/console/libs/tasks/model.php
before the instruction
$data = $schema->read(array('models' => false, 'connection' => $this->useDbConfig));
And now the bake all is working.
Related
Deprecated: PHP configuration files like "app.php" should not set $config. Instead return an array. - C:\composer\upgrade\vendor\cakephp\cakephp\src\Core\Configure.php, line: 343
You can disable deprecation warnings by setting Error.errorLevel to E_ALL & ~E_USER_DEPRECATED in your config/app.php. in C:\composer\upgrade\vendor\cakephp\cakephp\src\Core\functions.php on line 311
Exception: If config is null, key must be an array. in [C:\composer\upgrade\vendor\cakephp\cakephp\src\Core\StaticConfigTrait.php, line 79]
I just follow the tools. How to remove the error?
Very simply, as the error message indicates, you need to return an array instead of setting $config. Change
$config = [
to
return [
I have a setting in my APP/Config/config.php I have a line that defines the host:
define('SITE_URL','http://'.$_SERVER['HTTP_HOST']);
Whenever I run the cake console, I get the error:
Notice (8): Undefined index: HTTP_HOST [APP/Config/config.php, line 144]
Code Context
include - APP/Config/config.php, line 144
PhpReader::read() - CORE/Cake/Configure/PhpReader.php, line 80
Configure::load() - CORE/Cake/Core/Configure.php, line 267
include - APP/Config/bootstrap.php, line 190
Configure::bootstrap() - CORE/Cake/Core/Configure.php, line 92
require - CORE/Cake/bootstrap.php, line 146
ShellDispatcher::_bootstrap() - CORE/Cake/Console/ShellDispatcher.php, line 131
ShellDispatcher::_initEnvironment() - CORE/Cake/Console/ShellDispatcher.php, line 101
ShellDispatcher::__construct() - CORE/Cake/Console/ShellDispatcher.php, line 57
ShellDispatcher::run() - CORE/Cake/Console/ShellDispatcher.php, line 68
[main] - APP/Console/cake.php, line 33
Why is this appearing and how can I solve this problem?
Its because you are running from console, (cakePHP uses PHP-CLI)
$_SERVER['HTTP_HOST']
its only filled when running from a browser (web server)
#Braian is right.
You could do the following in your config file:
if(php_sapi_name() === 'cli') {
define('SITE_URL','http://{DEFAULT HOST HERE};
} else {
define('SITE_URL','http://'.$_SERVER['HTTP_HOST']);
}
Alternatively, you could query your database for a host setting of some sort - if your hosts are different based on the environment - and use Configure::write to set your config value before your console scripts main logic is run.
After transferring over a finished site to a new server, files/database and all, switching over the database settings in settings.php and running update.php I get the following errors:
Notice: Undefined index: name in block_menu() (line 146 of /home/nrsc2533/public_html/modules/block/block.module).
Notice: Undefined index: name in block_menu() (line 165 of /home/nrsc2533/public_html/modules/block/block.module).
Notice: Undefined index: name in system_menu() (line 647 of /home/nrsc2533/public_html/modules/system/system.module).
Notice: Undefined index: name in block_menu() (line 146 of /home/nrsc2533/public_html/modules/block/block.module).
Notice: Undefined index: name in block_menu() (line 165 of /home/nrsc2533/public_html/modules/block/block.module).
Notice: Undefined index: name in system_menu() (line 647 of /home/nrsc2533/public_html/modules/system/system.module).
I also lose most if not all of the items in the admin menu. I looked up the errors and they were all related to the following line of code:
'title' => check_plain($theme->info['name']),
This is a free theme that I customized, it is working fine on my test domain on my server, but not now that it has transferred. I did change the [theme].info file to reflect that it had been customized on the "name =" line. I checked online and found that the encoding may have been changed when I saved it, again strange since I had done this on the test domain and it seemed fine, so I changed the encoding to UTF-* without BOM and still to no avail. I have tried clearing the cache again via update.php and nothing changes. Any help will be GREATLY appreciated.
I get the above error notice in many pages on my drupal site.
Notice: Undefined index: node in workflow_tokens() (line 188 of
/home/lafune27/public_html/sites/all/modules/workflow/workflow.module).
Notice: Trying to get property of non-object in workflow_tokens()
(line 189 of
/home/lafune27/public_html/sites/all/modules/workflow/workflow.module).
Kindly help.
here's a
Looks like it might be a bug. There is an issue open for it on drupal.org. See comment #2 in http://drupal.org/node/1485816
I'm trying to get mongodb to work with cakephp. I'm not sure on where to place ichikaway's mongodb driver for cakephp and where to add the database connection.
My directory structure is that, under c:/websites/, I have cakephp folder and my project merry_flowers folder.
i've already gone through ichikaway's github and mark story's website.
If I put the mongodb driver in \cakephp\app\plugins and database connection in \cakephp\app\config\database.php
I'm getting the following error:
fatal error 256: ConnectionManager::loadDataSource - Unable to import DataSource class mongodb.mongodbSource [CORE\cake\libs\model\connection_manager.php, line 185]Code | Context
if (!App::import('Datasource', $class, !is_null($conn['plugin']))) {
trigger_error(sprintf(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s', true), $class), E_USER_ERROR);$connName = "mongo"
$_this = ConnectionManager
ConnectionManager::$config = DATABASE_CONFIG object
ConnectionManager::$_dataSources = array
ConnectionManager::$_connectionsEnum = array
$conn = array(
"plugin" => "mongodb",
"classname" => "mongodbSource",
"parent" => array(
"filename" => "dbo_source",
"classname" => "DboSource",
"parent" => null,
"plugin" => null
),
"filename" => "dbo\mongodb_source"
)
$class = "mongodb.mongodbSource"ConnectionManager::loadDataSource() - CORE\cake\libs\model\connection_manager.php, line 185
ConnectionManager::getDataSource() - CORE\cake\libs\model\connection_manager.php, line 109
Model::setDataSource() - CORE\cake\libs\model\model.php, line 2836
Model::__construct() - CORE\cake\libs\model\model.php, line 469
ClassRegistry::init() - CORE\cake\libs\class_registry.php, line 142
Controller::loadModel() - CORE\cake\libs\controller\controller.php, line 637
Controller::constructClasses() - CORE\cake\libs\controller\controller.php, line 493
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 186
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 87
If I put the mongodb driver in \merry_flowers\plugins and add the database connection to \merry_flowers\config\database.php, I'm getting the following error:
connecting to localhost:27017 failed: Unknown error APP\plugins\mongodb\models\datasources\mongodb_source.php, line 201
thank you.
It doesn't matter which plugins folder you use. Both have the same functionality. Both are included for your organizational convenience.
Do you have a mysql database set up also? If so, there might not be documentation for a dual installation. If you only have one DB, you should be configuring it in cakephp/app/config/database.php