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

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

Loïc Faugeron:
Mars Rover, Event Sourcing package
Jul 27, 2016 @ 11:51:05

Loïc Faugeron has continued his "Mars Rover" series in his latest post today. This series, based on a set of specifications from a development challenge. In this latest post he continues looking at event sourcing and creates a package to handle the eventing to make it more flexible and robust.

In this series we're building the software of a Mars Rover, according to the following specifications. It will allow us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) Test Driven Development (TDD).

Up until now, we've implemented the first use case, "Landing a rover on Mars" [and] in the last article, we wrote some Event Sourcing code. [...] In this article, we're going to extract them from the navigation package and put them in their own event-sourcing package.

He starts by creating the package itself as a Composer package including the composer.json configuration and a few other files to have phpspec work correctly. He then adds the event-sourcing package to the main project and starts in on using phpspec to generate its basic files. He then updates the main Lander class to use this new package for events. There's no code in the eventing classes yet, but stay tuned for the next tutorial in the series that will update them and get it all working together.

tagged: mars rover tutorial series landing event sourcing package phpspec

Link: https://gnugat.github.io/2016/07/27/mars-rover-event-sourcing-package.html

Laravel News:
Laracon Live Blog Day 1
Jul 27, 2016 @ 10:10:33

For those that can't make it to this year's Laracon US event, the Laravel News site has started up a live stream for each of the days you can use to catch the latest from each session and announcement made at the conference. Today is the first day of the conference, so the Day 1 stream is already up and going strong.

Welcome to day one of Laracon US. Today features three workshop talks and we will be live blogging each one here.

There's no need to reload as the stream is a live update so keep it up and keep track of all of the Laracon-related happenings through out the day. For more information about the sessions being presented each day, check out the full schedule on the main conference website.

tagged: laraconus16 live blog laracon laravelnews

Link: https://laravel-news.com/2016/07/laracon-live-blog-day-1/

Voices of the ElePHPant:
Interview with Steve Grunwell
Jul 27, 2016 @ 09:47:48

The Voices of the ElePHPant podcast, hosted by PHP community member Cal Evans, has posted their latest interview with a member of the PHP community. In this latest show Cal talks with Steve Grunwell, a senior web engineer at 10up.

Cal and Steve talk about his presentation at this year's Sunshine PHP conference (2016) about "taking the web offline". Steve talks about the reasoning behind his group originally making an offline application and how it works. Steve also talks some about his background with WordPress and trying to get it to do "non-Wordpress-y things" in the past. They also commiserate over some of the client work they've each done in the past when they say "I just need....". They also talk about the WPEnforcer plugin he's created to enforce coding standards in a more automated way.

You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly. If you enjoy the interview and want to hear more, be sure to subscribe to their feed and follow them on Twitter to get updates as the latest shows are released.

tagged: voicesoftheelephpant community interview stevegrunwell podcast

Link: https://voicesoftheelephpant.com/2016/07/26/interview-steve-grunwell/

Community News:
Recent posts from PHP Quickfix (07.27.2016)
Jul 27, 2016 @ 08:05:02

Recent posts from the PHP Quickfix site:

tagged:

Link:

Laravel News:
Taylor Otwell - Community Experiences Contributing To Laravel
Jul 26, 2016 @ 13:28:34

On the Laravel News site there's a post sharing some of the results from a recent request for feedback from Taylor Otwell (creator of the Laravel framework) asking the Reddit community for their own experiences contributing to the Laravel project.

Taylor created a feedback thread on Reddit asking the community on why they do not contribute as well as asking for suggestions on how to manage issues.

Taylor said in the thread, “One thing that has been bothering me is I have seen a few people say they don’t contribute to Laravel because it seems like PRs get closed or shot down without much explanation. [...] Taylor continues, “My biggest challenge is the “Issues” tab on GitHub. It gets a lot of activity and its hard to filter out genuine issues from support requests, configuration problems, general questions, etc”.

Among the opinions shared in the responses were comments about how feedback was given by a certain member of the Laravel development team. Taylor has already said that processes have been put in motion to help make this situation better and move people to where they're most productive. The thread and shares a lot of other opinions besides just this, so if you're considering contributing it's worth a read.

