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

Phil Sturgeon:
PHP-FIG: 3.0 or Rebrand
Aug 31, 2016 @ 10:38:01

Phil Sturgeon has a new post to his site giving a brief overview of the state of the PHP-FIG, the v3.0 proposal that's been put out and sharing some of his own thoughts on both.

I was involved in the PHP-FIG since 2012, and I have seen every conversation, been part of every decision, and know the reasoning for a lot of stuff, regardless of the result and my person preferences. Being so involved with this group for so long, I have a fair bit of context that other people are lacking.

The latest of about four large conversations in the FIG is: whether or not a new organization should take its place. Seeing it framed in this way is odd, because I'm not sure anyone is literally proposing that.

Phil covers some of the background behind the PHP-FIG group including some of the original goals and how it grew well beyond the "framework" part of its name. He talks about some of the reasons he sees that the group has stayed around. Then he gets into the FIG v3.0 proposal - a relaunch of the group with a different structure and different way of getting things done (after learning from some of the mistakes in the current group). He also talks about the other elephant (elePHPant?) in the room: whether this new structure calls for a new group to be formed or if the PHP-FIG should just adapt and move on.

It will be interesting to see how this all shakes out in the end but the PHP-FIG group has, undoubtedly, helped to usher in a lot of the "modern PHP" work we see in the community now especially when it comes to things like Composer, logger structure and middleware handling.

tagged: phpfig v3 proposal organization structure framework psr

Link: https://philsturgeon.uk/php/2016/08/30/php-fig-3-0-or-rebrand/

Laravel News:
Laravel 5.3 is now released
Aug 23, 2016 @ 10:52:24

As is mentioned in this new post on the Laravel News site, the latest version of the Laravel framework (v5.3) has officially been released:

The Laravel team is proud to announce the release of Laravel 5.3 and it’s now available for everyone. The new features in 5.3 are focused on improving developer speed by adding additional out of the box improvements for common tasks.

This is a general release and comes with six months of bug fixes and security fixes are provided for one year. Laravel 5.1 is the latest LTS release which includes bug fixes for two years and security fixes for three years.

The post also lists some of the major updates that come with the v5.3 release including:

  • New Home Page (for the project)
  • New packages like Laravel Passport, Laravel Scout and Laravel Echo
  • Updated migration handling
  • Queued job improvements

You can read the full list of changes in the rest of the post including a link to an upgrade guide for those migrating from previous versions.

tagged: laravel version release v53 framework update feature project

Link: https://laravel-news.com/2016/08/laravel-5-3-is-now-released/

Chema Garrido:
Speed test PHP vs Lumen vs Laravel
Aug 18, 2016 @ 12:08:53

Chema Garrido has written up a post sharing some results of a performance test (speed) between Lumen and Laravel also comparing it against Kohana and straight PHP.

I am working in the new EmailValidator!, and after developing the EU VAT API, I feel confident to develop it on Laravel Framework. But before we start… let’s test the speed of the stack.

I used my local computer a 8 cores i7 2ghz 8GB ram 512SSD. Apache2, PHP 7.0.8. Tested this test with siege 5 times for each and retrieved the highest.

The first part of the post shows the results in a tabular format but following this is the more detailed version, complete with the siege command executed and the code used. The results are interesting but seem to mostly fall into the real of micro-optimization as there's really not that much difference between the results (though the "Longest transaction" on the plain PHP code is an oddity).

tagged: laravel lumen performance speed test results framework

Link: https://chema.ga/speed-test-php-vs-lumen-vs-laravel/

In2it:
Decouple Your Framework for Easy Replacement
Aug 12, 2016 @ 11:14:12

In this recent post to the In2it blog Michelangelo van Dam makes a recommendation to decouple your logic from your framework to make it easier in the future if you need to replace it.

Decouple your framework or library from your business logic for future upgrades or replacements through usage of interfaces. By separating your business logic completely from the tool used to glue all things together, you can replace your framework or upgrade to a newer version without much problems.

