Download the PHP package oscarotero/server without Composer
On this page you can find all versions of the php package oscarotero/server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oscarotero/server
More information about oscarotero/server
Files in oscarotero/server
Package server
Short Description Simple class to emulate Apache's 'mod_rewrite' functionality from the built-in PHP web server
License MIT
Homepage https://github.com/oscarotero/server
Informations about the package server
Server
Simple class to emulate Apache's "mod_rewrite" functionality from the built-in PHP web server. This provides a convenient way to test any web application without having installed a "real" web server software here. It works with any cms or framework.
Installation
This package is installable and autoloadable via Composer as oscarotero/server.
Usage
Create a server.php
file that will be our server script.
Launch the php server:
That's all, you could see the web in your browser in http://localhost:8000
.
Changing the public directory
By default, getcwd is used to get the base directory of the server. But it can be changed using the first argument. Example:
Execute php files
If the file has the php extension, the path is returned, so it can be included. This is only needed if the base directory is different that the current directory and the site does not have an unique php file (wordpress sites, for example).
API
As seen in the previous examples, the method Server::run()
can return three values:
true
Means that the file exists and can be served directly by the php serverstring
Means that the file exists but must be included (is a php file that cannot be server directly)false
Means that the file does not exists