Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News Podcast:
Episode 43 - Laracon US 2017 wrap, Laravel Horizon, and new versions galore
Aug 18, 2017 @ 12:42:34

The latest episode of the Laravel News podcast, hosted by Jacob Bennett and Michael Dyrynda, has posted their latest episode: Episode 43.

Jake and Michael return after a few weeks' hiatus to recap Laracon US 2017, the big reveal of Laravel Horizon, and catch up on the latest framework news.

You can read the full episode transcript which includes time markers and links.

The post also includes links to several of the topics and software mentioned in the episode. If you enjoy the show be sure to subscribe to their feed to get notifications when the latest episodes are released.

tagged: laravelnews laravel podcast ep43 laracon horizon versions

Link: https://laravel-news.com/podcast/43

Zend Framework Blog:
Protecting passwords with Argon2 in PHP 7.2
Aug 18, 2017 @ 11:12:01

On the Zend Framework blog today there's a new post from Enrico Zimuel showing you how you can use Argon2 password hashing in PHP applications (coming natively in PHP 7.2).

PHP 7.2 will be released later this year (2017). This version contains some interesting additions, including two new security features: support of the libsodium library.

With these new features, PHP is the first programming language to adopt modern cryptography in its standard library.

In this article, we demonstrate the usage of the Argon2 password hash algorithm.

He then walks you through the installation of the pre-release version of PHP 7.2 and the argon2 library to get the environment up and running. He briefly talks about what the Argon2 hashing algorithm is and how to use it directly in PHP via the password_hash function. He also mentions the password_get_info function and shows what the result of inspection on an Argon2 application contains.

tagged: password hash argon2 tutorial install usage

Link: https://framework.zend.com/blog/2017-08-17-php72-argon2-hash-password.html

Matt Stauffer:
Laravel Collections’ higher order messaging and “when” method in Laravel 5.4
Aug 18, 2017 @ 10:31:19

In this new post to his site Matt Stauffer looks at the "higher order messaging" in Laravel's collections as a part of his series covering features in Laravel 5.4.

It seems like it was just last year that collection pipelines took over the Laravel world. Taylor had introduced collections to Laravel a while back but they sat somewhat under-appreciated until Adam Wathan wrote his book Refactoring to Collections about how they can transform the way you write a lot of your PHP code.

In Laravel 5.4, collections got a few boosts. Let’s take a look at a few.

He starts by talking about the higher order messaging design pattern and how it is different than just using something like foreach to iterate through a set. He then applies this to the Laravel collections, showing how they're implemented there via the "filter" and "pipe" methods.

tagged: collection higher order when messaging tutorial laravel54

Link: https://mattstauffer.co/blog/laravel-collections-higher-order-messaging-and-when-method-in-laravel-5-4

Twilio Blog:
Creating a Symfony 3 Project with Basic User Handling
Aug 18, 2017 @ 09:56:26

On the Twilio blog they've posted a new tutorial from author Margaret Staples showing you how to create a Symfony 3 project with user handling along with the Friends of Symfony bundle.

User handling is a fundamental part of a ton of web projects. This post will walk through how to get setup using the Symfony 3 framework and the Friends of Symfony bundle so that your project can allow users to register, login and out, and view and edit their User profile. The steps here will serve as a great starting point for your next web project.

She then walks you through the installation of the Symfony standard edition and how to answer some of the interactive setup questions. Once that's set up she shows how to install the FriendsOfSymfony/FOSUserBundle and what configuration options need to be changed to implement it. She then shows how to update the database schema for the new user handling and how to check to be sure the login, registration and profile pages are working as expected.

tagged: symfony3 project user handling tutorial install configure migrate

Link: https://www.twilio.com/blog/2017/08/up-and-running-with-symfony-3.html


Omniceps.com:
Introduction to Latte | Best PHP templating engine
Aug 17, 2017 @ 11:30:15

On the Omniceps site there's a new post introducing you to Latte, the templating component of the Nette framework that can be used independently.

A PHP templating engine is the one which gives you ability to write html for your clients efficiently using PHP variables.

However, PHP was originally built to be a templating engine, but yet it was never used primarily as a templating engine. There has been so many PHP templating engine so far in the market since PHP evolved, but none of them has made as great impression on us as Latte. Introducing you to Latte, one of the best PHP templating engine you have come across so far. Also Latte protects your web app from vulnerabilities like XSS (cross site scripting).

The tutorial starts with an example comparing "plain old PHP" templating with the Latte version for a foreach loop. Next they show how to install the Latte component and the two different kinds of macros the tool includes. They also talk about filters, performance concerns, context aware escaping and "pretty output" options.

tagged: nette framework template component latte introduction tutorial

Link: http://www.omniceps.com/latte-best-php-templating-engine/

Amit Merchant:
Laravel Eager Loading - load() Vs. with()
Aug 17, 2017 @ 10:46:11

In a new post to his site Amit Merchant covers the difference between two functions in Laravel's Eloquent functionality that do similar things: load() versus with() for eager loading.

Today, while working with one of my projects(which is built on top Laravel) I bumped into the situation where I needed to get associated model’s data for one of the models. So here, I had two approaches in Laravel to accomplish this which are basically called Eager Loading: with() [and] load().

Both accomplish the same end results - eager loading a related model onto the first. In fact, they both run exactly the same two queries. The key difference is that with() eager loads the related model up front, immediately after the initial query (all(), first(), or find(x), for example); when using load(), you run the initial query first, and then eager load the relation at some later point.

He then goes through examples of each and the queries they produce on the backend. He shows how splitting up the queries might be a better option for some cases and finishes with the benefits of using each (use cases).

tagged: laravel eager loading load with eloquent

Link: https://www.amitmerchant.com/Laravel-Eager-Loading-Load-Vs-With/

PHP.net:
PHP 7.2.0 Beta 3 Released
Aug 17, 2017 @ 09:12:13

On the main PHP.net site they've posted the announcement of the release of the latest beta for PHP 7.2.0: PHP 7.2.0 beta 3:

The PHP development team announces the immediate availability of PHP 7.2.0 Beta 3. This release is the third and final beta for 7.2.0. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system.

This development only release includes mostly bugfixes (full list here) and can be downloaded from the usual QA sites: source and Windows binaries. This is the last beta release for PHP 7.2.0. The next release in the series will be PHP 7.2.0 RC1 on August 31st.

tagged: language release php72beta3 php72 development

Link: http://php.net/index.php#id2017-08-17-1


Pawel Mikolajczuk:
Custom Caching for Twig
Aug 16, 2017 @ 11:07:07

In this post to his Medium blog Pawel Mikolajczuk shares some helpful tips for getting the most performance out of your Twig output with some custom caching techniques.

In Superdesk Publisher we have implemented Mutlitenancy with possibility to have multiple themes (but one activated). To make process of switching, uploading and updating themes for tenant we had to came up with solution to clear cache only for one particular theme not the whole instance (with many organisations and tenants).

To achieve that we created custom Twig Cache class.

He then shares the code for the class, extending the base Twig filesystem caching, to work with the multi-tenant architecture. It ensures that the output from one account is completely separate from another, preventing concerns of the wrong data being shown to the wrong user. He also shows how to enable it in the application configuration (Symfony) and a custom "compiler pass" class to finish the integration.

tagged: twig custom cache class output multitenant architecture

Link: https://medium.com/@pawel.mikolajczuk/custom-caching-for-twig-f9a7303cebdd