Why won't Xdebug 3 stop on PhpStorm breakpoints? - phpstorm

I've been using Xdebug and PhpStorm successfully for years. Now I've reinstalled on a new dev machine, it no longer works.
My setup is:
Wamp64 server
Xdebug 3.1.1
phpinfo() reports:
xdebug
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
Enabled Features (through 'xdebug.mode' setting)
xdebug.auto_trace => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.cli_color => 0 => 0
xdebug.client_discovery_header => no value => no value
xdebug.client_host => localhost => localhost
xdebug.client_port => 9003 => 9003
xdebug.cloud_id => no value => no value
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.collect_params => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.collect_return => Off => Off
xdebug.collect_vars => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.connect_timeout_ms => 200 => 200
xdebug.coverage_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.default_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.discover_client_host => Off => Off
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.gc_stats_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.gc_stats_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => no value => no value
xdebug.log => no value => no value
xdebug.log_level => 7 => 7
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.mode => debug => debug
xdebug.output_dir => C:\Windows\Temp => C:\Windows\Temp
xdebug.overload_var_dump => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.show_mem_delta => (setting removed in Xdebug 3) => (setting removed in Xdebug 3)
xdebug.start_upon_error => default => default
xdebug.start_with_request => yes => yes
xdebug.trace_enable_trigger => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.trace_enable_trigger_value => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => (setting renamed in Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.trigger_value => no value => no value
xdebug.use_compression => 1 => 1
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3
php.ini looks like this
[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.idekey=PHPSTORM
PhpStorm configuration is as follows:
When I click 'debug localhost' in PhpStorm project it opens the browser correctly, with the query string ?XDEBUG_SESSION_START=16111 - but won't stop on any breakpoints.
I also have the Firefox debug extension installed, but I'm not exactly sure how that fits into the whole mix. When I enable to debug extension, cookie XDEBUG_SESSION is dropped with a value of PHPSTORM.
It feels like I'm close, any suggestions here, please? How would I debug Xdebug my setup?

Related

Yii2 queue TTR attribute doesn't applies

I have the following queue config:
'queue' => [
'class' => \yii\queue\db\Queue::class,
'db' => 'db',
'tableName' => '{{%queue}}',
'channel' => 'default',
'mutex' => \yii\mutex\MysqlMutex::class,
'ttr' => 14400,
],
I wrote simple job that outputs current time in the console.
use yii\queue\JobInterface;
use yii\queue\Queue;
class DummyTimer implements JobInterface
{
public function run()
{
$strtime = time();
while($strtime + (4*60*60) > time())
echo date('H:i:s') . "\r\n";
}
public function execute($queue)
{
$this->run();
}
}
It runs only 300 seconds, and then gets killed with the next output in terminal:
2020-05-27 23:29:51 [8] app\modules\queue\DummyTimer (attempt: 1, pid:
7637) - Error
Symfony\Component\Process\Exception\ProcessTimedOutException: The process "'/usr/bin/php7.2' 'yii' 'queue/exec' '8' '300' '1' '7637'
'--color=1' '--verbose=1'" exceeded the timeout of 300 seconds.
So how to increase maximum lifetime of a job?
The original solution should be working just fine:
'queue' => [
'class' => \yii\queue\db\Queue::class,
'db' => 'db',
'tableName' => '{{%queue}}',
'channel' => 'default',
'mutex' => \yii\mutex\MysqlMutex::class,
'ttr' => 14400,
],
Stumbled upon the same issue and seemed that ttr in queue config did not work. But What I forgot to do was to re-start the queue process after changing the config. Works just fine with the configuration change if the queue is properly re-loaded with the new configuration.

Yii2 Read Write splitting couldn't connect slave server in master slave configuration

Have done Master Slave configuration as per official Yii2 documentation. Below is actual configuration look like,
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=1.1.1.1;dbname=master_db',
'username' => 'user',
'password' => 'password',
'charset' => 'utf8',
'enableSchemaCache' => true,
'schemaCacheDuration' => 10,
'schemaCache' => 'cache',
'slaveConfig' => [
'username' => 'slave_user',
'password' => 'slave_password',
'charset' => 'utf8',
'attributes' => [
// use a smaller connection timeout
PDO::ATTR_TIMEOUT => 10,
],
'enableSchemaCache' => true,
'schemaCacheDuration' => 10,
'schemaCache' => 'cache',
],
'slaves' => [
['dsn' => 'mysql:host=2.2.2.2;dbname=slave_db']
],
],
It always connect master database even if slave server is up and reachable.
Surprisingly replacing current master config with slave one works, moreover if try to connect slave database from command line it get connected in a moment but unable to achieve same with above configuration.
Wondering if there is any parameters missing in configuration or any other way to get things working like ideal read write splitting?
issue was resolved by adding connection class in the slaveConfig,
'class' => 'yii\db\Connection'

Laravel 5.4 odbc connection MS SQL SERVER

I need to config Laravel 5.4 to use the ODBC PDO Driver for Microsoft SQL Server.I didnt find any useful resource. If anyone previously used odbc in laravel 5.4 please help me out.
Database.php
'odbc' => [
'driver' => 'odbc',
'dsn' => 'Driver={SQL Server};Server=
{serverName};Trusted_Connection=true;Database=meteor;',
'host' => 'DESKTOP-B9M4O7M\SQLEXPRESS',
'database' => 'meteor',
'username' => 'DESKTOP-B9M4O7M\admin',
'password' => '',
'grammar' => [
'query' => Illuminate\Database\Query\Grammars\SqlServerGrammar::class,
'schema' => Illuminate\Database\Schema\Grammars\SqlServerGrammar::class,
],
],
You have missed a couple of settings, and misunderstood a couple of others. Try the following:
'odbc' => [
/* USE sql server as the driver, and set odbc settings (see below) */
'driver' => 'sqlsrv',
/* Tell laravel that you are using odbc */
'odbc' => true,
/* Set the ODBC data source, your previous dns */
'odbc_datasource_name' => '{SQL Server}',
/* There is no dsn config variable that I am aware of */
/*'dsn' => 'Driver={SQL Server};Server={serverName};Trusted_Connection=true;Database=meteor;', */
/* host is the server */
'host' => '{serverName}', /*'DESKTOP-B9M4O7M\SQLEXPRESS',*/
'database' => 'meteor',
'username' => 'DESKTOP-B9M4O7M\admin',
'password' => '',
'grammar' => [
'query' => Illuminate\Database\Query\Grammars\SqlServerGrammar::class,
'schema' => Illuminate\Database\Schema\Grammars\SqlServerGrammar::class,
],
],

Setting up a database for Yii 2

I need to install an app written in Yii 2 on my local computer. I installed composer and initiated the app with:
php /path/to/yii-application/init
Now I need to "create a new database and adjust the components['db'] configuration in common/config/main-local.php accordingly."
I have no clue how to do that.
1) Create database on your server.
2) Open common/config/main-local.php
Edit components to:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=DATABASE_NAME',
'username' => 'DATABASE_USER',
'password' => 'DATABASE_PASSWORD',
'charset' => 'utf8',
],
If using MAMP with mac then edit dsn line to :
'dsn' => 'mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=DATABASE_NAME'

How to replace environment-specific config, not cascade

I want to have a local development environment configuration for my database.php. I've created a new config director in my app and copied the database.php file into it. I'm using MongoDB and on production, I'm using a replica set with multiple servers, but locally, I'm just running a single server, so my connection info for production has more options:
Production:
...
'connections' => array(
'mongodb' => array(
'driver' => 'mongodb',
'host' => array('mongoDBA', 'mongoDBB'),
'port' => 27017,
'username' => 'myUserName',
'password' => 'myPassword',
'database' => 'theDatabase',
'options' => array('replicaSet' => 'myReplicaSet')
)
),
Local:
...
'connections' => array(
'mongodb' => array(
'driver' => 'mongodb',
'host' => 'localhost',
'port' => 27017,
'database' => 'theDatabase'
)
),
The problem is, when my local environment config loads, it merges the "connections" array. I want a way to completely replace the "mongodb" connection, so it's either one or the other, not both.
How can I accomplish this?
Create different set of configuration files:
app/config/local/database.php
app/config/production/database.php
And delete the file (or what you don't want of it):
app/config/database.php
And the you have to set your environment as
local
development
EDIT
This is how I do set my environment flawlessly, so I don't have to deal with hostnames and still don't get my local environment conflict with staging and production.
Create a .environment file in the root of your application and define your environment and add your sensitive information to it:
<?php
return array(
'APPLICATION_ENV' => 'development', /// this is where you will set your environment
'DB_HOST' => 'localhost',
'DB_DATABASE_NAME' => 'laraveldatabase',
'DB_DATABASE_USER' => 'laraveluser',
'DB_DATABASE_PASSWORD' => '!Bassw0rT',
);
Add it to your .gitignore file, so you don't risk having your passwords sent to Github or any other of your servers.
Right before $app->detectEnvironment, in the file bootstrap/start.php, load your .environment file to PHP environment:
foreach(require __DIR__.'/../.environment' as $key => $value)
{
putenv(sprintf('%s=%s', $key, $value));
}
And then you just have to use it:
$env = $app->detectEnvironment(function () {
return getenv('APPLICATION_ENV'); // your environment name is in that file!
});
And it will work everywhere, so you don't need to have separate dirs for development and production anymore:
<?php
return array(
'connections' => array(
'postgresql' => array(
'driver' => 'pgsql',
'host' => getenv('DB_HOST'),
'database' => getenv('DB_DATABASE_NAME'),
'username' => getenv('DB_DATABASE_USER'),
'password' => getenv('DB_DATABASE_PASSWORD'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
),
);
Note that I don't set a fallback:
return getenv('APPLICATION_ENV') ?: 'local';
Because, if I don't set the file, I want it to fail on every server I deploy my app to.