He talks about how it's common for applications to quickly become "good application turns into a cluster of code on top of a cluster of code". While the title suggests completely swapping out the underlying framework, he shifts it to talk more about updates to the current framework, especially ones that would break non-decoupled functionality. He then covers the ideals of "interoperability" between PHP packages based on common interfaces (like the PSRs) and how following a similar idea can help decouple your code to prevent hard work for future potentially breaking changes.

tagged: framework replacement changes interoperability dependencyinjection example

Link: https://www.in2it.be/2016/08/decouple-framework-library-easy-replacement/

Robert Basic:
Events in a Zend Expressive application
Aug 05, 2016 @ 09:40:47

Robert Basic has written up a new post sharing a method he came up with for event handling in a Zend Expressive application. He makes use of Zend's own EventManager component to integrate it with some of his work from a previous post.

Three weeks ago I wrote a post on how to utilize Tactician in a Zend Expressive application. Today I want to expand on that post a little by adding the possibility to trigger and listen to events using the Zend EventManager component.

Using events allows our application to respond to different events that occur during a request.[...] This allows for a better separation of concerns in some cases, because if we take this approach, our code that deals with [the current functionality] doesn’t care any more what happens after that

He then gets into the code, showing how to install the EventManager component and how to create/inject an event manager into a current object (a Command). He then shows how to attach en event to the handler and perform an action when the event is hit. He points out one issue with this kind of setup, however: the need for all dependencies to be created prior to the event being attached. Fortunately the Zend EventManager comes with DI container support making it simpler to access dependencies needed during the firing of the event.

tagged: zendexpressive framework application event eventmanager tutorial overview introduction

Link: https://robertbasic.com/blog/events-in-a-zend-expressive-application/

Master Zend Framework:
Can You Create Apps in Zend Expressive as Easily as With Laravel?
Jul 27, 2016 @ 13:23:01

On the Master Zend Framework site Matthew Setter has written up a post that tries to answer the question: "can you create Zend Expressive apps as easily as with Laravel?" He works through each of the major features in the frameworks (controllers, routing, views, etc) and compares the two and how easy they make it for the developer.

Laravel is the PHP framework For web Artisans, able to create applications nary with the speed of thought. Zend Framework, on the other hand, is the enterprise-ready framework; one that can build the largest of applications, for companies in the Fortune 500. I was asked, recently, if applications could be built as easily in Zend Expressive as in Laravel. Recently I sought to find out. Here's what I found.

He starts off with more of an "overview comparison" of his own experience building a simple application with Laravel and how, interestingly, there's not an easy way to make a direct comparison between the two. He also mentions picking the right tool for the job and not "fitting a square peg in a round hole" or trying to use the same development practices between the two. From there he then gets into more of the specifics of the features:

  • Forms and Entities (and Form ViewHelpers)
  • Routes and Controllers
  • View Helpers
  • Database Access
  • Data Models
  • Database Migrations and Testing
  • Testing

Each of the sections comes with some brief code snippets and examples from either side of the fence, helping you get a better idea of how they differ. He finishes off the post sharing his own opinions on the comparison between the two....but you'll have to read the article to find out about those.

tagged: laravel zendexpressive framework comparison features easy

Link: http://www.masterzendframework.com/zend-expressive-or-laravel/

Matt Stauffer:
Customizing pagination templates in Laravel 5.3
Jul 27, 2016 @ 12:33:36

Matt Stauffer is back with another in his series of posts about the new features coming in the v5.3 release of the popular Laravel framework. In the latest post he looks at pagination improvements allowing you to customize the related templates.

Laravel's pagination library is brilliant, because pagination is a common task that is a surprising amount of work to implement. In the past, if you wanted to customize your pagination templates, it was just as simple to customize your pagination template as it was to work with the rest of the pagination library.

