mongodb cakephp driver installation - cakephp

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

Related

cakePHP:Tried running this code in cakePHP

C:\xampp\htdocs\my_app\bin>cake bake migration_snapshot Initial
PHP Warning: Module 'intl' already loaded in Unknown on line 0
Exception: Database driver Cake\Database\Driver\Mysql cannot be used due to a missing PHP extension or unmet dependency
In [C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Database\Connection.php, line 202]
2021-02-09 08:52:48 Error: [Cake\Database\Exception\MissingExtensionException] Database driver Cake\Database\Driver\Mysql cannot be used due to a missing PHP extension or unmet dependency in C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Database\Connection.php on line 202
Exception Attributes: array (
'driver' => 'Cake\\Database\\Driver\\Mysql',
)
Stack Trace:
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Database\Connection.php:142
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Datasource\ConnectionRegistry.php:90
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Core\ObjectRegistry.php:110
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Datasource\ConnectionManager.php:212
- C:\xampp\htdocs\my_app\vendor\cakephp\migrations\src\Command\BakeMigrationSnapshotCommand.php:122
- C:\xampp\htdocs\my_app\vendor\cakephp\migrations\src\Command\BakeMigrationSnapshotCommand.php:55
- C:\xampp\htdocs\my_app\vendor\cakephp\migrations\src\Command\BakeSimpleMigrationCommand.php:91
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Console\BaseCommand.php:179
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Console\CommandRunner.php:336
- C:\xampp\htdocs\my_app\vendor\cakephp\cakephp\src\Console\CommandRunner.php:172
- C:\xampp\htdocs\my_app\bin\cake.php:12
Please check if you have two different versions of php on your machine.
cake bake should read the php extensions from xamp's php version i.e C:\xampp\php.

SavedModel file does not exist when using Tensorflow hub

When trying to use the hub.load function from tensorflow_hub, I get an OSError: SavedModel file does not exist at: error.
The weird thing is that it worked a few days ago, so I don't quite understand why I'm getting this error now.
Code to reproduce:
import tensorflow as tf
import tensorflow_hub as hub
URL = 'https://tfhub.dev/google/universal-sentence-encoder/4'
embed = hub.load(URL)
Specific error received:
OSError Traceback (most recent call last)
<ipython-input-11-dfb80f0299b2> in <module>
1 URL = 'https://tfhub.dev/google/universal-sentence-encoder/4'
----> 2 embed = hub.load(URL)
~/opt/anaconda3/lib/python3.7/site-packages/tensorflow_hub/module_v2.py in load(handle, tags)
100 if tags is None and is_hub_module_v1:
101 tags = []
--> 102 obj = tf_v1.saved_model.load_v2(module_path, tags=tags)
103 obj._is_hub_module_v1 = is_hub_module_v1 # pylint: disable=protected-access
104 return obj
~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in load(export_dir, tags)
576 ValueError: If `tags` don't match a MetaGraph in the SavedModel.
577 """
--> 578 return load_internal(export_dir, tags)
579
580
~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/saved_model/load.py in load_internal(export_dir, tags, loader_cls)
586 tags = nest.flatten(tags)
587 saved_model_proto, debug_info = (
--> 588 loader_impl.parse_saved_model_with_debug_info(export_dir))
589
590 if (len(saved_model_proto.meta_graphs) == 1 and
~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/saved_model/loader_impl.py in parse_saved_model_with_debug_info(export_dir)
54 parsed. Missing graph debug info file is fine.
55 """
---> 56 saved_model = _parse_saved_model(export_dir)
57
58 debug_info_path = os.path.join(
~/opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/saved_model/loader_impl.py in parse_saved_model(export_dir)
111 (export_dir,
112 constants.SAVED_MODEL_FILENAME_PBTXT,
--> 113 constants.SAVED_MODEL_FILENAME_PB))
114
115
OSError: SavedModel file does not exist at: /var/folders/77/rvfl368x44s51r8dc3b6l2rh0000gn/T/tfhub_modules/063d866c06683311b44b4992fd46003be952409c/{saved_model.pbtxt|saved_model.pb}
So, just deleting that folder and running the hub.load() function again solves the issue
I have tried the above solution, but it didn't work for me...
Here's what worked:
Download the model from tfhub.dev with assets, variables and .pb checkpoint file.
Make sure you import tensorflow_text module!
import tensorflow_text
Specify the downloaded folder path in the hub.load() statement as in:
model =
hub.load("/Users/bilguun/Desktop/universal-sentence-encoder-multilingual-large_3/")
I was using i3d = hub.load(https://tfhub.dev/deepmind/i3d-kinetics-400/1).signatures['default'] as shown here
This method of loading the model worked in that day but after a few days I got the same error: OSError: SavedModel file does not exist at: C:\Users\catal\AppData\Local\Temp\tfhub_modules\092225fb776e28d6d64ac605ab6be03f18dd2027{saved_model.pbtxt|saved_model.pb}
After doing some research, I understood that the saved_model file location (specified in the error) was temporary so even if that folder still exists, there is no more saved_model.pb in it. So I downloaded the model linked here: https://tfhub.dev/deepmind/i3d-kinetics-400/1 and set i3d = hub.load("C:\\absolute_path_to_saved_model_folder").signatures['default'] and it worked.
So using Bilguun's answer really helped in my case.
This kind of error happens because the downloaded model is saved in temporary folder created by the application.
Since it is a temporary folder, the model saved in it may gets deleted or even the folder can be deleted.
When calling the hub.load() command, the programme checks for the temporary folder, if the folder is not found, the program will download the data from internet.
But if the folder is found and the data(or model) is not there, instead of downloading from the internet, it raises an error.
It can be resolved by deleting the temporary folder completely.
In Mac the temporary folder can be accessed by the command "open $TMPDIR" on the terminal( reference : https://osxdaily.com/2018/08/17/where-temp-folder-mac-access/).
The name of the folder can be get from the raised error and can be deleted easily .

CakePHP console gives error "Undefined index: HTTP_HOST"

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.

Drupal 7 - Theme Info Name Errors After Transferring Site to New Server

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.

Undefined property: ModelTask::$useDbConfig

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.

Resources