![]() ![]() This makes the web server compatible with any PHP web framework (Laravel, Symfony, etc.) that take advantage of URL re-writes to route all the requests through a single index.php and eventually invoke different routes and controllers internally. This makes the in-built PHP web server similar to the rewrite modules of other servers like Apache and Nginx. If page.php does not return false for a request then any output produced by itself be returned to the client (browser).If page.php returns false for a particular HTTP request, then the requested resource (file) will be processed and served.Now regardless of whatever URL that you visit – /foo, /foo/bar.php, /baz.php, /style.css, etc. An example: $ php -S localhost:8080 page.php While passing a specific file to the web server, it is super important to note that the file will be treated as a “router” script in such cases. Eventually an HTTP 404 Not Found will be thrown if the files aren’t found. If none of them are found, the parent directories will be looked up for those files until the document root is reached. Whenever the document root ( or a folder ( is accessed via an HTTP request, the web server will look for an index.php or index.html file in the respective file system folder. PHP 7.2.24-0ubuntu0.18.04.10 Development Server started at Sat Feb 5 09:55:51 2022ĭocument root is /home/user/pub # docroot If no document root is specified, the current working directory is served. You can always go through the different options by reading up on man php but as far as serving local files and folders are concerned all we need to know is that pass your desired host ( addr) and port to -S and if you want, you can specify the document root with the -t option. The syntax of the command looks like this: $ php -S addr:port $ php -S localhost:8080 specific-file.php The PHP CLI language interpreter ships with a built-in web server that can be fired up like this: # Serve index.php or index.html from the current working directory You can use the built-in PHP web server to quickly serve PHP and other static files (HTML, CSS, images, videos, fonts, etc.) from your current working directory or any other path in your local file system. Traditionally we’d install and configure web servers like Apache or Nginx but if you’re working on a PHP app or a static website and already have PHP installed in your system, you wouldn’t need to go the traditional route. ![]() We do this by serving the local source code via a HTTP web server and then visiting in our browser to see the results. The most basic requirement while working on websites and web apps is the ability to see our results in a web browser. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |