natanfelles / php-server
Fine tuning on the PHP Built-in web server.
Installs: 9 090
Dependents: 2
Suggesters: 0
Security: 0
Stars: 25
Watchers: 5
Forks: 1
Open Issues: 0
Requires
- php: >=5.6.0
README
Fine tuning on the PHP Built-in web server
See release notes at: https://github.com/natanfelles/php-server/releases
Installation
Composer
Open your terminal and run:
composer global require natanfelles/php-server
Add the composer bin path to your .bashrc:
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
Manual
Download and extract the php-server project folder.
Add the php-server alias to your .bashrc:
echo 'alias php-server="~/php-server/bin/php-server"' >> ~/.bashrc
Config
You can run the php-server in any folder of your operating system.
Each time you run the php-server command, it will look up if there is a file named php-server.ini in the current directory. If found, your settings will override the default settings.
A quick example file content is:
php = PHP_BINARY host = localhost port = 8080 root = ./public autoindex = true index = index.php error_reporting = E_ALL [ini] display_errors = 1 display_startup_errors = 1 max_execution_time = 360 post_max_size = 200M upload_max_filesize = 200M ; Array of runtime extensions: extension[] = mysqli extension[] = zip [server] ENVIRONMENT = development
You can use the command
php-server new
to create a new configuration file in the current directory.
Explanation
General Vars
Sections
Knowing this, just create (if necessary) a php-server.ini file, run the server and you're done.
Run
As you can see in the config. You can create a php-server.ini file to leave the settings of each project already pre-established.
But, you can also simply run php-server
and the server will already be available at http://localhost:8080.
The php-server command can receive some parameters and they are:
For example, to run the server on a different port:
php-server --port 8081
Or, also with a different version of PHP than the default:
php-server --php php7.4 --port 8081
Right. You get the idea. If you want to run on a different host you can add the host to the hosts file of your operating system.
Contribute
Hello, how nice that you are reading this.
If you have any idea to improve this project or something is not working as it should, do not hesitate to open an issue and if you have solved the problem feel free to open a Pull Request.