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

Matt Stauffer:
Things I didn't know Laravel could do
Jun 03, 2016 @ 10:47:51

Matt Stauffer has a post to his site sharing a few things he didn't know Laravel could do as discovered during his work on his book Laravel Up & Running.

It turns out that there's a long road between "I have a book contract" and "I know everything there is to know in order to write this book."

It doesn't matter how much of an expert you feel like. It doesn't matter how much time you've spent learning and teaching. Across the board, every tech author I've talked to has described just how much they learned—had to learn—when they wrote a book.

I learned a lot in writing Laravel: Up and Running. And I want to share it with you.

He includes a list of four of the interesting things he learned during his writing:

  • The Cookie Facade is one special cookie
  • Attaching files to emails is easier than you think
  • You can chain more Scheduler methods than the docs show
  • You can assert that a view gets passed certain data

Each item also comes with a brief code example showing it in action. If you'd like more information about the book and a free sample, be sure to sign up using the form in the post or you can just pre-order the book and get the whole thing as soon as it's released.

tagged: oreilly book laravel interesting feature top4 free sample

Link: https://mattstauffer.co/blog/things-i-didnt-know-laravel-could-do

Pascal Martin:
INI directives are evil!
Apr 28, 2016 @ 12:58:40

In a new post to his site Pascal Martin shares some thoughts about why INI directives are evil, mostly in how they could be used to enable/disable major pieces of functionality in the PHP language.

A few times, while evolutions were discussed for PHP 7, someone suggested a new feature could be optional, depending on an INI configuration directive — the idea being each user could then enable it or not.

Still, the idea of directives that could change, sometimes deeply, the behavior of a programming language… It scares me!

He goes back in time a bit to talk about a feature like this that was once a part of the language (happily removed now): "magic quotes". He points out that, while the intent was to provide security to submitted data, the results were disastrous if it was moved to another server without the setting enabled. He also points out some of the steps that have to be taken when a new directive controlling a major feature is introduced - even worse if you're creating a product to run on other peoples' servers.

In any case, before suggesting "but they could allow us to enable or not this feature with a simple INI directive" for ideas as critical as a weak or strict typing mechanism, ask yourself: do you really want two languages with very distinct behaviors, and applications and libraries that work only on some combinations of configuration values?
tagged: ini directive feature language evil opinion

Link: https://blog.pascal-martin.fr/post/ini-directives-are-evil.html#fn:why-optionnal-feature

Laravel Daily:
Three new features in Laravel 5.2.22
Mar 01, 2016 @ 11:17:53

The Laravel Daily site has a quick post on the heels of the latest minor release of the Laravel framework, v5.2.2, that includes some of the new features that came along with it.

Two days ago Taylor Otwell released a new minor version of Laravel framework – 5.2.22. Along with some small fixes, there are a few new functions, let’s look into them.

The three features they talk about aren't major changes to the framework but they are helpful to those needing these little tweaks:

  • Validate array distinct (a new rule to validate if array has only different values)
  • fullUrlWithQuery (automatically adding query parameters to a url() kind of call)
  • Blade: continue and break (more flow control in Blade templates)

Examples are included showing how to use the new functionality as well.

tagged: laravel feature release array distinct fullurlwithquery blade continue break

Link: http://laraveldaily.com/three-new-functions-in-laravel-5-2-22/

SitePoint PHP Blog:
Sourcehunt #4 – Reflection, Authorization, Crons, and more
Feb 29, 2016 @ 11:18:04

The SitePoint PHP blog has posted the latest in their "Sourcehunt" series of posts highlighting several open source libraries across a wide range of topics they find notable: Sourcehunt #4.

We skipped January’s Sourcehunt, but we’re back now, ready to boost the stardom of more projects!

Libraries included in this latest Sourcehunt include:

Each item in the list comes with a bit of detail around what the library is and what kinds of features it provides. There's also a few other links included to alternatives and resources about the libraries.

tagged: sourcehunt ep4 opensource library feature sitepoint

Link: http://www.sitepoint.com/sourcehunt-4-reflection-authorization-crons-and-more/

Alfred Nutile:
Feature Flags In Laravel
Jan 26, 2016 @ 09:45:02

In a post to his site Alfred Nutile has posted a guide to integrating feature flags (toggles) into your Laravel-based application to show and hide features based on different criteria. He makes use of the Atriedes/feature library to handle some of the logic and decisions for him.

We are working on using FeatureFlags or Toggles in our applications. For one we are aiming to do all our work on mainline branch at all times so this would be a key coding discipline to use FeatureFlags so we can hide a feature in progress knowing it will not interfere with the application.

[...] One key thing, as I use this in Laravel, is I will try and mix this with the existing Authorization workflow that is already present. This gives me some already prepared ways to think about this both at the view layer, model layer and controller layer and where to register these states.

He shows how to get the "feature" library installed and integrates it with the Laravel application via two service providers: one for the core flag handling and the other for defining the policies themselves. He includes the code for each of these providers and makes some simple "can see" and "can add" policies for a Twitter field. He also shows the code for the evaluation methods and how to make use of the functionality in a menu (template). He also includes a screencast showing how it all works in a live application.

tagged: featureflag toggle tutorial laravel atriedes library screencast feature

Link: https://alfrednutile.info/posts/175

Jordi Boggiano:
New Composer Patterns
Dec 21, 2015 @ 11:52:36

Jordi Boggiano, lead developer on the Composer has posted about some of the new Composer patterns that have been introduced into the tool this year, including some you might not even have realized.

