In an already familiar format, here’s more PHP news you may have missed over the past month or so. As usual, let me know if I’ve missed anything!
Drupal 8 – beta 1
The long awaited version 8 of Drupal has finally been released – albeit in beta format. You can now take it for a spin and test drive some of its newest features.
Guzzle 5 and Ring PHP
“If you liked it then you shoulda put a ring on it”
Seriously though, Guzzle 5 is already out. How crazy is that? It wasn’t that long ago that we were still being introduced to it, and here it already boasts version 5 and async requests.
RingPHP will be the new handler system in Guzzle 5 (release date TBD). RingPHP gives Guzzle the ability to send asynchronous requests, greatly reduces the complexity of creating new handlers, and yields much simpler and more explicit request state transitions in Guzzle.
RingPHP is heavily influenced by Clojure, Clojure’s Ring, and Clojure’s HTTP Kit, and as such, it utilizes various functional programming concepts and uses PHP associative arrays as the main data structure. The use of functional composition and simple associative arrays allows RingPHP to be easy to understand, fast, and simple to add behavior to at runtime via middleware.
You can read the rest here if you’re interested, but in a nutshell, Guzzle can now do async requests, while breaking little to no compatibility with version 4. Users of the old API shouldn’t notice any difference, except for huge performance increases due to non blocking redirects and all the other magic the post I linked above talks about.
In general PHP world, things are gaining traction. Among the most interesting are:
We now have an “isset ternary” (see here) which rids us of code like this:
$a = isset($_GET['mykey']) ? $_GET['mykey'] : ""
…and lets us write the same thing like this:
$a = $_GET['mykey'] ?? ""
Alternative Tag Removal
Alternative tags like
"ASP tags (<%) and script tags (<script language=php>) as a means of entering or leaving PHP mode” have been voted out of PHP – in the next version, they will no longer be supported. I personally never even knew about the script tag, and am glad it’s gone, even if all the sites that use it will suddenly have all their PHP code exposed if they update the PHP major version without updating their code alongside it. We can’t keep holding ourselves back to accommodate an incompetent few, and if completely destroying their applications is what it takes for them to get a move-on, so be it.
See the RFC here.
What surprised me in this vote is that more than zero people voted no. I can’t imagine why someone would vote no, save for the reason I stated above.
PSR 6 and 7
Note: Section edited as per Matthew’s clarification below
Two PSRs not many people are familiar with are in the process of being redefined and edited by the PHP-FIG, each very important for further standardization of popular packages and libraries.
PSR 6 focuses on Caching and defining a common interface for it. The beginning of the meta document says it all:
Caching is a common way to improve the performance of any project, making caching libraries one of the most common features of many frameworks and libraries. This has lead to a situation where many libraries roll their own caching libraries, with various levels of functionality. These differences are causing developers to have to learn multiple systems which may or may not provide the functionality they need. In addition, the developers of caching libraries themselves face a choice between only supporting a limited number of frameworks or creating a large number of adapter classes.
PSR 7 will implement a common HTTP message interface. The group is “[…] adding an IncomingRequestInterface, that extends the RequestInterface, for describing access to common incoming data sources (e.g., query string arguments, cookies, upload file metadata, etc.). The goal is to make the IncomingRequest/Response pair ubiquitous, and the target for MVC and middleware frameworks (instead of custom, per-project or per-framework implementations); this will promote writing code that can be shared between different frameworks. Read more here.
Anthony Ferrara had something interesting to say about both of these – namely, why he disagrees with their current state. You can read his thoughts here.
You might be wondering what happened to PSR 5. PSR 5 is a PhpDoc standard proposed by the PhpDocumentor team, though due to the chaotic nature of the Google Group the PHP-FIG uses and the generally fragmented approach to discussing PSRs, I wasn’t able to discern its current status or when it’s about to be implemented, if at all. If you’d like to look into this standardization of Docblocks, see here.
PHP 7 Timetable
Finally, the internals team has decided on a vague timetable for PHP 7’s release – it’s planned for November of 2015. Let’s see if they can hit that deadline!
PHP 7 timetable: https://wiki.php.net/rfc/php7timeline
HHVM in Laravel Homestead
Laravel’s Homestead has been upgraded slightly again. The box itself has been improved to contain HHVM pre-installed at version 3.3.0 (long term support), and to have Xdebug’s remote debugging active by default. The files of the Homestead repo have been updated as well to allow for HHVM’s activation.
Naturally, this also means I’ve synced Homestead Improved with its upstream, absorbing all of the original Homestead’s changes, but keeping things as simple and efficient as you’re used to them being.
To activate HHVM in Homestead or Homestead Improved, see the original official documentation.
Symfony2 – DX++
Symfony2 has been bending over backwards to make itself more approachable to developers over the past few months. This developer experience upgrade has not only made working with the framework far more pleasing, but also converted several skeptics to believe in the usefulness and efficiency of the framework.
For example, a smarter assets:install command will now make sure that it hard-copies files instead of symlinking on systems that don’t support symlinks – all by default. No more symlink installation problems like those encountered here. New shortcut methods have been added to controllers, the debug toolbar will be able to debug Ajax requests and much, much more.
You can find all the new release updates here, described in detail with code demos.
Last but not least, there’s an official (and free) Symfony2 best practices book – grab it here!
Composer – Virtual Packages and Proper Requires
Three very interesting posts showed up over the web regarding composer. The first one taught us about virtual packages and the
provides keyword in packages. The second one is a response to the first post and corrects it somewhat, explaining matters into a bit more depth.
Finally, the third post is an excellent guide through properly requiring your packages.
AuraPHP 2 – Stable!
The Aura Di and Aura Web packages have gone stable, which allowed the maintainers to upgrade all the other Aura packages to 2.0 stable as well, thus pushing the entire project into 2.0 waters. This big milestone means that not only the components have a new major version, but automatically all frameworks using them (Aura aims for a components first, frameworks second approach).
The Themosis project has also rebranded itself into an agency specializing in WP development and has reserved the framework.themosis.com subdomain as the home for the framework by itself. Read about the changes on their home page, and let us know if you’ve used Themosis for anything – we’d love to publish your work.
Speaking of new releases – Yii 2 is finally available and out of beta. We’ve discussed the advantages the new version brings in a previous post and have revisited the topic recently, listing 7 reasons for choosing Yii 2 for your next project. If you’ve built anything with Yii and would like to showcase it, or are just interested in tutorializing it and spreading the word, get in touch!
Phalcon 2 beta 3
The Phalcon framework has reached beta 3 status. Word is, this might be the last beta release before general availability, as all tests are now passing in full and API parity has been achieved. If you haven’t given Phalcon 2 a try yet, make sure you take it for a spin. For a really quick setup, see our quick tip on getting it up and running in no time.
A productive month in the PHP world, no doubt! Did I miss anything? Let me know in the comments below, and let’s discuss it there! If you have any tips for the next News post (due in about a month, give or take), just shoot me an email and I’ll decide whether or not it lacks exposure enough to be included in a list of news people may have missed. Thanks for reading!
The Principles of Beautiful Web Design, 4th Edition
Docker for Web Developers
Learn PHP in One Day and Learn It Well