Xdebug not working in CLI and Lando environment - phpstorm

I'm trying to setup CLI Xdebug in the Lando environment.
It works flawlessly from the web, but I can't manage to make it working from CLI to debug tests and scripts.
Here is my .lando.yml file:
name: develop
recipe: wordpress
proxy:
appserver_nginx:
- develop.loc
config:
php: '7.3'
via: nginx
database: mariadb
xdebug: true
I use PHPStorm as my IDE. I already setup server, server mapping, and ports 9000 and 9003 for listening, but it still doesn't stop at breakpoints.
Did anyone setup CLI Xdebug with Lando? Any ideas? Thanks for helping.

I managed to make it working.
So, the idea is to setup two environment variables:
PHP_IDE_CONFIG="serverName=localhost", where localhost is the name of the server in your PhpStorm settings.
XDEBUG_TRIGGER="1" - this variable triggers the xdebug.
But how can we provide the variables dynamically to make XDEBUG_TRIGGER working only when you want to?
For such things Lando has the tooling option!
So, we can create the custom command which would make the magic happen, like this:
tooling:
phpdebug:
service: appserver
cmd:
- php
env:
XDEBUG_TRIGGER: 1
PHP_IDE_CONFIG: "serverName=localhost"
Then restart (or rebuild) you appserver, and you'll have a brand new custom command for debugging PHP from CLI, like this:
lando phpdebug test.php
So, it works the same as lando php test.php, but with providing all the environment variables needed to run Xdebug.
Update:
If someone is interested in how to debug WP CLI from the Lando environment:
lando phpdebug /app/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php --version
So, it's the same as lando wp --version, but with providing Xdebug environment variables
P.S. Please be aware - it's the instructions for Xdebug 3.

Related

Configuration files BROKER_DATABASE_HOST Docker

I'm trying to access the ContextBroker configuration file in the path /etc/sysconfig/contextBroker and it's empty. What is the problem?
https://fiware-orion.readthedocs.io/en/master/admin/running/index.html
I'm using Docker.
Also I am testing the installation by yum centos and tells me that the repository is wrong.
  Is it copied from the web?
https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/admin/yum.md
The /etc/sysconfig/contextBroker is used in RPM-base deployment. Docker is based in compiling Context Broker directly from sources, as you can see in the docker file.
So, in this case, you have to use CLI based configuration. Note the docker is built with some of them:
ENTRYPOINT ["/usr/bin/contextBroker","-fg", "-multiservice", "-ngsiv1Autocast" ]
But you can add aditional ones. For example, in the reference docker-compose.yml we set -dbhost, and more ones could be added in the same way.
command: -dbhost mongo
I guess that using docker run you could also add commands in the same way command works in docker-compose.yml, although I don't know the details. Maybe some docker expert could add more info :)

How to set PHP_IDE_CONFIG while debugging PHP CLI using PhpStorm

I've configured Xdebug and PhpStorm properly, and have used Browser Debugging Extensions and successfully tested a PHP CLI server LaravelFly which speeds up Laravel.
sudo php /vagrant/www/zc/vendor/scil/laravel-fly/bin/fly start
But I failed to test it using PHPUnit today:
sudo php -dxdebug.remote_host=192.168.1.108 vendor/bin/phpunit --stop-on-failure
I added this to Vagrant Ubuntu .zshrc
export PHP_IDE_CONFIG="serverName=zc.test"
but it still does not work and PhpStorm response the same error messag.
In the picture above, I found that $_SERVER['PATH'] is not same with the $PATH of my vagrant user, then I got it.
I removded sudo
php -dxdebug.remote_host=192.168.1.108 vendor/bin/phpunit --stop-on-failure
Now it works!

PhpStorm & Xdebug - cant get to work debugger with CLI script

