Cygwin Console : Can't Execute PHP Scripts Locally In Command Line - php

I am trying to run a php script locally placed under wamp folder in cygwin command line but getting the following error -
"-bash: php: command not found"
The Local Server I am using is WAMP.
The php.exe file is in the path C:/wamp64/bin/php/php5.6.24
and I am using cygwin in windows 10.
Any suggestion regarding this will be highly appreciated.
Many thanks in advance.
Ritaja

Related

PHP Command line don't execute command

I installed xampp and put the php folder in my environment variable.
When I execute the "php filename.php" command, it always opens the interactive mode, it's the same with wamp.
Could someone help me? thank you

How to run php script in command line interface windows OS

I have installed xampp in my windows OS.completed the configuration settings .But i can't run a simple php script from CMD . Is there anything should i do bfore running the script .
Be sure, that php is added to your path variable, so you can run php -v in your terminal. You should get the current version of your installed php.
If php was added to your path variable, you can run a php script like php file.php
See http://php.net/manual/en/faq.installation.php#faq.installation.addtopath
First, you have to go till that file path in command prompt then use command to execute php script,
php file_name.php

How to run php code on command prompt using xampp

hey I want to run php on command prompt with xampp server. I made 2 environmental variables C:\xampp\php and C:\xampp\mysql\bin. how to execute the php code now?
Run command from console
c:\xampp\<path to php>\php.exe <path_to_your_php_project>\your_script.php

Command php not found in Windows

I have installed xampp server in windows 7. I have already checked Browser its working.But I am trying to run the php -v command prompt. I receive the following error message.
´php´ is not recognized as an internal or external command,
operable program or batch file
This pops up if Windows doesnt know about php. To solve this you have to add the full path to the php.exe to your PATH-variable in windows.
After you restart the console php should be available.
Add the php folder to your path and restart cmd.
Use this command from the command line (use the path to the php.exe, it is usually under c:\xampp\php):
set PATH=%PATH%;C:\xampp\php
Add the full path to find the folder, for example:
c:\xampp\php\php.exe -v or c:\xampp\php\php.exe -version

How can I run a php without a web server?

I would like to ask if I can run a php without having installed a web server. Do I have to use the php like CGI and run my page via command line? And if so, what are the steps that I do I have to choose through the installation of php? I mean the preferences as CGI and the components after that step?
I installed the php 5.3.3 but is seems not working, I get several message that the php5ts.dll is missing and when I put that file in my ext folder other error messages appear. Are there any configuration files or steps that I have to use?
(is php 5.3.3 suitable for doing something like this?)
If I have to have a web server installed how can I run my php code through the command line?
You should normally be able to run a php file (after a successful installation) just by running this command:
$ /path/to/php myfile.php // unix way
C:\php\php.exe myfile.php // windows way
You can read more about running PHP in CLI mode here.
It's worth adding that PHP from version 5.4 onwards is able to run a web server on its own. You can do it by running this code in a folder which you want to serve the pages from:
$ php -S localhost:8000
You can read more about running a PHP in a Web Server mode here.
For windows system you should be able to run php by following below steps:
Download php version you want to use and put it in c:\php.
append ;c:\php to your system path using cmd or gui.
call $ php -S localhost:8000 command in a folder which you want to serve the pages from.
PHP is a normal sripting language similar to bash or python or perl. So a script with shebang works, at least on linux.
Example PHP file:
#!/usr/bin/env php
<?php
echo("Hello World!\n")
?>
How to run it:
$ chmod 755 hello.php # do this only once
$ ./hello.php
You can use these kind of programs to emulate an apache web server and run PHP on your computer:
http://www.wampserver.com/en/
http://www.apachefriends.org/en/xampp.html

Categories