概述
蛊毒传说
PHP CLI作为它的调用(php用于命令行接口)称为php.exec:wampbinphpphp5.x.yphp.exe(其中x和y是已安装的php的版本号)如果您想要创建从命令行运行的php片段,那么它非常简单,非常有用。创建这样的批处理文件,让我们称之为phppath.cmd :PATH=%PATH%;c:wampbinphpphpx.y.z
php -v变化x.y.z已安装在WAMPServer中的PHP版本的有效文件夹名称将其保存到已经在您的路径上的文件夹中,以便您可以在任何地方运行它。现在,从命令窗口,CD进入源文件夹并运行>phppath。那就跑PHP_script.php它应该像梦一样工作。下面是一个配置PHPComposer和PEAR的示例,如果需要的话,它们是存在的@echo off
REM **************************************************************REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by defaultREM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServerREM **************************************************************set baseWamp=D:wampset defaultPHPver=7.1.9set composerInstalled=%baseWamp%composerset phpFolder=binphpphpif %1.==. (
set phpver=%baseWamp%%phpFolder%%defaultPHPver%) else (
set phpver=%baseWamp%%phpFolder%%1)PATH=%PATH%;%phpver%php -v
echo ---------------------------------------------------------------REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=D:wampbinphpphp%phpver%pear set PHP_PEAR_DOC_DIR=D:wampbinphpphp%phpver%docs set PHP_PEAR_BIN_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_DATA_DIR=D:wampbinphpphp%phpver%data set PHP_PEAR_PHP_BIN=D:wampbinphpphp%phpver%php.exe set PHP_PEAR_TEST_DIR=D:wampbinphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------)REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *REM * This assumes that composer is installed in /wamp/composer
REM *REM **************************************************************IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=%baseWamp%composer set COMPOSER_CACHE_DIR=%baseWamp%composer
PATH=%PATH%;%baseWamp%composer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------)set baseWamp=set defaultPHPver=set composerInstalled=set phpFolder=像这样调用这个命令文件来使用PHP的默认版本> phppath或者获得以下PHP的特定版本> phppath 5.6.30
最后
以上就是传统指甲油为你收集整理的wamp如何配置php命令行,如何在WAMPServer中从Windows命令行运行PHP的全部内容,希望文章能够帮你解决wamp如何配置php命令行,如何在WAMPServer中从Windows命令行运行PHP所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复