tagged: community experience laravel taylorotwell contributing

Link: https://laravel-news.com/2016/07/taylor-otwell-askes-community-experience-contributing-laravel/

Peter Petermann:
Composer – What You Should Know
Jul 26, 2016 @ 12:56:21

Peter Petermann has shared a few of his thoughts about right and wrong things to do when using Composer in your PHP-based applications. He offers suggestions based on some of the more wide-spread (but wrong, in his opinion) practices he's seen in several projects.

Last year I wrote a piece called “a few thoughts about composer and how people use it“. In that post I had a list of things which are problematic about how composer is used. That post got widely recognized, linked an visited, but in general those issues still exist.

However lately I’ve had even more people asking questions (either on related forums, irc or even irl) about problems that stem from issue number 2: people are using composer as an installer (and sometimes Number 3 because of Number 2). In that Post I already gave a quick opinion on how workflows with composer should look like, In this post I’ll try to give a few more pointers on how to use composer without creating a mess.

He then breaks up the remainder of the post into various practices he's seen and calling out developers for doing including:

  • starting a project vs installing
  • globally installed composer packages
  • tagging and building

With each of his points he makes suggestions about what's wrong about the practice as well as some suggestions about how things could be done better.

tagged: composer opinion bad practices suggestion correct

Link: https://devedge.wordpress.com/2016/07/23/composer-what-you-should-know/

SitePoint PHP Blog:
Can We Have Static Types in PHP without PHP 7 or HHVM?
Jul 26, 2016 @ 11:34:57

On the SitePoint PHP blog Younes Rafie asks the question "Can we have static types in PHP without PHP 7 or HHVM?" One of the main features introduced by both of these versions (or platforms) is the ability to type things strictly and enforce more correct data handling. Previously PHP has been a "lazy typing" language and would regularly shift the type of a variable depending on the immediate need. Obviously, this can lead to unpredictable behavior.

Now that PHP 7 has been out for a while with interesting features like error handling, null coalescing operator, scalar type declarations, etc., we often hear the people still stuck with PHP 5 saying it has a weak typing system, and that things quickly become unpredictable.

Even though this is partially true, PHP allows you to keep control of your application when you know what you’re doing.

They show how, through a series of examples, to add a bit of additional validation with exceptions to ensure the input is the correct type. However this can be a bit more time consuming and difficult to remember so the team at Box put together the augmented types extension that brings some of the static typing to PHP 5.x. They help you get it installed and working in your PHP installation and include an example of it in use with DocBlock-based type hints. The extension provides handling for the basic types as well as arrays, multiple arguments, default values and return types.

tagged: static types php7 hhvm extension augmented types tutorial

Link: https://www.sitepoint.com/can-we-have-static-types-in-php-without-php-7-or-hhvm/

Joseph Silber:
The new Closure::fromCallable() in PHP 7.1
Jul 26, 2016 @ 10:20:47

In a new post to his site Joseph Silber looks at a new feature that will be coming with the next release in the PHP 7.x series - PHP 7.1 - the ability to convert a callable type into an actual Closure instance.

With PHP 5.5 going EOL earlier this week and the PHP 7.1 beta expected later this month, now sounds like a good time to look into a neat little feature coming in 7.1: easily converting any callable into a proper Closure using the new Closure::fromCallable() method.

He starts with a quick refresher on what closures/callables are in PHP (or an introduction for those not already familiar) including a simple example with the reject handling on a Laravel collection. He then modifies the example to try to pass in a base PHP function. This doesn't work directly (as it's not technically "callable" how it's expecting) so he wraps the is_float in a closure instead. This is a bit of a hassle and not as reusable so he updates it for PHP 7.1 and uses the Closure::fromCallable handling to make it automatically. He follows this with another example use case: calling a private method with the array of object/method name from inside the class.

tagged: closure callable fromcallable php7 example introduction

Link: https://josephsilber.com/posts/2016/07/13/closure-from-callable-in-php-7-1