The digest of interesting news and materials from the world of PHP over the past two weeks, №11 (02/12/2013 - 02/25/2013)
We bring to your attention another collection with links to news and materials.
Enjoy reading! ')
News and Releases
Open source code for Zend Optimizer + - In the last issue, Zeeva Suraski’s statement about the possible inclusion of Zend Optimizer + in the PHP 5.5 core was mentioned. Given that the voting on this issue has not yet begun, and 5 alpha has already been released, and the first beta version 5.5 is scheduled for March 7, Zend Optimizer + probably will not be included in the next version. But it can not but rejoice that the code of the tool is already open and accessible to everyone! The repository of the project is here , there is also an assembly instruction.
PHP 5.5.0alpha5 - Unplanned alpha release, which, in addition to bug fixes, contains minor innovations in the MySQLi API and Mysqlnd and a few others. Full list of changes here .
Release Bolt 1.0 - After six months of work, the first stable version of the CMS, based on the Silex framework and the symfony components, has finally been released.
Php
Why objects (usually) usually use less memory than arrays in PHP - A great post from the active core PHP developer, Nikita Popov. At first glance, it seems obvious that objects should occupy more memory, since an object is nothing but an array of properties + some additional information. But the fact is that PHP in most cases optimizes the massive component of the object. Read more about how it works, read the post. It is worth noting that what is written is only relevant for PHP> = 5.4.
RFC: Comma at the end of the function argument list - A list of array elements in PHP can be terminated with a comma: array ('Foo', 'Bar',); which is definitely very convenient. This RFC has proposed to add the ability to complete the list of function arguments with a comma by analogy with arrays: function ($ foo, $ bar,) {};
Stupid idea for PHP core? - The author of the post proposes to include in PHP some method that would allow caching the state of the application between launches (requests). In general, something similar to APC or Zend Optimizer + but for caching objects and data, not an opcode. Interesting, but this is unlikely to ever be .
Mystical PHP RFC process, and how you can change the Web - For anyone who is interested in how new features get into PHP, the author wrote a wonderful post that talks about the RFC process, making it more transparent for ordinary developers. The author gives a lot of useful tips and recommendations for those who want to participate in the development of the language and who have something to offer.
Study materials
Analysis of Bottlenecks (PDF) - Slides of the report from core PHP developer Ilya Alshanetsky from the largest PHP conference recently held in London - PHPUK 2013.
Closures, lambda expressions and anonymous functions - These concepts in PHP are often interchanged, but is this correct? In the post, the author answers the question, what is the difference between lambda expressions, anonymous functions and closures, as well as what are their features in PHP.
RESTful API on ZF2 , 2 - A series of articles on building RESTful interfaces in general and on Zend Framework 2, in particular. In the first post, the author writes about the basic principles of REST, the Richardson REST services maturity model , Hypertext Application Language, and how it can be used to define the overall structure of JSON resources. The second part deals with such an aspect of RESTful interfaces as error messages. The author writes that returning an error code is not enough and offers two possible solutions: vnd.error and API-Problem . Both articles will not affect ZF2, so they will be useful to everyone.
Getting rid of null in PHP - How often do you have to write something like if (null === $ obj) in your PHP code? Inspired by Scala and Google Guava, the author offers a more elegant solution using the wrapper class.
Don't use PHP libraries with known problems - A great initiative from SensioLabs, thanks to which any developer using Composer to manage dependencies has the ability to automatically find potential security problems with security.sensiolabs.org . Users can download their composer.lock file, and the system will check dependencies for known problems and issue a report. In addition, there is an API in case you want to automate the check. The base of vulnerabilities is posted on GitHub , and anyone can help in replenishing it by simply making the appropriate pull-request.
Preventing CSRF attacks - This post, which deals with the generation of safe CSRF tokens, has generated a wave of community discussions. The author proposed a method of generating less predictable, and therefore safer values. A more detailed look at the problem and the CSRF in general, made in his post Anthony Ferrara.
Simplify the generation of test data using Faker - In one of the previous releases mentioned useful library Faker, designed to generate data very similar to real. This time we have a nice tutorial with examples on how to use this library.
Interview with the creator of PPI - PHP meta-framework - PPI is a PHP framework that absorbed all the best from Zend Framework 2, Symfony2 and Doctrine2. In an interview, the framework author answers various questions, for example, why is PPI a meta-framework? and what does the meta-framework mean?
Setting up a staging environment - An excellent detailed tutorial that shows how to configure a fully ready to use staging environment using Vagrant (CLI for VirtualBox). The author maximizes the configuration to Fortrabbit, but by analogy it is easy to adjust the configuration of the desired environment for any other PaaS / hosting.
About creating user groups - Article that was previously published in the journal php | architect. The author shares recommendations for creating user groups: search for local developers interested in meetings; information dissemination through companies using PHP; search for sponsors and partners, and others.
External processes and PHP - A small tutorial in which it is a question of starting and using external processes with the help of threads.
Extract excerpt from a WAV file - The article provides an overview of the WAV format and the structure of the WAV file, followed by a demonstration of the use, written by the author of the Audero Wav Extractor library, for cutting out excerpts from the WAV file.
Scaling Silex applications - A small post about how you can use YAML to configure routing. The author lists the extension code (SilexRouteExtension) and gives examples of its use.
My love and hate for treit in PHP - Only lazy did not write about trait in PHP. And, nevertheless, another post in which the author writes not only about the good, but also about the negative aspects of the new opportunity.
We work with Slim Middleware - In a post it is told about what “middleware” is and how the PHP Slim mic framework can be used as a layer in the middleware stack. As an example, the implementation of the caching layer on Slim. More examples on github .
2 php on nginx server - A small note in which the author describes the process of compiling PHP versions 5.4 and 5.5 from the sources and configuring the nginx server to use different versions on different virtual hosts.
Programming with Anthony - Design Patterns - Continuing a series of instructional videos from a famous PHP scene figure - Anthony Ferrara. This time, the topic is not revealed by Anthony himself, but by Larry Garfield, one of the authors of Drupal 7 Module Development . All videos from the series here .
How we use Yii , Yii 2.0 - Most recently, the Ural conference of web developers took place in Chelyabinsk. The links slides reports from samdark .
24 cool PHP libraries that you should know about - A selection of good libraries for all occasions: routing, caching, ORM, benchmark, validation, filtering, payment processor, and many others.
Interfaces or abstract classes? - If you doubt which of the OOP tools to choose: an interface or an abstract class for solving a specific task, then you will be interested in this post, in which the author writes about the benefits of each and gives recommendations for choosing.
PHP class wrapper for simply building call chains - In the post, the author shows a simple method for creating a wrapper for an existing class that implements the ability to build call chains a la jQuery.
Do not abuse dependency injection - In a small post, the author shows by example how excessive use of dependency injection can significantly worsen the code.
Avoid the original MySQL extension , 2 - It's no secret that the original MySQL extension for PHP is hopelessly outdated and, nevertheless, very often used. In this two-part article, we first describe what is actually wrong with the MySQL extension, and then consider the alternatives: MySQli and PDO.
PHP5.5: Try / Catch / Finally - Starting with PHP 5.5, a finally / finally support was added to the try / catch block for exception handling. In this small article, the author demonstrates examples of the use of new features and experiments a little. For example, even if there is a return in try / catch, the finally block will still successfully execute.
6 reasons why PHP - the hobbit - Quora recently missed the question: If there was a war between programming languages, who would you hold and why? . In one of the answers, each language was viewed as a race / hero from Lord of the Rings. In the original answer, PHP is an orc: “An ugly guy. Does not respect the rules. A headache for many people who manage them. But dominate most of Middle-earth. Orcs team up with Saruman (C ++) to create something called HipHop. ” The author of the post believes that PHP is still a hobbit and gives its arguments.
Full standard coding for PHP - If you absolutely do not like the accepted standards PSR-0,1,2 , then pay attention to this "standard" - it is beautiful.
Link to the previous release. Material prepared by pronskiy