However, for the sake of making the pagination library easier to extract for non-Laravel projects, Laravel 5.0 (or maybe even earlier?) introduced a much more complex—but more portable—system for pagination templates. Thankfully, in Laravel 5.3, we're going to go back to how it always was: simple and easy.

He then gets into the basics of how pagination works in Laravel applications (not the template part, the backend) using the Task::paginate handling. He includes the view to just show the results and the current view handling for the pagination links. Finally he shows how to customize the template in v5.3 by registering a custom view to the partials.paginator and using the links method to inject them into your current template.

tagged: laravel template pagination customize tutorial series v53 framework

Link: https://mattstauffer.co/blog/customizing-pagination-templates-in-laravel-5-3

Alejandro Celaya:
Project Scalability with Zend Expressive
Jul 21, 2016 @ 09:46:10

In a new post to his site (also posted on the Zend Developer Zone) Alejandro Celaya looks at scalability with Zend Expressive, a lightweight framework from Zend, the creators of the Zend Framework.

I've been working with some different frameworks lately. One of them is Zend Expressive, and I've come to the conclusion that I don't need to choose between different frameworks; depending on the project, Expressive always fits my needs and scales from small projects to bigger applications.

He starts off by looking at the "microframework approach" that Zend Expressive takes, making it easier to get up and running for smaller applications. He points out that this setup is fine when the application is small, but what happens as it grows - it just wouldn't scale well and be manageable. He talks about the setup he uses for larger scale applications, moving the configuration to dynamic config files and making use of more complex dependency injection. He also talks some about modularity in applications, the "middleware paradigm" and how he set up controller-style dispatching (versus just the default closures method).

tagged: zendexpressive tutorial scalability framework microframework update functionality

Link: http://blog.alejandrocelaya.com/2016/07/21/project-scalability-with-zend-expressive/

TutsPlus.com:
How to Program With Yii2: Uploading Files
Jul 15, 2016 @ 12:15:45

On the TutsPlus.com site there's a new installment in their "How to Program With Yii2 Series" looking at implementing file uploads with some simple examples.

In this How to Program With Yii2 series, I'm guiding readers in use of the Yii2 Framework for PHP. In this tutorial, I'll guide you through the basics of uploading files and images in Yii2.

For these examples, we'll continue to imagine we're building a framework for posting simple status updates, e.g. our own mini-Twitter. The image above demonstrates writing a short update while uploading a picture I took of the Taj Mahal.

They start with a look at some of the file upload plugins that seemed like the best they found to use with Yii2: FileInput and the 2Amigos BlueImp File Uploader. They go with the first option for the rest of the tutorial, showing you how to get it installed (via Composer), updating your current database tables and changing the model to reflect these updates. Next they help you create the view with the image upload form and one to display the image result once the upload is successful (including the controller code needed).

tagged: yii2 framework series tutorial upload files plugin

Link: http://code.tutsplus.com/tutorials/how-to-program-with-yii2-uploading-files--cms-23511

Robert Basic:
Using Tactician in a Zend Expressive application
Jul 14, 2016 @ 10:41:10

In this recent post to his site Robert Basic shares some of his experience integrating the Tactician command bus library into a Zend Expressive-based application.

I spent some time connecting the dots last week, so I decided to put together an example on how to get started with using Tactician in a Zend Expressive application. The example itself is not really useful, but it does show how to setup the dependencies and get started with these two libraries.

He briefly introduces the two pieces of technology here and then "dives in" immediately to the integration. He shows how, using the Zend Expressive skeleton application, to expand on the default "ping" endpoint and add in the Tactician library (and another library that makes it easily integrate with the DI container). He updates how the "ping" action is made in the routing, making it go through a factory. He then brings Tactician in, setting up the command bus and a simple "ping" command for the bus to use in handling the requests to the /api/ping endpoint. Complete code and explanations of each part are included in the tutorial to help you follow along.

tagged: tactician commandbus zendexpressive command tutorial psr7 framework

Link: https://robertbasic.com/blog/using-tactician-in-a-zend-expressive-application/