Executing php program in eclipse - php

I installed php eclipse in my system i wrote sample php program and try to run it i'm getting error like this
Exception occurred executing command line.
Cannot run program "C:\Program Files\xampp\php" (in directory "C:\Program Files\xampp\php\www\Hello world"): CreateProcess error=5, Access is denied

Try naming your projects without spaces & installing XAMPP somewhere other then in Program Files like on the root C:
C:\xampp\php\www\HelloWorld
Most command line programs (EG:The launcher in this case) have problems with spaces in files & folder names, including the /Program Files/ directory.
Or in eclipse change the path to php.exe to C:\PROGRA~1\xampp\php

Related

How to run Yii console app from Ubuntu CLI?

I uploaded my project to a server running Ubuntu. The project has a console command logrotation/index. I want to run it through the command line, and Ubuntu says "yii: command not found". I tried to run it in different ways.
How to run this console application from the command line and then (for the future) put it as a cronjob?
Inside project directory:
./yii logrotation/index
Or
php yii logrotation/index
The error message "yii: command not found" means that Ubuntu can't find the binary in $PATH directories. So you need to specify ./ to show that you are executing a file from the current directory.

Lame conversion works in CMD but not in PHP

exec("lame audio.mp3 audio.wav")
Similar questions didn't helped.
This is the command that should be executed via PHP.
The audio.mp3 file presents in the directory and no permission issues.
Lame encoder is present at: C:\Program Files (x86)\Lame. This path is added into System Environmental Variables PATH.
lame command works in cmd, it displays the version as 3.99.3. (This means lame is installed and added to the PATH properly).
The PHP file present in the folder D:\XAMPP\htdocs\demo.php. Executing lame audio.mp3 audio.wav via cmd in the directory D:\XAMPP\htdocs runs properly and the mp3 file is converted to wave file without any issue.
The PHP exec is alone not working. Where I am missing?
Edit: The error.log file have the following error:
'lame' is not recognized as an internal or external command, operable
program or batch file.

Composer fail installation on PHP path

Im trying to install Composer.exe, and it always fail after I choose php.exe file and click next, with an error:
The PHP exe file you specified did not run correctly [exit code 1]: D:\Software(x86)\wamp64\bin\php\php7.0.10\php.exe
Program Output: 'D:\Software' is not recognized as an internal or external command, operable program or batch file.
Thing is: Path to the php.exe is valid. I have php in env variables, so if I run cmd and type in php it runs...
But if open cmd and type in path that I gave to the composer so D:\Software(x86)\wamp64\bin\php\php7.0.10\php.exe
It respond with 'D:\Software' is not recognized as an internal or external command, operable program or batch file. too.
To clarify, I restarted computer after php installation and I after added env variables.
And this is in my env path var: ...;D:\Software(x86)\wamp64\bin\php\php7.0.10\
I installed xampp on D:\ Drive and it didnt work too, then I
uninstalled it and istalled it on C:\ and it worked... Dunno what was
the problem, if someone can explain, please do. Thanks
I guess you have to escape the braces in windows. Either with a backslash or the complete folder with quotes

Creating batch file launching .phar with alias

I'm currently experimenting with WP-CLI (http://wp-cli.org) - I have finally managed to get it to run on my basic command line by downloading/moving it to a PATH variable directory (i.e C:\xampp\php) and then updating my PATHSPEC to include .PHAR.
I have renamed the original file from wp-cli.phar to wp.phar in order to be able to reference it as wp in my cmd.exe.
Prior to this method I installed wp-cli using CURL and chmod in my Git Bash installation then renaming the file to wp (without an extension) and adding the path containing file to the PATH variable. This caused the .PHAR file to work in Git Bash but not to work on the command line.
MY ISSUE:
Whenever I try to use my wp.phar in the native CLI I get a php error report - it does recognise the command and does show a list of suggestions (which is usually given when syntax is incomplete or incorrect).
How do I even start to figure this out?
1 - I've attempted to look for a git batch file in my Git Bash directory to see if I can find a dependency I'm missing but no dice.
2 - My Git Bash is now not recognizing the wp command and I now need to refer to wp.pharand then add any sub-commands/arguments after. However using the Git Bash CLI wp.phar doesn't cause errors
After a few months I found a solution.
Make sure that your PHP root folder path and the folder path containing your phar files are added to the Windows PATH Environment Variable (to allow us to just use the filename to refer to them).
CMD Line Options (Run as Administrator):
assoc .php=phpfile and assoc .phar=pharfile
Next is adding the program that opens this file. Adding an ftype command allows us to open .php/.phar files without using the php.
ftype pharfile=php.exe %1 %* (The %1 is a placeholder for the file called and %* refers to any other arguments that many be input).
FINALLY
The key issue was getting the .phar scripts to execute in the command line as windows ends up trying to open these files in it's Open With Dialog
So what I did was wrap my .phar in a batch file with this command (in the same folder as the phar
echo php "%~dp0wp-cli.phar" %* > [name of file].cmd
I then run this file as [name of file] with any arguments and it works as usual.

Running php file through command line?

Everytime I try to load a file through command line I get this message:
Could not open input file: dummy.php
I have tried everything,
php C:\Program Files (x86)\Zend\Apache2\htdocs\dummpy.php
php dummy.php
php htdocs\dummy.php
I can't run a file! I can get php information and all other stuff, so I belive my CLI is ok.
I actually need this to run phpwebsocket, but I can't run anything through CLI.
You either need to enter the path without spaces, like this:
php c:\progra~2\Zend\Apache2\htdocs\dummy.php
Or, you can put quotes around the whole thing since your path does have spaces, like this:
php "C:\Program Files (x86)\Zend\Apache2\htdocs\dummy.php"
Or, when you open your command prompt, make sure to navigate to the folder that your PHP file exists in. For example, a simple navigation might look this this (type enter after each line):
cd \
cd Program Files (x86)
cd zend
cd apache2
cd htdocs
php dummy.php
If you write
php dummy.php
you must be sure that your current directory is
C:\Program Files (x86)\Zend\Apache2\htdocs\

Categories