Launch PHP Server locally with just 2 clicks!
This is an option for those who are too lazy to write the command to start PHP Local Server every time it is needed. 😜
In fact, this script will executes the php -S localhost:YOUR_PORT command from the directory and on the port configured by the user.
- PHP needs installed for the script to work.
- This script only works on Windows.
Open the batch file in a text editor of your choice (Notepad, VS Code, etc...) and find the block that starts on line 22 of the code.
On line 23, change the value of the language variable to the following values according to your language:
- pt-BR to set in Brazilian Portuguese (this is the default language because i'm brazilian hehehe);
- en to set in english;
- es to set in spanish;
On line 24, change the value of the start_path variable to the full path of the folder where you want to consider the root directory to run the PHP files.
For example, if you set start_path to "C:\Users\Thomaz\Projetos_PHP", all PHP files that are inside that directory can be executed.
If the path specified in the start_path variable does not exist or is invalid, the script will display a message stating that the path is invalid and will terminate.
On line 25, change the value of the port variable to the port you want to run the PHP Server.
ATTENTION: The value of the variable port must be declared as a number (without quotes) and not as a string.
"I will always choose a lazy person to do a difficult job because he will find an easy way to do it." - Bill Gates