This is my first post here, I post because after reading through X articles googling can't get PhpStorm, Xdebug work with CLI scripts.
Already tried to follow advices from:
PHPStorm + XDebug Setup Walkthrough
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
PHPStorm + XDebug + Vagrant
and few blogs that I've found online, but still nothing...
I had it working, but after destroy vagrant recently and now can't fully restore this feature.
SETUP:
I'm running Symfony project on Vagrant.
Debugging of "webpages" on my server works just perfectly.
When I try debug CLI Command I prequisite it with:
export XDEBUG_CONFIG="XDEBUG_SESSION=1"
export PHP_IDE_CONFIG="serverName=vagrant"
XDEBUG.INI (on Vagrant):
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=192.168.0.133 (ip I get from ifconfig -a on Vagrant)
xdebug.remote_port=9000
xdebug.max_nesting_level=2500
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
Any help much appreciated. Digged through X articles on web but in my eyes all configurations look ok, no idea what to do...
Set xdebug.remote_connect_back to be 0.
This option prevents you from using right IP address when you are doing Remote CLI debugging. Since it's a CLI debug, the IP will always be local (vagrant machine) while you need another one.
This option works OK when debugging over browser as request comes from your "real" computer. But when doing CLI debug .. request will be local to Vagrant machine.
When this option is set to 1 (as it is done now) it ignores the setting from #2 below.
xdebug.remote_host=192.168.0.133 (ip I get from ifconfig -a on Vagrant) -- this should be an IP of your computer where PhpStorm is running as seen from Vagrant machine.
Combination of those 2 above will do the job for you.

Changing Haproxy configuration on openshift

I have a scalable Python 2.7 app on OpenShift and I'm getting this 503 error.
I checked some answers that might work but they say to rhc into the app and change the Haproxy configurations, but I don't have a clue on how to do it.
Can someone help me please?
1) Install rhc: https://developers.openshift.com/en/managing-client-tools.html and read https://blog.openshift.com/how-haproxy-scales-openshift-apps/
2) Run $ rhc setup for the initial configuration of the tool and check https://developers.openshift.com/en/managing-log-files.html#accessing-logs-via-ssh for viewing haproxy logs
3) Run rhc ssh --app yourapp, once inside, cd haproxy/conf and change your haproxy.cfg appropriately
I edited haproxy.cfg:
option httpchk OPTIONS * HTTP/1.1\r\nHost:\ {{ my app link }}
It’s working now.

How to use Linux Xampp mysql_pdo with Symfony 2.0

I've got a serious problem.
I would like to use Doctrine 2 on my Symfony 2 projet.
I've change the php path from the app/console :
/opt/lampp/bin php
I've specify the good path for my mysql_pdo in /opt/lampp/etc/php.ini
pdo_mysql.default_socket = /opt/lampp/var/mysql/mysql.sock
and check to my php_info() for my pdo :
PDO
PDO support enabled
PDO drivers mysql, pgsql, sqlite, sqlite2
pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.7-dev - 091210 - $Revision: 304625
$
Directive Local Value Master Value
pdo_mysql.default_socket /opt/lampp/var/mysql/mysql.sock /opt/lampp/var/mysql/mysql.sock
pdo_pgsql
PDO Driver for PostgreSQL enabled
PostgreSQL(libpq) Version 8.0.3
Module version 1.0.2
Revision $Id: pdo_pgsql.c 300351 2010-06-10 12:11:19Z iliaa $
Everything seems fine, but when I use this Symfony command :
php app/console doctrine:mapping:import WonderWBundle yml
It juste says :
[PDOException] could not find driver
I'm on Ubuntu 10.10
XAMPP for Linux 1.7.4 !
It seems that I've got everything to made Pdo work well but not on Symfony 2.
Does anyone could help ? Pleeeaaaassse (I'm going mad !!)
Thanks a lot :P
(P.S : Grrr cannot link my screenshots !)
Another reason could be related to PHP itself.
Various linux distros compile their php-cgi/fpm/apache and php-cli to use different php.ini files ( which actually makes sense )
Both ini files use to have their module configuration files included from subdirectories.
If you install an additional module manually, the `phpinfo()? viewed in a web browser may show the module, but programs executed on the commandline, just like Zend Framework app/console are using php-cli with another configuration.
e.g. for the apache module
/etc/php/php-apache/php.ini
/etc/php/php-apache/php.d/pdo_mysql.ini
for the commandline php
/etc/php/php-cli/php.ini
In this case you have to repeat your module configuration for the commandline client
/etc/php/php-cli/php.d/pdo_mysql.ini
The commandline php also has a phpinfo functionality, which you can use to verify your cli installation:
~ # php -i | grep "pdo"