PHP 5.4 Officially released
PHP 5.4 was officially released as a stable version. There are some new features on this PHP version, but maybe the surprisingly one is: it comes with a built-in web server for development purposes.
What’s new on PHP 5.4 (Key Features) :
- Shortened Array Syntax
- Built-in web server for development purposes
What are Traits ?
“Traits is a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.”
“A Trait is similar to a class, but only intended to group functionality in a fine-grained and consistent way.”
More indeep details on http://pt2.php.net/manual/en/language.oop5.traits.php
Built-in Web Server
PHP.net states that is for development purposes only, as is not ready for production, anyway i believe that will shorten the complexity of setting up any other web server when you are getting into the language. Makes it extremely easy to start and test code on the browser.
The server has a limited number of options:
- URI requests are server from the directory where the server was started, unless you use the -t option to explicitly define the document root
- If URI request doesn’t find the file requested on the document root, the server will return index.php or index.html, if they exist, 404 otherwise
- When server is started you can define a file, that will be used as router for the webserver. All requests will be deliver to it.
Web server syntax: php -S localhost:8000 -t /var/local/www router.php
Lorna did a more complete post on this, if you’r curious just go on and read it. PHP 5.4 Built In Webserver