I'm trying to set up PHPUnit in PhpStorm 2017.1 on Windows 10 using a Vagrant box for a Laravel project. I've set up a remote interpreter, and I've been using it for a couple of months now, everything working fine.
I've been asked to do some unit testing so I've set up PhpStorm with PHPUnit, following my coworkers' instructions (PhpStorm on Mac) but when I select autoload.php in my vendor folder I receive the error message
"Can not parse PHPUnit version output: Could not open input file: /vagrant/vendorphpunitphpunitphpunit" (no slashes).
If I run PHPUnit via vagrant ssh in the command line, my tests execute fine, and I can manually select the PHPUnit phar in PhpStorm, but then I'm missing the autoloaded classes, so everything fails.
WI-35806 -- seems the same. It was marked as fixed today.
If that's the right ticket then the fix should be available in 2017.1.2 -- you may try EAP build when it will become available if you cannot wait until 2017.1.2 final will be officially released.
If you get a similar bug when setting up PHPUnit with Docker, then it could also be because of bad volume bindings.
In the following preferences screen, click on the folder icon to Edit Docker Container Settings, then edit the Volume bindings.
In case you configure remote PHP cli interpreter by Docker Compose, if you get a similar bug of parsing PHPUnit version output like this, the reason may comes from using variables in docker-compose.yaml (e.g using $PWD in volume binding).
For instance, if you mount your current directory like this:
...
volumes:
- $PWD:/var/www/html
PHPStorm do not know what $PWD really is, therefore it cannot parse PHPUnit output due to volume binding. You should change the variables to a specific value (e.g to ./ in this case):
...
volumes:
- ./:/var/www/html
Related
I use Panther Tests Case and PHPUnit on my symfony project for functional testing.
When I run my tests on my computer (php bin/phpunit), everything works fine. When i'm connected on my server and I run my tests, everything works fine.Chrome-driver is correctly installed on th server and i can run it with command lines.
BUT, when i push on gitlab and my CI starts, i always have the same error :
That is a screenshot from gitlab interface
My script begins with a connection to my server using SSH.So the beahviour should be the same as when i connect to my server using Putty and SSH...
The command i use on my .gitlab.ci script is 'php bin/phpunit'. The same that i use locally.
I've found some posts speaking about this problem but all on Selenium and nothing for panther... Please help ! :)
don't know if the problem is still existing, but I've been struggling with the same issue since yesterday and I fixed it by evenutally reading the doc ;-) : https://github.com/symfony/panther#chrome-specific-environment-variables
Due the Chrome's sandboxing, there is the need to specify a specific ENV variable to ensure the correct running in a container.
I update my .gitlacb-ci.yml with this on my test step:
before_script:
- ... {HERE : ensure your chromedriver is existing in the container}
- export PANTHER_NO_SANDBOX=1
So... lesson learned/remembered : 5 min of doc reading is worth 2 days of google searching... ;-)
I'm trying to add debugging to an old project that uses exec() to start a new session asynchronously from within another PHP script:
exec("php /var/www/html/validata/index.php",$result)
The normal PHP script is fully debugable with Xdebug but the script started with the exec command isn't because it can't map from file:///var/www/html/index.php to a local file location since it's started within CLI shell. The session started this way does trigger the debugger but can't find the file locally:
Cannot find file '/var/www/html/validata/index.php' locally.
To fix it set server name by environment variable PHP_IDE_CONFIG and restart debug session.
I've followed the instructions to add the PHP_IDE_CONFIG to the env. I've also added this to the server with 127.0.0.1 replaced with the desktop PC IP address (server is running in a docker container):
export XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"
Any pointers are greatly appreciated!
UPDATE
Solution:
Use the cli interpreter set to the docker container (in settings > Languages & Frameworks > PHP > CLI interpreter, add new, select docker and point it to the php binary) so that a debug session can be started with a new debugging configuration. I've copied the arguments from the exec command into the new configuration and it can now fully debug the script. I have to prepare a database table to make it fully testable but this is a working solution for me.
Thanks for all the replies!
You can solve the issue about the wrong php.ini file being loaded by specifying it in the command line:
exec("php -c " . escapeshellarg(php_ini_loaded_file()) .
" /var/www/html/validata/index.php",$result);
Though I doubt that would make much of a difference as far as xdebug is concerned.
I think a better solution would be to just require the file, which would cause xdebug to not become lost when you fork a new process.
require_once "/var/www/html/validata/index.php";
I've made a mistake how to refer to the server in PHP_IDE_CONFIG:
export PHP_IDE_CONFIG="serverName=SomeName"
should be run in the container where php runs, and SomeName should exactly match what is in PHPStorm/IntelliJ Settings > Languages & Frameworks > php > Servers > Name (not host). It's not a fqdn, just whatever is in the name field.
Does anybody know how to debug CLI PHP scripts from the CLI?!? I don't want to debug a PHP web page - I don't have a PHP web page. I don't want to debug a remote script either - I'm running/debugging right here on this system. I don't want to (at this time) try to get some IDE (Eclipse, PhpStorm or whatever) to debug a CLI PHP rather I just want to debug some PHP CLI script at the Linux command line itself. In Perl this would be simply perl -d <script.pl> <options>. Debugging a script, to me, is not figuring out compile errors or other simple things. To me it's setting break points, running code, examine the contents of variables and being able to arbitrarily execute or eval ('<php code>') at the debugger.
Sure later I'd like to configure this into my IDE of choice (at this time this is Eclipse) but I have not managed to get that working. Debugging from the CLI a PHP CLI script would be a good start for me.
Thanks.
I don't know why I'm limited to a character count when posting a comment. Perhaps I can add more text here.
Here's what I have tried in order to use xdebug and/or Zend debugger with Eclipse:
Base Eclipse version Mars.1 Release 4.5.
Eclipse PDT UI Plugin version 3.7.0.2015112
Tried installing xdebug using pecl install xdebug. Says I need to add "zend_extension=xdebug.so" to php.ini. Really? Which php.ini? I have several:
Andromeda:sudo find / -xdev -name php.ini
/etc/php5/cli/php.ini
/etc/php5/apache2/php.in
/opt/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_64_5.3.18.v20110322/resources/php53/php.ini
/opt/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_64_5.3.18.v20110322/resources/php5/php.ini
/opt/eclipse/plugins/com.zend.php.debug.debugger.php56.linux.x86_64_13.0.1.v20151112-2045/resources/php56/php.ini
Andromeda:
I put the zend_extension thing in both /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini. Made a phpinfo.php page and I see Xdebug in there (yea!). Configure a Debug Configuration in Eclipse to use xdebug and try to debug:
Launching renameUser has encountered a problem. An internal error occurred during "Launching renameUser" java.lang.NullPointerException.
Oh goodie...
I had also installed the Zend Debugger and added the following to those same two php.ini files:
zend_extension=/usr/lib/php5/20121212/ZendDebugger.so
zend_debugger.allow_hosts=127.0.0.1/32, 192.168.0.0/16
zend_debugger.expose_remotely=always
Changed debug configuration to use Zend Debugger and attempted to debug. Received:
Error launching 'renameUser' The debug session could not be started. Please make sure that the debugger is properly configured as a php.ini directive.
Restarted Eclipse and now the debugger attempts to run but simply terminates with a 255 exit value attempting to run /opt/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_64_5.3.18.v20110322/resources/php5/php-cgi. Why it's runnign php-cgi is beyond me. I said this was a CLI not a CGI. In any event I get the following when trying to run this from the command line:
Andromeda:/opt/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_64_5.3.18.v20110322/resources/php5/php-cgi
/opt/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_64_5.3.18.v20110322/resources/php5/php-cgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
Found a libiconv.so.2 in /opt/eclipse/plugins/org.zend.php.debug.debugger.linux.x86_64_5.3.18.v20110322/resources/lib and set LD_LIBRARY_PATH to include that but this just fails to launch the debugger at all stating to make sure that the debugger is properly configured as a php.ini directive... UGH!
Other odd stuff:
When Eclipse starts up it fails to open my RSE based project thus displaying edit buffers from the last run as empty
Eclipse will no longer exit! Select File: Exit. Nothing happens. Click on the X in the title bar - nothing happens. Now I have to kill it to close it!
When debugging on the command line you need to tell PHP you want to debug also
http://xdebug.org/docs/remote
says
export XDEBUG_CONFIG="idekey=session_name"
php myscript.php
assuming xdebug is enabled (it doesnt matter which .ini file its in, but there is a standard place per OS for this, usually in a conf.d folder called xdebug.ini which is auto included)
This allows you to debug a cmdline script.
Personally I use Vim with Vdebug extention (xdebug for vim) to debug and nothing other than a command line is needed
What worked for me was using dephpugger. I found the steps to get CLI debugging working here:
https://hackernoon.com/how-debug-php-applications-with-dephpugger-98cc234d917c
I had previously installed xdebug and tried out exussum's answer.
The steps I followed are included here for completeness.
Install dephpugger:
composer global require “tacnoman/dephpugger”:”dev-master”
Put dephpugger on the path:
export PATH=$PATH:$HOME/.composer/vendor/bin
make sure to include in the php file at the breakpoint:
xdebug_break();
open up 2 terminal instances. In one run:
dephpugger debug
In the other run
dephpugger cli /path/file.php
replacing /path/file.php with the path to your file. if you need command line arguments to the php script put the path and arguments in quotes. It still seems a little hacky. I think the real trick is to write in a language that has a better debugger built in.
exussums answer works for me.
In addition I have the following in /etc/php/7.0/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_enable=true
#xdebug.remote_enable=false
And I had to do this: https://github.com/vim-vdebug/vdebug/issues/363
Being able to set break points in a PHP script requires some kind of debugger extension being loaded, either XDebug or Zend Debugger.
And then you need some kind of interface to this debugger to make your wishes about break points known. I am unfamiliar with the Perl debugging, but I haven't heard about any PHP CLI based debugging - it is always taking place in an IDE that is able to handle the debugging protocol of one of the extensions.
Of course there is the good old var_dump();die('hi'); debugging, but this does not include continuing code execution after the script ended. ;)
I assume I'm making some simple mistake, but I just can't get the Google App Engine PHP SDK (GAE) "helloworld" example to work.
When I attempt to run the example on a Windows XP command line, I get no errors. The dev appserver is ever started on port 8080. I followed the GAE PHP SDK "Getting Started" page to the letter. If I mistype the path name, I get an error on that, but that’s it.
I have installed Python 2.7, PHP 5.4 and the GAE PHP SDK 1.8.3. All seem to work independently without error. Testing such…phpinfo() works, the Python interpreter works as well.
I’ve read all of the other questions/answers on this subject on the Stack(here) but nothing has helped. Here's some details:
My "helloworld" dir (the app.yawl file is there too):
C:\helloworld\helloworld.php
My Google GAE dir:
C:\google_appengine
My PHP dir:
C:\PHP
My Python dir:
C:\Python27
Here's the dev appserver startup command line I'm using in a Windows XP CMD window:
python C:\google_appengine\dev_appserver.py --php_executable_path=C:\PHP\php-cgi.exe C:\helloworld\helloworld
The dev web server does not start, can't see the listener on default port 8080 in netstat.
You said that the app.yawl file is present in the helloworld directory.
Its actually app.yaml . You may have saved that with incorrect extension. Check it.
The other thing I noticed is in the last command you are pointing to the .php file as C:\helloworld\helloworld.
You should actually point to the APPLICATION_DIRECTORY, which in your case is just C:/helloworld/
I'm deploying a PHP application on Heroku and I need to run some tasks using CLI.
In order to do that I have to set LD_LIBRARY_PATH env variable using this command:
heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
but every time I do it toolbelt overrides the command and the variable points to C:\Program Files (x86)\Git\app\php\ext;C:\Program Files (x86)\Git\app\apache\lib. Obviously it's not okay. Does anyone have any ideas how to do this in proper way?
5 days passed and still I have no answer. The CLI interface is used by scheduler, so I could use this workaround:
export LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib && ~/bin/php ~/www/index.php cron
This is actually not a problem with Heroku toolbelt, it's documented behavior by msys (I'm assuming you're running this in the msysgit shell). You can either run the command in a different shell (eg. Powershell) or use '//' at the start of the path like this:
heroku config:add LD_LIBRARY_PATH=//app/php/ext://app/apache/lib
This won't cause problems when the path is used on Linux.