Running PHP on Windows Command Line in WAMPServer
If you're new to PHP and wish to execute it from the command line, WAMPServer can assist you. However, configuring the system variables to the PHP folder may not always provide the desired outcome. Here's a comprehensive guide to help you resolve this issue:
Identifying the PHP CLI
The PHP CLI (Command Line Interface) is known as php.exe and resides in the following path:
c:\wamp\bin\php\phpx.y.z\php.exe
(where x and y represent the version numbers of your installed PHP)
Creating a PHP Script
To write PHP scripts for execution from the command line:
PATH=%PATH%;c:\wamp\bin\php\phpx.y.z php -v
(Replace x.y.z with your PHP version)
Executing the Script
>phppath
php your_script.php
This method should provide you with the desired output.
Additional Configuration
For enhanced functionality, consider the following additional configuration:
set PHP_PEAR_SYSCONF_DIR=%baseWamp%\bin\php\phpx.y.z set PHP_PEAR_INSTALL_DIR=%baseWamp%\bin\php\phpx.y.z\pear set PHP_PEAR_DOC_DIR=%baseWamp%\bin\php\phpx.y.z\docs set PHP_PEAR_BIN_DIR=%baseWamp%\bin\php\phpx.y.z set PHP_PEAR_DATA_DIR=%baseWamp%\bin\php\phpx.y.z\data set PHP_PEAR_PHP_BIN=%baseWamp%\bin\php\phpx.y.z\php.exe set PHP_PEAR_TEST_DIR=%baseWamp%\bin\php\phpx.y.z\tests
set COMPOSER_HOME=%baseWamp%\composer set COMPOSER_CACHE_DIR=%baseWamp%\composer\cache PATH=%PATH%;%baseWamp%\composer
This enhanced configuration allows you to utilize PEAR and Composer functionalities, expanding your PHP development capabilities.
In summary, understanding the PHP CLI location and utilizing batch files for script execution ensures a seamless PHP experience from the Windows command line in WAMPServer.
The above is the detailed content of How Do I Run PHP Scripts from the Windows Command Line Using WAMPServer?. For more information, please follow other related articles on the PHP Chinese website!