Home > php教程 > php手册 > Quickly build a development environment through PHP7's built-in web service, and it's all done with a BAT script

Quickly build a development environment through PHP7's built-in web service, and it's all done with a BAT script

WBOY
Release: 2016-09-24 09:02:58
Original
1426 people have browsed it

Since PHP5.4, PHP has a built-in web server. When deploying the development environment, we can completely ignore the WAMP or WNMP environment and use PHP directly.
Foreword: First of all, congratulations on the smooth launch of ThinkPHP5. I am very grateful to Think for its long-term contribution to PHP development. I will also make a small tool for you here, which can be considered as a marginal support for ThinkPHP5! Hehe...

Background: Since PHP5.4, PHP has a built-in web server. When deploying the development environment, we can completely ignore the WAMP or WNMP environment and directly use the command PHP -S http://localhost:8000 to make the PHP project Started running. In Windows, we usually do not set the system environment Path, and PHP configuration is a bit troublesome. It is not easy for some people to allow CMD to execute PHP.

Goal: No need to install WNMP or WAMP environment, realize rapid deployment of PHP development and running environment, and get started with one click.

Let’s get started: Here I wrote a BAT script for you, which can automatically detect and install the PHP environment, and start the PHP built-in WEB service. The content of the BAT script can be seen below. Just place a start.bat file in the project root directory and double-click this file to open your PHP project. The PHP version used by this tool is PHP7.0.10. When the script is run, a PHP directory will be automatically downloaded and placed under the root of the current drive letter. This PHP is the official window version. When the tool is initially run, you may be asked to install the VC library. Just install it according to the prompts. If you do not install it, PHP will not be able to run, resulting in various dll file loss errors! The specific deployment is as shown below, in which the start.bat file has been compressed and uploaded. Please download it in the attachment!

Note: Some anti-virus software will report viruses. You know this. It is recommended that you use Tencent Butler or add it to the trust list. Ha ha! ! !

