The digest of interesting news and materials from the world of PHP for the last two weeks No. 11 (02/12/2013 - 02/25/2013)

We bring to your attention the next selection with links to news and materials.
Enjoy reading!
News and Releases
- Zend Optimizer + open source - In a previous release, Zeev Surasky’s statement about the possible inclusion of Zend Optimizer + in the PHP 5.5 kernel was mentioned. Given that the vote on this issue has not yet begun, and alpha 5 has already been released, and the first beta version 5.5 is planned for March 7 , then probably Zend Optimizer + will not be included in the next version. But I cannot but rejoice that the tool code is already open and accessible to everyone! The project repository is here , there is also an assembly instruction.
- PHP 5.4.12 and PHP 5.3.22 came out - Regular updates and, as always, inside a bunch of fixed bugs .
- PHP 5.5.0alpha5 - Unscheduled alpha release, which, in addition to bug fixes, contains small innovations in the MySQLi and Mysqlnd APIs and several others. Full list of changes here .
- Zend releases Zend Studio 10 - In the new version of the IDE, as previously announced , emphasis has been placed on the development of a backend for mobile applications and integration with cloud services.
- Bolt 1.0 release - After six months of work, the first stable version of CMS, based on the Silex framework and Symfony components, is finally released.
Php
- Why objects (usually) usually use less memory than arrays in PHP - 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 more than an array of properties + some additional information. But the fact is that in most cases PHP optimizes the massive component of an object. Read more about how this works in the post. It is worth noting that the writing is relevant only for PHP> = 5.4.
- RFC: Comma at the end of the function argument list - The list of array elements in PHP can be completed with a comma: array ('Foo', 'Bar',); which is certainly very convenient. This RFC proposes to add the ability to complete the argument list of a function 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 you to cache the state of the application between starts (requests). In general, something similar to APC or Zend Optimizer + but for caching objects and data, not an opcode. Interesting, but hardly ever will be .
- Mystical PHP RFC process, and how you can change the Web - For everyone who is interested in how new features get into PHP, the author wrote a wonderful post in which he talks about the RFC process, making it more transparent for ordinary developers. The author gives a lot of useful tips and advice for those who want to participate in the development of the language and who have something to offer.
Learning Materials
- Bottleneck Analysis (PDF) - Slides of the report from the core PHP developer Ilya Alshanetsky from the largest PHP conference recently held in London - PHPUK 2013.
- Closures, lambda expressions, and anonymous functions - These concepts are often used interchangeably in PHP, but is this correct? In a post, the author answers the question of what is the difference between lambda expressions, anonymous functions and closures, and also 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 determine the overall structure of JSON resources. The second part discusses 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 . In both articles, ZF2 will not be affected, 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 a wrapper class.
- Do not use PHP libraries with known problems - A great initiative from SensioLabs, thanks to which any developer using Composer for dependency management can automatically find potential security problems with security.sensiolabs.org . Users can upload their composer.lock file, and the system will check for known problems and report. In addition, there is an API in case you want to automate verification. The vulnerability database is uploaded to GitHub , and anyone can help to replenish it by simply making the appropriate pull-request.
- PHP and Composer Dependency Security - Some more security recommendations for dependencies managed by Composer.
- Preventing CSRF Attacks - This post, which deals with generating secure CSRF tokens, has generated a wave of community discussions. The author has proposed a method for generating less predictable, and therefore safer, values. A closer look at the problem and CSRF as a whole, has done in his post, Anthony Ferrara.
- Testing models in Laravel - A great detailed tutorial on organizing unit testing in Laravel 4 .
- We simplify the generation of test data using Faker - In one of the previous releases we mentioned the useful Faker library, designed to generate data very similar to real ones. This time we have a good tutorial with examples on using this library.
- Interview with the creator of PPI - PHP meta-framework - PPI is a PHP framework that has absorbed all the best from Zend Framework 2, Symfony2 and Doctrine2. In an interview, the author of the framework 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 use the Vagrant (CLI for VirtualBox) to set up a fully ready-to-use staging environment. The author maximally approximates the configuration to Fortrabbit, however, by analogy, it is easy to adjust the configuration of the desired environment for any other PaaS / hosting.
- About creating user groups - An article that was previously published in the journal php | architect. The author shares recommendations on creating user groups: search for local developers interested in meetings; dissemination of information through companies using PHP; search for sponsors and partners and others.
- External Processes and PHP - A small tutorial that talks about starting and using external processes using threads.
- Extract an excerpt from a WAV file - The article gives an overview of the WAV format and structure of the WAV file, and then demonstrates the use of the author of the Audero Wav Extractor library to cut excerpts from a WAV file.
- Views in Lithium using layouts - A small tutorial on the outgoing CakePHP framework.
- XML Parsing with SimpleXML - A simple and detailed tutorial for those who have not yet encountered XML parsing in PHP.
- PHP streams for everything - Another small tutorial that shows how to work with data streams in PHP.
- Scaling Silex Applications - A small post on how you can use YAML to configure routing. The author gives the extension code (SilexRouteExtension) and gives examples of its use.
- My love and hate for traits in PHP - Only lazy ones did not write about traits 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 - This post talks about what “middleware” is and how the PHP Slim microframework can be used as a layer in the middleware stack. An example is the implementation of the cache 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 source and setting up nginx server to use different versions on different virtual hosts.
- Programming with Anthony - Design Patterns - Continuation of a series of training videos from the famous figure in the PHP scene - Anthony Ferrara. This time, it’s not Anthony himself who reveals the topic, but Larry Garfield, one of the authors of Drupal 7 Module Development . All videos from the series are here .
- API Authentication: HMAC with Public / Private Keys - This article describes how to validate API requests using public / private key pairs.
- How we use Yii , Yii 2.0 - More recently, the Ural Conference of Web Developers was held in Chelyabinsk. The links slide 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.
- HOWTO: One possible implementation of the Model (MVC) in the Zend Framework is Habrapost, which describes how to organize the application architecture on Zend Framework 1.
- Interfaces or abstract classes? - If you doubt which of the OOP tools to choose: an interface or an abstract class for solving a specific problem, then you will be interested in this post in which the author writes about the advantages of each and gives recommendations for selection.
- PHP class wrapper for simply building call chains - In a post, the author shows a simple method for creating a wrapper for an existing class that implements the possibility of building call chains a la jQuery.
- Do not abuse dependency injection - In a short post, the author illustrates how excessive use of dependency injection can significantly degrade code.
- Avoid the original MySQL extension , 2 - It is no secret that the original MySQL extension for PHP is hopelessly outdated and, nevertheless, very often used. This two-part article first describes what is actually wrong with the MySQL extension, and then explores alternatives: MySQli and PDO.
- PHP5.5: Try / Catch / Finally - Since PHP 5.5, finally support has finally been added to the try / catch block for exception handling. In this short article, the author demonstrates examples of using the new feature and experimentes a bit. For example, even if return is encountered in try / catch, the finally block still succeeds.
- 6 reasons why PHP - the hobbit - Not so long ago, a question popped up on Quora: If there was a war between programming languages, who would you hold and why? . In one answer, each language was seen as a race / hero from The Lord of the Rings. In the original answer, PHP is an orc: “Ugly guy. Does not respect the rules. A headache for the 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 cites its arguments.
- Full encoding standard in PHP - If you absolutely do not like the accepted PSR-0,1,2 standards , then pay attention to this "standard" - it is beautiful.
Link to the previous issue.
Material prepared by pronskiy