PATH for PHP "Command Not Found" - php

Forgive me for my ignorance here: I am coding in Symfony2 and I am trying to use the app/console commands to speed up development.
In any case I am using XAMPP for my local server and I am needing to specify where php is installed in my PATH to use app/console.
Here is what my PATH looks like inside of my .bash_profile:
/opt/subversion/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Applications/XAMPP/xamppfiles/bin/php:/usr/local/git/binalias
But when I run php -v I get:
-bash: php: command not found
When I try and run: php ./app/console from inside of my symfony root, I get:
-bash: php: command not found
If I run:
/Applications/XAMPP/xamppfiles/bin/php -v
I get:
PHP 5.5.3 (cli) (built: Aug 26 2013 08:28:37)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
Why is my PATH not working when I run, php ./app/console from inside of my Symfony directory.
Any assistance would be GREATLY welcomed. Thanks.

Your path is wrong:
/opt/subversion/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Applications/XAMPP/xamppfiles/bin/php:/usr/local/git/binalias
This part:
/Applications/XAMPP/xamppfiles/bin/php
Should be:
/Applications/XAMPP/xamppfiles/bin

Related

Running gulp in docksal

I have a Drupal 9 (this isn't a Drupal question) site installed in a Docksal container. In its theme I have node.js and gulp.
I seem to have a Catch-22.
From the command line:
$ gulp
Pattern Lab Node v5.4.0
Pattern Engine mustache: good to go
Error: php cli required. Command failed: /bin/sh -c php --version
/bin/sh: php: command not found
So I go to the bash shell in Docksal, because I know that from there I can, for instance, do this:
$ php -v
PHP 8.1.4 (cli) (built: Mar 29 2022 02:03:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.4, Copyright (c) Zend Technologies
with Zend OPcache v8.1.4, Copyright (c), by Zend Technologies
with blackfire v1.76.0~linux-x64-non_zts81, https://blackfire.io, by Blackfire
that is, run php from the command line.
When I try running the gulp command there:
$ gulp
bash: gulp: command not found
I don't think I should have to run it from fin bash. I've been in other environments where gulp runs quite nicely from the command line in both docksal and lando, and the php command invokes php. I don't know what I'm missing here.

Laravel commands giving me errors, parse error, expecting `'&'' or `"variable

I am using osx, and have composer and Laravel both installed. I downloaded laravel fine, and chmodded the storage folder. Now if I run any command make: I am getti getting the following error:
Parse error: parse error, expecting '&'' or"variable (T_VARIABLE)"'
in
/Applications/XAMPP/xamppfiles/htdocs/eco/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
on line 484
I have run php -v in my terminal which returns:
PHP 7.1.4 (cli) (built: May 10 2017 16:03:28) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Inside my bash_profile I have the following:
export PATH=~/.composer/vendor/bin:$PATH
export XAMPP_HOME=/Applications/XAMPP
export PATH=${XAMPP_HOME}/bin/php-7.1.4:${PATH}
export PATH
and when I echo my path I have:
/Applications/XAMPP/bin/php-7.1.4:/Users/user/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.composer/vendor/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
I also ran 'which php' which returns:
/usr/local/bin/php
Composer is installed and laravel is too:
Does anyone have any idea what may be causing this, or a way to fix this? Thanks.

PHP --version shown incorrectly on osX

I've installed in my osX php7 from homebrew, however when I type in the shell eitherphp --version or php-fpm --version I get as result an older version
PHP 5.5.30 (fpm-fcgi) (built: Oct 23 2015 17:22:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
From the shell I looked for every php file or folder sudo find / -name "php" but nothing linked to PHP 5.5
What should I do?
After creating ~/.bash.profile as written in comments by Michael, I found the solution thanks to change the PHP path to MAMPs PHP
In ~/.bash_profile I wrote:
export PATH=/usr/local/Cellar/php70/7.0.2/bin:$PATH
export PATH=/usr/local/Cellar/php70/7.0.2/sbin:$PATH
First row is for php, the second for php-fpm
Then, to be sure that changes take effect type in terminal source ~/.bash_profile

Creating new project in Yii: error 'php: No such file or directory'

I am trying to create new yii application on Ubuntu by calling:
sudo yii-project/framework/yiic webapp yiidemo
from my htdocs dicectory(XAMPP).
The message I get is:
/usr/bin/env: php: No such file or directory
PHP is installed though. 'php -v' yelds:
PHP 5.5.11 (cli) (built: Apr 9 2014 14:29:14)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
My PATH looks like that('echo $PATH'):
/home/alan/home/alan/netbeans-8.0/bin/netbeans/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/lampp/bin
'php' seems to be in /opt/lampp/bin so the last entry.
Any advice on how to make it work and get rid of the error would be greatly appreciated :).
Solution:
1) Sudo PATH and user PATH differ. That's why 'sudo php -v' doesn't work.
User's path:
echo $PATH
/home/alan/home/alan/netbeans-8.0/bin/netbeans/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/lampp/bin
A proper way to echo sudo's path:
sudo /usr/bin/printenv PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2) I've installed PHP from repositories. I can now call 'sudo php'.
sudo apt-get install php5-cli
Thanks Matt and guys from Ubuntu forums(spjackson & SeijiSensei)!

How to use wsdl2phpgenerator on WAMP

I'm having a lot of trouble trying to get the php for a soap wsdl request working. I came across wsdl2phpgenerator which sounds like it generates the code for the service you want? Problem is I can't figure out how to use it. I'm running WAMP on my local machine. How do i install and use, the instruction don't seem to make a lot of sense to me.
I guess you use windows when you use WAMP.
You should not run the wsdl2phpgenerator through apache. You need to run it on the commandline.
step 1:
First open the CMD and type:
php --version
If the cmd prints something out like :
PHP 5.4.19 (cli) (built: Aug 23 2013 00:51:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
go to step 3:
step 2: add php to windows env path:
https://stackoverflow.com/a/9546345/1210773
use the path to your own php installation
after this run step 1 to validate php is correctly setup
Step3: run wsdl2phpgenerator
move the cmd to the wsdl2phpgenerator dir and run wsdl2php
I found some examples in the wsdl2phpgenerator documentation:
https://github.com/wsdl2phpgenerator/wsdl2phpgenerator/wiki/ExampleUsage

Categories