Here is a short update on some nice little features that have become available in the last year in Composer.

He includes five of these features in his list (but something tells me these are just some of the more user-facing improvements the project has introduced):

  • Checking dependencies for bad patterns
  • Referencing scripts to avoid duplication
  • Defining your target production environment in composer.json
  • Excluding paths from the optimized classmap
  • Requiring packages easily and safely

For each item he includes the command (and sometimes optional arguments) that make it work and what kind of results you can expect. There's definitely some handy features in here and not just for the "power users" in the crowd.

tagged: composer feature update project patterns duplication environment classmap

Link: http://seld.be/notes/new-composer-patterns

Matt Stauffer:
Implicit route model binding in Laravel 5.2
Dec 18, 2015 @ 09:34:53

Matt Stauffer has continued his series looking at the new features of Laravel v5.2. In this new article he talks about the addition of implicit route model binding. This is a bit more fancy term for the ability to link models to routes and tell Laravel they're related.

If you've never used it, Laravel's route model binding has been around for a while, but Laravel 5.2 is about to make it even easier. [...] In your route service provider, just teach the router: $router->model('shoe', 'AppShoe'); That means, "any time I have a route parameter named shoe, it's an ID representing an instance of AppShoe". [...] In Laravel 5.2, it's even easier to use route model binding. Just typehint a parameter in the route Closure (or your controller method) and name the parameter the same thing as the route parameter.

He includes code examples of the "old way" to do it with model functionality inside the route and the "new way" of linking the model to the route. This allows you to auto-magically have a valid model instance once the route is called. He also shares some of the little known features of this model binding including using closures in bind() calls and changing the "route key" away from the "id" column.

tagged: model route binding laravel feature implicit feature v52

Link: https://mattstauffer.co/blog/implicit-model-binding-in-laravel-5-2

Matt Stauffer:
Implicit route model binding in Laravel 5.2
Dec 18, 2015 @ 09:34:53

Matt Stauffer has continued his series looking at the new features of Laravel v5.2. In this new article he talks about the addition of implicit route model binding. This is a bit more fancy term for the ability to link models to routes and tell Laravel they're related.

If you've never used it, Laravel's route model binding has been around for a while, but Laravel 5.2 is about to make it even easier. [...] In your route service provider, just teach the router: $router->model('shoe', 'AppShoe'); That means, "any time I have a route parameter named shoe, it's an ID representing an instance of AppShoe". [...] In Laravel 5.2, it's even easier to use route model binding. Just typehint a parameter in the route Closure (or your controller method) and name the parameter the same thing as the route parameter.

He includes code examples of the "old way" to do it with model functionality inside the route and the "new way" of linking the model to the route. This allows you to auto-magically have a valid model instance once the route is called. He also shares some of the little known features of this model binding including using closures in bind() calls and changing the "route key" away from the "id" column.

tagged: model route binding laravel feature implicit feature v52

Link: https://mattstauffer.co/blog/implicit-model-binding-in-laravel-5-2

SitePoint PHP Blog:
Feature Toggling Explained with Qandidate’s Toggle
Dec 15, 2015 @ 11:49:57

The SitePoint PHP blog has posted a tutorial showing you how to use the Toggle library from Qandidate to handle the enabling and disabling of features in your application.

A frequently used development workflow in version control systems is feature branching. The idea is that we develop new features in branches other than the master one. After a feature is tested and ready to be released, it is merged back into the master branch or a release branch for deployment. This approach helps us develop new features without disturbing the main code base.

However, developing a feature branch might take much longer than a normal release cycle. [...] One of the techniques widely used as an alternative to feature branching is feature toggling. Feature toggles (or feature flippers) act like on/off switches. [...] We can temporarily hide a partially built or risky feature (release toggles) or limit finished stable features to a certain group of users (business toggles).

They introduce the basics of the Toggle library and it's main components: the Manager, Toggles, Operators, Conditions and Context. These are all combined together to help determine if a feature should be enabled or hidden. Examples of each are included along the way as well as one showing a toggle in action. They also show how to integrate it with a framework, in this case a Laravel project as middleware. The post ends with a look at strategies, giving you even more customization around the conditions of the toggle (example: Affirmative, Majority and Unanimous), statues and creating the conditions from either YAML or array configurations.

tagged: feature toggle flag qandidate library tutorial introduction functionality

Link: http://www.sitepoint.com/feature-toggling-explained-with-qandidates-toggle/

PHP Roundtable:
035: Immutable PHP
Nov 25, 2015 @ 09:53:44

The PHP Roundtable podcast has posted their latest episode, recorded live with host Sammy Kaye Powers and guests Larry Garfield, Matthew Weier O'Phinney and Glen Hickle talking about immutability in PHP.

Immutability plays a huge role in functional programming and many languages support immutability directly; like the readonly keyword in C#. It is possible to create immutable objects in PHP, but the language lacks inherent immutable features for scalar variables and class properties. We discuss how to bring functional programming concepts to PHP and brainstorm some features that could possibly be added to future versions of PHP to offer better immutability support.

You can watch the live recording of this latest episode either through the in-page video player or directly over on YouTube. If you enjoy the show, be sure to also subscribe to their feed and follow them on Twitter for information on the latest episodes (and when future live recordings are happening).

tagged: phproundtable ep32 immutability programming feature functional support

Link: https://www.phproundtable.com/episode/immutability-and-functional-concepts-in-php