Tips: To run the script for the first time, you need to download php.zip and VC library program through VB, so you need to wait for a while. Don’t be impatient and run the BAT script again. Of course, after installation, you can run it casually, and you can open it multiple times. After all, the WEB service port is randomly calculated.
Quickly build a development environment through PHP7's built-in web service, and it's all done with a BAT script
Quickly build a development environment through PHP7's built-in web service, and it's all done with a BAT script@echo off<br> <br> :: PHP simple development environment construction tool V1.0<br> ::<br> :: Author: Anyon <zoujingli><br> :: Website: http://www.ctolog.com<br> :: Created: 2016/09/22 20:20<br> <br> title HTTP-SERVER<br> <br> set pan=%~d0<br> :: Determine whether the PHP running environment exists<br> if not exist %pan%php (goto down) else (goto start)<br> <br> <br> :start<br> cls<br> <br> :: Temporarily set the PHP running environment path<br> Set path=%~dp0..php;%~dp0php;%pan%php;%path% <br> <br> :: Random computing service running port<br> ​ set port=%random%<br> Set /a port=port%%1000+2000<br> Title [ %port% ] HTTP-SERVER<br> <br> ::Open a browser window<br> Start http://localhost:%port%<br> <br> ::Start the Web service process<br> @echo on<br> @php -S localhost:%port%<br> Goto end<br> <br> :down<br> cls <br> Echo.<br> ​​echo ​The local environment is not detected, trying to download and install, please wait...<br> Echo.<br> <br> :: Resource path definition<br> Set src=http://zoujingli.oschina.io/static/php-install/php.zip<br> Set des=%pan%php.zip<br> ​ <br> set sof_32=http://zoujingli.oschina.io/static/php-install/vc_redist.x86.exe<br> Set sof_des_32=%pan%vc_redist.x86.exe<br> <br> set sof_64=http://zoujingli.oschina.io/static/php-install/vc_redist.x64.exe<br> Set sof_des_64=%pan%vc_redist.x64.exe<br> ​ <br> ​ set script=%pan%script.vbs<br> ​ set dir=%pan%<br> <br> :: Generate VB script, download and process PHP support program<br> echo Set xPost = CreateObject("Microsoft.XMLHTTP") >%script%<br> echo xPost.Open "GET","%src%",0 >>%script%<br> echo xPost.Send() >>%script%<br> echo Set sGet = CreateObject("ADODB.Stream") >>%script%<br>    echo sGet.Mode = 3 >>%script%<br>     echo sGet.Type = 1 >>%script%<br>     echo sGet.Open() >>%script%<br>     echo sGet.Write(xPost.responseBody) >>%script%<br>     echo sGet.SaveToFile "%des%",2 >>%script%<br>     <br>     if "%PROCESSOR_ARCHITECTURE%"=="x86" (        <br>         echo Set xPost = CreateObject("Microsoft.XMLHTTP") >>%script%    <br>         echo xPost.Open "GET","%sof_32%",0 >>%script%<br>         echo xPost.Send() >>%script%<br>         echo Set sGet = CreateObject("ADODB.Stream") >>%script%<br>         echo sGet.Mode = 3 >>%script%<br>         echo sGet.Type = 1 >>%script%<br>         echo sGet.Open() >>%script%<br>         echo sGet.Write(xPost.responseBody) >>%script%<br>         echo sGet.SaveToFile "%sof_des_32%",2 >>%script%<br>     ) else (<br>         echo Set xPost = CreateObject("Microsoft.XMLHTTP") >>%script%    <br>         echo xPost.Open "GET","%sof_64%",0 >>%script%<br>         echo xPost.Send() >>%script%<br>         echo Set sGet = CreateObject("ADODB.Stream") >>%script%<br>         echo sGet.Mode = 3 >>%script%<br>         echo sGet.Type = 1 >>%script%<br>         echo sGet.Open() >>%script%<br>         echo sGet.Write(xPost.responseBody) >>%script%<br>         echo sGet.SaveToFile "%sof_des_64%",2 >>%script%<br>     )<br>     <br>     :: 定义ZIP解析函数<br>     echo Sub UnZip(ByVal myZipFile, ByVal myTargetDir) >>%script%<br>     echo     Set fso = CreateObject("Scripting.FileSystemObject") >>%script%<br>     echo     If NOT fso.FileExists(myZipFile) Then >>%script%<br>     echo         Exit Sub >>%script%<br>     echo     ElseIf NOT fso.FolderExists(myTargetDir) Then >>%script%<br>     echo         fso.CreateFolder(myTargetDir) >>%script%<br>     echo     End If >>%script%<br>     echo     Set objShell = CreateObject("Shell.Application") >>%script%<br>     echo     Set objSource = objShell.NameSpace(myZipFile) >>%script%<br>     echo     Set objFolderItem = objSource.Items() >>%script%<br>     echo     Set objTarget = objShell.NameSpace(myTargetDir) >>%script%<br>echo intOptions = 256 >>%script%<br> echo objTarget.CopyHere objFolderItem, intOptions >>%script%<br> echo End Sub >>%script%<br> :: Unzip ZIP file<br> echo UnZip "%des%", "%dir%" >>%script%<br> :: Execute VB script<br> cscript %script%<br> ​ <br> cls<br> Echo.<br> Echo Here you will be prompted to install the VC support library, please follow the prompts! <br> Echo.<br> ​ ​ ​ ​ --- If it is not installed, please follow the prompts to install it! ---<br> Echo.<br> ​ ​ ​ ​ --- If it is already installed, please ignore and close the prompt box! ---<br> Echo.<br> ​ <br> ::Install and generate VB cleaning script<br> echo Set fso = CreateObject("Scripting.FileSystemObject") >%script%<br> echo fso.deleteFile "%des%" >>%script%<br> If "%PROCESSOR_ARCHITECTURE%"=="x86" (<br>           %sof_des_32%<br> echo fso.deleteFile "%sof_des_32%" >>%script%<br> ) else (<br>           %sof_des_64%<br> echo fso.deleteFile "%sof_des_64%" >>%script%<br> )<br> echo fso.deleteFile "%script%" >>%script%<br> :: Execute VB script<br> cscript %script%<br> <br> cls<br> Goto start<br> <br> :end</zoujingli>Update: The resource address is updated to the Oschina server

Quickly build a development environment through PHP7s built-in web service, and its all done with a BAT script start.zip ( 1.44 KB Download: 10 times )

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template