CakePHP 3: DebugKit is not enabled - debugging

I downloaded the DebugKit plugin using:
php composer.phar require --dev cakephp/debug_kit "~3.0"
But it still shows warning in error.log and DebugKit is not working:
Warning: DebugKit not enabled. You need to either install
pdo_sqlite, or define the "debug_kit" connection name
So how to define debug_kit connection name in app.php and how to enable debugkit??

Installing and enabling pdo_sqlite from Terminal
For PHP5.6
sudo apt-get install php5.6-sqlite3
For PHP7
sudo apt-get install php7*-sqlite3
After installation, Restart Apache Server
sudo service apache2 restart
Note: php5.6-sqlite3 = {YourPhpVersion}-{SqliteVersion}

In app file:
.../config/app.php
in option "Datasources": create new sub option like this:
'debug_kit' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => DB_HOST,
'port' => DB_PORT,
//'port' => 'non_standard_port_number',
'username' => DB_ACC,
'password' => DB_PASS,
'database' => DB_NAME,
//'encoding' => 'utf8mb4',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,'quoteIdentifiers' => false,
'url' => env('DATABASE_URL', null),
]
Save file app and refresh your website. Done.

Related

LdapRecord: Connection doesn't exist error after successful test

When I run php artisan:test the default connection is successful, but when I run php artisan I get an error saying the connection doesn't exist.
config/ldap.php settings:
'default' => env('LDAP_CONNECTION', 'default'),
'connections' => [
'default' => [
'hosts' => [env('LDAP_HOST', '127.0.0.1')],
'username' => env('LDAP_USERNAME', 'cn=user,dc=local,dc=com'),
'password' => env('LDAP_PASSWORD', 'secret'),
'port' => env('LDAP_PORT', 389),
'base_dn' => env('LDAP_BASE_DN', 'dc=local,dc=com'),
'timeout' => env('LDAP_TIMEOUT', 5),
'use_ssl' => env('LDAP_SSL', false),
'use_tls' => env('LDAP_TLS', false),
],
],
.env settings (username and password copied from working environment)
Laravel 9.19
PHP 8.1
directorytree/ldaprecord-laravel 2.5.6
I uninstalled and reinstalled LdapRecord with the same result.
Configuration docs:
https://ldaprecord.com/docs/laravel/v2/configuration#using-an-environment-file-env

How to configure Laravel to use PhpRedis?

PHP 7.3
Laravel 5.8
Until now I was using Predis for my cache in the Laravel project. Now I want to switch to PhpRedis. I've read it's really simple (just config changes), but I have a lot of problems. I don't know what to begin with, so I'll write all what I know.
My hosting provider claims that PhpRedis is enabled.
The code below executed in a controller (Predis is set) works fine - I receive the set value.
$redis = new \Redis();
$redis->connect( 'socket path', 0 );
$redis->set('test', 'testValue');
print_r( $redis->get('test') );
However, the same code in the raw PHP file executed via SSH returns "Uncaught Error: Class 'Redis' not found in..."
Let's go to changes in config/database.php. Here is my configuration:
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'/*'phpredis'*/),
'cluster' => true,
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'/*'redis'*/),
'prefix' => Str::slug(env('APP_NAME'), '_').'_',
'parameters' => ['password' => env('REDIS_PASSWORD', null)],
],
'default' => [
'scheme' => 'unix',
'path' => env('REDIS_HOST'),
'host' => env('REDIS_HOST'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT'),
'database' => env('REDIS_CACHE_DB', 0)
],
(...) // other
],
When I change values to these in comments, my website shows just a blank page - any errors in the mailbox.
Furthermore, when I run for example "php73 artisan config:clear" in the SSH, console returns "Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension." in the Illuminate/Redis/Connectors/PhpRedisConnector.php.
When I change the alias in config/app.php from "Redis" to "RedisManager" and try again it returns
Uncaught Error: Class 'Redis' not found in /path/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:70.
What's going on? How to set Laravel's configuration to use PhpRedis? Maybe it's my hosting provider issue? Thanks in advance for every advice.
If I missed some important code, give me a sign - I will add it.
The PHPRedis libraries are not installed by default in a shared hosting environment, and are generally not part of a PHP installation by default. You would have to ask your host to install these libraries within their shared hosting platform.

