On PHPMaster.com today there's a new tutorial for those on the bleeding edge of PHP using the latest released version (5.4) and a feature that comes with it - using the built-in webserver that comes bundled for testing purposes.
One of the cooler features of the new PHP 5.4 release is a built-in web server designed specifically for development and testing. Now you can write and test your code without having to have a full-fledged LAMP configuration - just launch a the built-in server from the command line, test your code, and then shut it down when you're finished. [...] In this article I'll explain some basic uses of the new built-in server and show you how to build a portable personal development server useful for quickly testing your applications
He starts with a look at how to start up the web server (a simple command line switch and host/port definition) and the resulting default phpinfo page it displays. Other options include the ability to specify a document root for your server and create a sort of "front controller" for it to route requests. They show how to create a simple application based on this that can dynamically load in the index file, a router and pass the request off to the correct file. Their example includes some "niceties" too like logging, "hosts allowed" and checks for requesting directories.
You can find their full code for this example over on github.
没有评论:
发表评论