DebugKit Toolbar do not show at the top-right of my localhost/thegioididong page.
Try:
bin/cake plugin assets symlink
to load debugkit assets.
SOLVED! I do these thing:
1: check the debug status at the top of config\app.php.
`'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),`
2: add to the end of config\bootstrap.php these codes:
`if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}`
3: create debug_kit table in mysql database - leave it empty database (localhost/phpmyadmin - in my case), then add:
'debug_kit' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'root',
'password' => 'root1234',
'database' => 'debug_kit', //leave it empty - without tables
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
'quoteIdentifiers' => false,
'url' => env('DATABASE_URL', null),
],
into config\app.php following this structure:
'Datasources' => [
'default' => [
//default database config here
],
'debug_kit' => [
//debug_kit database config as above
],
'test' => [
//test database config here
],
],
Thanks a lot. I'm sory for my English!
in my case cake 3.5 this lines of code work
if (Configure::read('debug')) {
Configure::write('DebugKit', ['forceEnable' => true]);
Plugin::load('DebugKit', ['bootstrap' => true]);
}
add this line at the end of bootstrap.php
Do you have this in your bootstrap.php file?
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
enabled sqlite, for linux mint
nano /etc/php/7.2/apache2/php.ini
uncomment
extension=sqlite3
restart apache
service service apache2 restart
For CakePHP 3.x:
Check if "debug" is set to true. You may add debug('test'); somewhere in your app and check if you see the word "test" in your website's code at the beginning.
Check that debugkit plugin is loaded by adding debug(Plugin::loaded('DebugKit')); at the end of bootstrap.php. This should echo "true".
Add Configure::write('DebugKit', ['forceEnable' => true]); before you load DebugKit.
Add your development TLD to the "safeTld" property. (thanks #mark)
// Allow e.g. http://foo.bar.dev or http://my-shop.local domains locally
Configure::write('DebugKit.safeTld', ['dev', 'local', 'example']);
Copy or symlink asset plugins running bin/cake plugin assets symlink (use copy on windows)
Docs here.
Make sure you have sqlite extension installed. If you're using Laragon, enable Sqlite extensions in Menu > PHP > Extensions (this is what fixed my issue).
Related
Upgraded CakePHP from 3.5 -> 3.6 -> 3.7. The error message, Property _transportConfig does not exist, is displayed as soon as the application starts in the browser.
Email Transport config in app.php
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'username' => '*******#gmail.com',
'password' => '********************',
'log' => true,
'tls' => true
],
],
I've found some information in the migration guide, here is a solution that may work;
First, you need to add this to your bootstrap file
use Cake\Mailer\TransportFactory;
then replace
Email::setConfigTransport(Configure::consume('EmailTransport'));
by
TransportFactory::setConfig(Configure::consume('EmailTransport'));
finally you might consider updating the debugger via composer :
λ composer require --update-with-dependencies "cakephp/debug_kit"
Might not be the best way to, but it worked for me!
I'm working on a project which only a few packages of cake 3 :
cakephp/orm
cakephp/validation
cakephp/i18n
cakephp/cache
I just installed the last one (cache).
I uploaded my project to a production server, and was surprised to see that my queries using the ORM are extremely slow (a query that lasts about 100ms on my local machine can take up to 5 or 10 seconds on the production server).
It seems that there are queries on the information_schema table that take much time and resources. So I've went on the web and saw that I needed the enable cacheMetaData param in my config.
My config looks like this :
ConnectionManager::config('default', [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'host' => 'my-host',
'database' => 'my-database',
'username' => 'my-username',
'password' => 'my-password',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetaData' => true // If set to `true` you need to install the optional "cakephp/cache" package.
]);
I followed the instruction above and installed the cakephp/cache package. But I'm guessing I need to enable it somehow (or somewhere), but can't figure out how (or where).
Here is what I tried :
\Cake\Cache\Cache::config('_cake_model_', [
'className' => 'File',
'prefix' => 'myapp_cake_model_',
'path' => '/cache/models/',
'serialize' => true,
'duration' => '+2 minutes',
]);
But it's still not working, my cache or cache/models/ folder is still empty and the requests are taking a long time.
How can I fix this ?
Thanks for your time
kinkaz
For a detailed solution on this topic, please see http://discourse.cakephp.org/t/orm-cache-metadata-issue/1071
I am using Cakephp 3 and MSSQLSRV 2014. I made all the necessary changes to connect to MSSQL server. In GUI, I can see that cakephp can connect to MSSQL. Please see the below screenshot.
So now when I go to bin directory to bake the application, I get below error unable to load MSSQL driver, which is already installed:
Here are my datasource settings in app.php file:
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlserver',
'persistent' => false,
'host' => 'localhost\SQLEXPRESS',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
'port' => '1433',
'username' => 'sa',
'password' => 'password',
'database' => 'ServerMatrix',
'encoding' => 65001,
'timezone' => 'UTC',
'cacheMetadata' => true,
'log' => false,
I am thinking its probably a bug that should be reported to CakePHP community, but wanted to get some help from stack-overflow community to see if they have encountered such issue.
In command line interface typed php --ini and opened loaded php.ini file and added SQLSrv extensions. That solved the problem for baking an application.
Thanks to #ndm.
I'm developing a CakePHP 2.2 site locally with MAMP. Every so often, I get one or more warnings similar to this, about not being able to write to one or more cache files:
Warning: SplFileInfo::openFile(/Applications/MAMP/htdocs/mywebsite/www/app/tmp/cache/persistent/myapp_cake_core_cake_console_en-au): failed to open stream: Permission denied in /Applications/MAMP/htdocs/mywebsite/www/lib/Cake/Cache/Engine/FileEngine.php on line 313
The weird thing is, /tmp is 777, tmp/cache is 777, and tmp/cache/persistent is 777 (don't worry... it won't be 777 on the server!). The file itself inside tmp/cache/persistent is 644 - but I assume Cake is creating and managing that file, and does so with the permissions it needs.
If I just refresh the page, the error goes away (and then re-appears sometime later). I'm not doing any explicit caching, so this stuff is just Cake doing whatever it automatically does.
So my question is:
a) How does this automatic caching of Cake's work? Is it trying to write to that file on every page refresh, and failing only once in a while? Or is it only trying to write to that file once in a while, but failing every time it tries?
b) If it's only failing only once in a while, can I safely just ignore it? And if it's failing every time it tries, how can I fix it?
Thanks in advance for any help!
This happens probably when a process different from Apache create files in the cache. This can be the case for instance when you run shell commands as you probably do it as a different user than apache.
By default the File cache creates files with permissions allowing only the user that has created the files to modify them, but this can be fixed by setting a mask in the Cache config in core.php:
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666
));
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666
));
If you want to avoid giving read/write access to the "other" group, check out my other solution here:
https://stackoverflow.com/a/18703956/385979
Simple really, assuming and you are a sudoer and your user name is martinlutherking
sudo adduser martinlutherking www-data
This way cake console commands can read cache files created by apache2, however you may need to do the inverse group add to ensure that www-data can read cache files created by martinlutherking
Just in case anybody is seeing this and wonders how it works in cakePHP 3.x:
modify /config/app.php and add 'mask' => 0666 to
/**
* Configure the cache adapters.
*/
'Cache' => [
'default' => [
'className' => 'File',
'path' => CACHE,
'url' => env('CACHE_DEFAULT_URL', null),
'mask' => 0666
],
and probably you also want to add it to the log files:
/**
* Configures logging options
*/
'Log' => [
'debug' => [
'className' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'file' => 'debug',
'levels' => ['notice', 'info', 'debug'],
'url' => env('LOG_DEBUG_URL', null),
'mask' => 0666
],
'error' => [
'className' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'file' => 'error',
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
'url' => env('LOG_ERROR_URL', null),
'mask' => 0666
],
],
I am quite new to cakephp and I'm having trouble getting it configured to work on my live server. It works fine on my local machine.
I think the problem is that my live server is configured to use Memcache. When I visit the live site I get:
Warning (2): session_start() [function.session-start]: open(=1&retry;_interval=15/sess_mt8tpui04vorqojg7s945e5sf5, O_RDWR) failed: No such file or directory (2) [CORE/Cake/Model/Datasource/CakeSession.php, line 615]
Warning (2): session_write_close() [function.session-write-close]: open(=1&retry;_interval=15/sess_mt8tpui04vorqojg7s945e5sf5, O_RDWR) failed: No such file or directory (2) [CORE/Cake/Controller/Controller.php, line 712]
Warning (2): session_write_close() [function.session-write-close]: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (tcp://127.0.0.1:11211?persistent=1&weight;=1&timeout;=1&retry;_interval=15) [CORE/Cake/Controller/Controller.php, line 712]
So i've tried enabling cake to use memcache by adding the following to app/Config/core.php:
Cache::config('default', array(
'engine' => 'Memcache'
));
But I still get the same error.
The php.ini is configured to use memcache correctly.
Any ideas?
Thanks
Your Cache::config looks incomplete!
It should look like this and This code block will be in app/Config/bootstrap.php
Cache::config('default', array(
'engine' => 'Memcache', //[required]
'duration' => 3600, //[optional]
'probability' => 100, //[optional]
'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
'servers' => array(
'127.0.0.1:11211' // localhost, default port 11211
), //[optional]
'persistent' => true, // [optional] set this to false for non-persistent connections
'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
));
Also you need to set a session handler http://book.cakephp.org/2.0/en/development/sessions.html#cache-sessions
Mine looks like this, note that I have called "sessiones"
& This code block will be in app/Config/core.php
Configure::write('Session', array(
'defaults' => 'cache',
'handler' => array(
'config' => 'sessiones'
),
'cookie' => 'PHPSESSID',
'timeout' => 3600,
'cookieTimeout' => 0,
'autoRegenerate' => false,
'checkAgent' => true,
'ini' => array(
'session.cookie_secure' => false,
'session.cookie_httponly' => true,
)
));
And then set up the Cache:config for the handler "sessiones"
and This code block will be in app/Config/bootstrap.php
Cache::config('sessiones', array('engine' => 'Memcache','duration'=> 3600,/*'prefix' =>'es',*/ 'servers' => array(array('127.0.0.1:11211'), 'compress' => false));