Cannot Create SSL client. SSL not enabled in build

I've been migrating databases from mLab to MongoDB Atlas (mLab is being terminated Nov 10th). I've been trying to put make a mongo url dsn connection to connect to my Atlas cluster. However, when I put in the connection, I get this error:
MongoDB \ Driver \ Exception \ InvalidArgumentException
Cannot create SSL client. SSL is not enabled in this build.
I have been told this is how you connect to MongoDB Atlas from this source stackoverflow post
Database.php:
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mongodb' => [
'driver' => 'mongodb',
'dsn'=> env('DB_DSN'),
'database' => env('DB_DATABASE'),
],
my .env file:
DB_DSN=mongodb://****username:****password#*****-shard-00-00.d4sg0.mongodb.net:27017,*****-shard-00-01.d4sg0.mongodb.net:27017,*****-shard-00-02.d4sg0.mongodb.net:27017/****database?ssl=true&replicaSet=atlas-xn698l-shard-0&authSource=admin&retryWrites=true&w=majority
Project Specs:
Laravel,
Apache,
MongoDB,
Composer using Git Bash

invalid value for parameter "client_encoding": "utf8mb4" (SQL: select * from "tablename") when deploy laravel to heroku [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I am trying to deploy my laravel app to heroku but it returns an error:
SQLSTATE[22023]: Invalid parameter value: 7 ERROR: invalid value for parameter "client_encoding": "utf8mb4" (SQL: select * from "tablename").
I changed my tablename collation and columns from utf8mb4_unicode_ci to utf8unicode_ci but nothing happened. Please help me. I tried all the possible solutions I've searched but nothing really works.
I have faced the same problem. Mistakenly i have not added DB_CONNECTION=pgsql in config vars on Heroku dashboard. Inside setting tab click on Reveal Config Vars and add DB_CONNECTION=pgsql there.
Another way just simply add config vars using terminal.
heroku config:add DB_CONNECTION=pgsql
After setting up your psql details as specified up there on config/database.php
run
git push origin master
git push heroku master
And try run the bash again..
heroku run bash
php artisan migrate:fresh
yes
and you're good to go
Laravel Databse Connection Environment issue
You are probably using the Postgresql as the Database instead of MySql.
Then please configure the database config in config/database.php file
'default' => env('DB_CONNECTION', 'pgsql')
or set the DB_CONNECTION in .env as pgsql
pgsql will not support utf8mb4, it is for the MySQL, if you are using Postgresql pls correct the connection environment.
For mysql:
[
'database.connections.rds' => [
'driver' => 'mysql',
'host' => $endpoint,
'port' => $port,
'database' => $db_name,
'username' => $user,
'password' => $password,
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
]
]
for Postgres
[
'database.connections.rds' => [
'driver' => 'pgsql',
'host' => $endpoint,
'port' => $port,
'database' => $db_name,
'username' => $user,
'password' => $password,
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
]
]
Are you using laravel/telescope?
I had the same problem when trying to implement my project. To resolve the error, I removed laravel/telescope from my project.
'mysql' => [
// ...
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
// ...
],
This happens at the environment variable configuration level on Heroku if you haven't done key = DB_CONNECTION and value = pgsql.
In config/database.php, Use default connection
'default' => 'pgsql',
"client_encoding": "utf8"
If you are using MySQL than change default connection to
'default' => 'mysql',
"client_encoding": "utf8mb4"

How to install drush for a vagrant project?

I have drush installed in my system but drush does not work inside vagrant. It works for MAMP though.
Here is drush status
drush status
Drupal version : 7.41
Site URI : http://default
Default theme : garland
Administration theme : garland
PHP configuration : /etc/php5/cli/php.ini
Drush version : 5.10.0
Drush configuration : /var/www/project_name/sites/all/drush/drushrc.php
Drush alias files : /home/vagrant/.drush/project_name.aliases.drushrc.php
Drupal root : /var/www/npro/docroot
Site path : sites/default
File directory path : sites/default/files
In settings.php file, mine is multi site. I added following code to sites/xyz_site/settings.php
Add following code
$databases = array(
'default' =>
array(
'default' =>
array(
'database' => 'database_name',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
$conf['file_public_path'] = 'sites/xyz_site/files';
Above solution worked for me.

Resources