Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute PHP files from the command line

After I got an issue with Jenkins, that the deployment is hanging up on jobs, that need to execute PHP on the command line (pdepend, phpmd, phpcpd etc.), and noticed, that I also cannot re-install Composer or run tools like PHPLoc on the command line, I created a PHP file

<?php
print_r(get_defined_constants());

and tried to execute it on the command line:

php phptest.php

And it didn't work. When I do so, nothing happens. No errors. Just nothing:

enter image description here

The environment is PHP 7.0.3 and Ubuntu 14.04.3 (in a VirtualBox VM). Btw. php -v or php -i executed on the command line is still working.

What might cause this issue and how to solve it?

EDIT

The permissions seem to be correct:

root@ubuntuvm:~/Desktop# ls -lia | grep "phptest.php"
132234 -rw-r--r--  1 root root   40 Aug  2 17:29 phptest.php

777 is also not working:

root@ubuntuvm:~/Desktop# chmod 777 ./phptest.php 
root@ubuntuvm:~/Desktop# php phptest.php
^C

The error reporting is set up:

/etc/php/7.0/cli

error_reporting = E_ALL
display_errors = On
log_errors = On
error_log = /var/log/php_errors.log
like image 548
automatix Avatar asked May 06 '26 00:05

automatix


1 Answers

This just started happening to me and I finally figured it out. I don't know if this was your problem or if you can replicate it, but hopefully this may help somebody else.

I had two projects open in PHPStorm and in one of those projects I had turned on "Listen for PHP Debug Connections" and due to some configuration option, as soon as I ran ANY php script anywhere on my system, that one PHPStorm window would grab the process and halt it for debugging.

enter image description here

Normally, this would cause PHPStorm to jump forward to be the top-most window to give me a visual cue that it can taken control, but due to the type of script I was running I was immediately switching windows after starting it. So my manual window switching made me not notice PHPStorm's auto-switch.

After making PHPStorm stop listening for connections, I was able to run scripts again.

like image 119
Kenny Wyland Avatar answered May 07 '26 14:05

Kenny Wyland