PHP
Article

PHP News You May Have Missed – September, October 2014

By Bruno Skvorc

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.

For a full release post see here, and to find out how you can quickly and easily get an instance of your own up and running, see our quick tip.

Guzzle 5 and Ring PHP

If you liked it then you shoulda put a ring on it
      – Jesus

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.

Long story short, after having gotten many a request for async support in Guzzle, the prolific Michael Dowling created Ring PHP, a new driver behind Guzzle 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.

PHP Updates

In general PHP world, things are gaining traction. Among the most interesting are:

Isset Ternary

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).

For the full report on this progress, see Paul Jones’ post here and for a quickstart with Aura 2, see Hari’s tutorial.

Themosis 1.0

Themosis, the framework for WordPress we’ve already written about has reached version 1.0. For an in depth look, stay tuned – tutorials are coming soon.

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.

Yii 2

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.

Conclusion

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!

More:
  • http://www.mrgeek.me/ Ali Gajani

    Sweet!

  • http://mwop.net/ Matthew Weier O’Phinney

    I’m writing to clarify your statements on the new proposals from the framework interop group (PHP-FIG).

    Neither PSR-6 nor PSR-7 are new; both have been in progress for literally years.

    PSR-7 has had a spate of new activity recently, however, as I have taken over as Editor to push it to completion. Its goals have also changed; it’s not targeted primarily at clients, as you claim in your recap, but at both client and server-side applications. To the latter, we are 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.

    PSR-6 has had new activity in the form of several people questioning design decisions long since argued, and re-opening those arguments. No changes have been made to it in the past month, however.

    • http://www.bitfalls.com/ Bruno Skvorc

      Guess the influx of activity to both PSRs had me tricked, thanks for clarifying! I’ll amend the post immediately!

  • http://www.niden.net Nikolaos Dimopoulos

    One more thing that did not make it in the news.

    Phalcon 2.0 beta 3 has been released this morning. For more information you can check our blog post:

    http://blog.phalconphp.com/post/100083107700/phalcon-2-beta-3-released

  • sydnerdrage

    Excellent write up! Thanks for sharing. It’s almost impossible to know everything that goes on unless you stick to reddit and twitter 24/7 so articles like this are perfect for catching up on everything that I’ve missed!

    However I think it’s really important to emphasise that the isset ternary and the removal of the alternative tags are not in a stable release of PHP. You mention very briefly that the tag removal is in the ‘next release’ but isset ternary reads as if it is… If only! Perhaps grouping this in your next PHP post as ‘whats coming in PHP’ would be the best way to highlight this – it could even include notes on frameworks (e.g. whats happening with ZF2/3 and the discussion around that at the moment).

    • http://www.bitfalls.com/ Bruno Skvorc

      I’ll try and be more specific in the future, thanks for the feedback!

  • Bruno Seixas

    really enjoy these posts =) Thanks a ton!
    The Symfony 2 ebook arrives in a very handy time!

    • http://www.bitfalls.com/ Bruno Skvorc

      Agreed, I’ll be retrofitting all my code to it as soon as the new version is out. Glad you liked the writeup!

  • http://www.bitfalls.com/ Bruno Skvorc

    Added!

  • http://vanilladevs.com/ Eugene Chechel

    This $a = $_GET[‘mykey’] ?? “” is awesome!!!

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in PHP, once a week, for free.