Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Fine-tuning on the PHP built-in web server

License

NotificationsYou must be signed in to change notification settings

natanfelles/php-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest releasePHP versionPackagist downloads

Fine-tuning on the PHP built-in web server

PHP Built-in web server autoindex

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

Run:

source~/.bashrc

Manual

Download and extract thephp-server project folder.

Add the php-server alias to your.bashrc:

echo'alias php-server="~/php-server/bin/php-server"'>>~/.bashrc

Run:

source~/.bashrc

Config

You can run the php-server in any folder of your operating system.

Each time you run thephp-server command, it will look up if there is a file namedphp-server.ini in the current directory. If found, your settings will override the default settings.

A quick example file content is:

php = PHP_BINARYhost = localhostport = 8080root = ./publicautoindex = trueindex = index.phperror_reporting = E_ALL[ini]display_errors = 1display_startup_errors = 1max_execution_time = 360post_max_size = 200Mupload_max_filesize = 200M[server]ENVIRONMENT = development

You can use the commandphp-server new to create a new configuration file in the current directory.

Explanation

General Vars

KeyDefault ValueDescription
phpPHP_BINARYPHP binary path or command
hostlocalhostServer host
port8080Server host port
rootgetcwd()Document root. The location that will be the public root of your website.
autoindextrueDetermines if the server will list directory contents if it does not find an index file.
indexindex.html index.phpThe names of the index files separated by spaces.
error_reportingE_ALLSets thelevel of errors that will be reported.

Sections

SectionDescription
iniUsed to set customphp.ini directives.
serverUsed to set customServer and execution environment information.

Knowing this, just create (if necessary) a php-server.ini file, run the server and you're done.

Run

As you can see in theconfig. You can create a php-server.ini file to leave the settings of each project already pre-established.

But, you can also simply runphp-server and the server will already be available athttp://localhost:8080.

The php-server command can receive some parameters and they are:

ParameterDescription
--phpPHP binary path or command
--hostServer host
--portServer host port
--rootDocument root

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 php8.4 --port 8081

Right. You get the idea. If you want to run on a different host you can add the host to thehosts 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 anissue and if you have solved the problem feel free to open aPull Request.


[8]ページ先頭

©2009-2025 Movatter.jp