I'm trying to use SASS from PHP but I always get a 127 error.
Here is what I'm doing:
$command = 'sass pathtomyfile.scss:pathtomyfile.css';
system($command, $return);
echo $return; // give me: 127
If I run the exact same command in the terminal, everything work fine.
Note that I'm trying to do it on Mac OS X.
Edit: I believe this is a permission issue but I have no idea of how to solve this.
Edit 2: I'm using rvm
127 error is command not found make sure the PATH is set correctly to a place where sass command was installed or full path to the command, you can find the full path to sass by running in your shell which sass.
As you use RVM you can make sure proper environment is used with wrappers:
$ rvm use 1.9.3 --install
$ gem install sass
$ rvm wrapper 1.9.3 php sass
$ which php_sass
/home/user/.rvm/bin/php_sass
and use the returned path to run sass.
Related
So I have installed MAMP and I am using PHP, however I also used Terminal with PHP as well. Now for some reason Terminal is not working with PHP anymore, for example:
Terminal / PHP command not found
So basically I can not work with anything at the moment. I have also simplified .bashrc and .bash_profile.
Terminal and PHP not found
Thanks. mac-machine
cd ~ && nano .zshrc
Add the path of php in .zshrc like:
export PATH=/Applications/MAMP/bin/php/php8.0.8/bin:$PATH
Then run source .zshrc and run php -v to confirm path setup
The problem is working with PHP command line is not found with ZSH, it gets a message: zsh: command not found: php.
So working with older BASH instead of ZSH it works fine.
I am trying to install composer through php, as described in their wesite.
php -r "readfile('https://getcomposer.org/installer');" | php
But it is displaying the following error:
$ php -r "readfile('https://getcomposer.org/installer');" | php
output is not a tty
input is not a tty
I am in windows 7 and using git bash to execute this command. At windows command prompt, it is working fine. This problem is only occur when I run this command from git bash 2.6.2-64bit.
BTW, I have installed composer for windows, and that is working fine. But I can not download composer.phar in this way. How can I fix this issue?
It can be a PATH or an encoding issue:
issue 25 mentions:
it seems that git ls-remote origin, run from a freshly-built and installed MinGW Git fails to be able to output anything, and git ls-remote origin | cat (a trick learned from working with old MSys'/MinGW's quirks) only says: output is not a tty (the exit code is 127, suggesting that some executable was not found, but it is very difficult to say which one because not even debug print statements to stderr are shown; It seems that in case of a crash or of a die(), stderr is not flushed)
issue 519 even suggests to unalias winpty
unalias $(alias | grep winpty | cut -d"=" -f1 | cut -d" " -f2)
But:
No, we cannot simply abandon winpty. PHP can be run interactively, i.e. it requires a proper Win32 Console. Running PHP without winpty in MinTTY would not provide that Console instance, leaving you with a seemingly unresponsive terminal.
See git-for-windows/build-extra#44ed99b, #399 and #400 to understand what havoc you would wreak by simply removing those aliases.
So right now, the bash console is not compatible with executing php through pipe (as the second | php might not benefit from winpty, which seems needed when a program requires a Win32 Console for interactive usage).
Peh points out in the comments:
If you use C:`Program Files\Git\bin\bash.exeinstead ofC:\Program Files\Git\git-bash.exe`, then the command works fine.
I'm using it in combination with ConsoleZ without any problems
That probably is because bash.exe does not use winpty, contrary to git-bash.exe.
VonC's answer is correct, and to help others in the future I want to provide a more visual solution.
Navigate to C:\Program Files\Git\bin
Double-click on bash.exe
You should now see a command prompt.
Navigate to your PHP project directory and install Composer.
$ cd C:\path\to\your\project
$ curl -sS https://getcomposer.org/installer | php
$ ls
The file composer.phar is now visible in project root.
Install a package with composer.
$ php composer.phar require some-package-you-want-to-install
Can output by using bash: C:\Program Files\Git\bin\bash.exe
I'm trying to get formatted coloured output from a command line utility presented on a php web page.
I'm using ansi2html.sh from http://www.pixelbeat.org/scripts/ansi2html.sh
It works fine if I run the same command from the command line. I am on OSX.
The command I am running is:
exec ("vendor/bin/phinx migrate -e development | ../../phinx_upgrades/ansi2html.sh 2>&1", $phinx_output, $phinx_return);
The output I get is:
../../phinx_upgrades/ansi2html.sh: line 38: gawk: command not found
So I assume its running the script, but it cant find gawk. I did brew install gawk but its already installed.
I can run gawk from command line, gawk --version gives me GNU Awk 4.1.1, API: 1.1
If I ask which gawk I get /usr/local/bin/gawk
When I echo $PATH I see /usr/local/bin as one of my paths.
I'm not familar with OSX, but i think that you have to add gawk folder to your environment variable PATH
Also, check directly on your bash if you can launch gawk, if it is work fine in your bash, so restart your Apache server
Hope that helps :)
Answer PHP exec $PATH variable missing elements should give hints for setting up the right $PATH for the php call. As a quick fix you could edit the ansi2html.sh script to reference /usr/local/bin/gawk directly
I am trying to compile less file using php, and I am trying to use lessc which I installed as nodejs module on my windows 7
I am trying to do :
$command = lessc %s -compress %s
via
exec($command, $output);
and if I do this via cmd it works fine but I can't execute it using above command in php :(.
the path which works are relative to my drive (E:/wamp/my-project/less/hello.less)
Any body knows what I am doing wrong?
Note: I know how I can use lessphp compiler, and I am already using it but I would like to use lessc module installed via nodejs.
Are you able to get the output of the command when it fails? It's possible that lessc isn't directly available in your path. If you installed it via npm install -g then it will likely be in %appdata%, which is a user path'd directory. It really depends upon how the php process gets initiated, but my guess is that this path won't work.
If I need to use an npm module like this, I usually npm install it locally, and invoke the path to lessc.cmd from a relative path to my program.
Hope this helps. Happy coding!
hi i start working Laravel 4, i have finished the installation process with composer, but when try to use artisan it always give a message
Laravel requires the Mcrypt PHP extension
i have checked with php_info() it shows me Mcrypt PHP extension is enabled, after searching on web i have found some solutions, if i apply those then composer stops working viceversa . i am using XAMPP for development if i use which php command in terminal it show me path /usr/bin/php but my development php is in /Applications/XAMPP/xamppfiles/bin, i have extend the $PATH using .bash_profile
export XAMPP_PHP=/Applications/XAMPP/xamppfiles/bin
export PATH="$XAMPP_PHP:$PATH"
after this artisan start work great but composer stops its working if i type composer command in terminal it show ???? output, now i want composer, php and artisan work perfect just looking for good settings
I solved this problem with a workaround. Instead of changing the $PATH variable, on /usr/bin/ I created a symbolic link to XAMPP's PHP:
cd /usr/bin/
ln -s /Applications/XAMPP/xamppfiles/bin/php phpx
'phpx' is the name I gave to run php on XAMPP (pick the name you prefer - obviously it needs to be different than 'php'). This way I can run artisan using 'phpx' (XAMPP version) which has mcrypt. For example:
phpx artisan key:generate
And if you need to run composer, you run php (mac version):
php composer.phar install
It's a workaround, I'm not proud of it, but it's working.
The best solution would be to install mcrypt on your mac (use this tutorial), mysql and use mac's php. But as a lot of developers (including me) still rely on XAMPP, this workaround may be enough for testing.
If it outputs ???? it most likely means you have detect_unicode = On in your php.ini. This must be off because it breaks phar files.