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

Laravel News:
Laravel Route Tips to Improve Your Routing
Apr 05, 2018 @ 11:13:12

On the Laravel News blog they've posted a tutorial with some helpful tips for improving your routing in your Laravel-based application.

The Laravel router has a great, well-polished API when you first dive into Laravel as a beginner or newcomer to the framework. What follows is not anything hidden or new, but a few tips that should help you when you’re learning Laravel 5.

The documentation is excellent, and the tips that follow supplement and piece together a few parts that will help you get a quick jumpstart on learning how to use routing in your Laravel applications.

The tips include:

  • Custom Namespaces
  • Route Macros
  • Debugging Routes
  • Named Group Routes

Each of the tips include the code needed to implement them and a brief summary of why they're useful.

tagged: routing tips laravel tutorial namespace macro debug named

Link: https://laravel-news.com/laravel-route-tips-to-improve-your-routing

Nicolas Grekas:
Making Symfony router lightning fast - 2/2
Feb 22, 2018 @ 12:54:30

Nicolas Grekas has posted the second part of his look at the work that was done to increase the performance on the router in version 4 of the Symfony framework. In part one he covered some of the basic changes made to the router for faster matching. In this latest article he covers some of the "tweaks" made on top of this work to help improve things even more.

In Making Symfony’s Router 77.7x faster - 1/2, we learned how to build a faster URL matcher, using hash-map lookups for static routes, and combined regular expressions for routes with placeholders, while preserving all the advanced features of the Symfony router. However, more work was needed for some real world apps, as at least one of them experienced a slow down. Let’s see how fixing this provided us with (one of) the fastest PHP routers out there.

He then starts working through some of the newer changes to help "reclaim" some of the performance loss in certain situations. He talks about same-prefix route ordering, subpatterns and placeholders to change how the combined regular expressions perform the matching on the incoming URL. The result is an even more performant routing system that's 77 times faster than what they started with.

tagged: symfony routing performance regularexpression regex improvement series part2

Link: https://medium.com/@nicolas.grekas/making-symfony-router-lightning-fast-2-2-19281dcd245b

Robert Basic:
Prooph query bus
Dec 21, 2017 @ 09:52:19

In a post to his site Robert Basic continues his series looking at the Phrooph package, this time focusing on the query bus. This functionality allows you to dispatch an event to a single "finder" in the CQRS/event souring framework.

Continuing on with the The query bus allows the handler to do whatever it needs to do to return the result, synchronously or asynchronously.

He starts by talking about the return value of the bus - a ReactPHP promise for the async handling - and the plugin system that allows for more advanced handling. He then starts on the example, showing how to create a simple bus object and define the routing to a specific query handler. This is then dispatched and a closure is defined as the "done" operation. From this basic example he then moves to something a bit more useful - an example query to determine how may Calls for Papers are currently open on the Joind.in service (fetched via the API).

tagged: prooph example tutorial querybus query routing handler

Link: https://robertbasic.com/blog/prooph-query-bus/

Frank de Jonge:
Battle Log: Symfony Routing performance considerations.
Feb 28, 2017 @ 10:55:24

In a new post to his site Frank de Jonge shares his "battle log" when looking into routing performance considerations in Symfony after a "deep dive" into the component's code.

Last week I took a deep dive into Symfony's Routing Component. A project I worked on suffered from a huge performance penalty caused by a routing mistake. This lead me on the path to discovering some interesting performance considerations. Some common practices align nicely with Symfony's optimisations, let's look into those.

He starts off by describing the process he took to start the investigation and what prompted him to investigate the performance issue. He talks about his use of profiling to locate the bottleneck and track down the root cause. He answers the five "why's" about the issue and uses that to guide an approach. Ultimately he located the source of the issue - YAML parsing that shouldn't have been needed - and what the component does to make it more performant in non-development environments. He ends the post with a list of four performance considerations as you're going through your own development to get the most out of the component.

tagged: symfony performance routing considerations deepdive

Link: https://blog.frankdejonge.nl/symfony-routing-performance-considerations/

Programming With Yii2: Routing and URL Creation
Dec 13, 2016 @ 12:15:02

The TutsPlus.com site has posted the next article in their "Programming with Yii2" series, this time focusing on the routing and URL creation in the application and how the requests get to the intended functionality (in controllers).

In today's tutorial, I'll review routing and URL creation in Yii. When a browser request arrives at your Yii application's index.php file, it must be parsed to determine which controller and method to call. That's routing. The reverse process of linking to parts of your application is URL creation, which is best done programmatically.

Yii provides a lot of flexibility in managing routing and generating links. Follow me as I review the basics.

He starts with a bit of background on the URL manager that comes built in to the Yii2 framework and how the routes are defined. He then starts in by defining some of the desired routes for the application and how to set them up in the main configuration file (including defaults). The tutorial also includes configuration examples of "pretty URLs", and outputting custom URLs using the "Url" helper.

tagged: programming yii2 series routing url creation tutorial

Link: https://code.tutsplus.com/tutorials/programming-with-yii2-routing-and-url-creation--cms-26869

Laravel News:
Route improvements are coming to Laravel 5.4
Dec 07, 2016 @ 10:12:31

The Laravel News site has a quick new post about some routing improvements that are coming in the next larger release of the framework , Laravel v5.4:

As Laravel 5.4 development continues, two new improvements are coming to your routes, better route caching for large applications and fluently registering routes.

The route caching updates will help performance with larger applications, reducing the parsing time required to locate and push a request to the right location. The "fluent" route improvements basically allow for the definition of some things, like middleware or route names, as a part of the route definition rather than after the fact. Examples of this are included in the post.

tagged: laravel routing improvement v54 cache fluent registration

Link: https://laravel-news.com/route-improvements

Matt Stauffer:
Routing changes in Laravel 5.3
Jul 28, 2016 @ 09:36:05

In another of his series of posts about the upcoming version of the Laravel framework (v5.3) Matt Stauffer focuses in on some of the changes in routing that are coming down the line.

The last few versions of Laravel have showed the way routing works shifting around a bit. This is usually a sign that we're feeling some sort of pain—something feels off—but haven't found the perfect solution yet. In 5.3, we may have found it.

He starts by looking at some of the routing changes that happened when v5.2 was released including the change away from two groups ("web" and "api"). In v5.3 the major change is the location of the routes definitions containing all of the routes in your application. In the update, this relocation (into a directory) allows you to define multiple route configurations that can be individually changed based on features rather than one global place. He also includes an example of how you can set up your RouteServiceProvider to load in custom configurations as well.

tagged: laravel v53 routing changes directory multiple files configuration

Link: https://mattstauffer.co/blog/routing-changes-in-laravel-5-3

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Routing
Feb 17, 2016 @ 10:38:40

Loïc Faugeron has posted the next part of his "Ultimate Developer Guide" series covering individual Symfony components. In this new article he details the routing component.

In this guide we explore the standalone libraries (also known as "Components") provided by Symfony to help us build applications. We've already seen: HTTP Kernel and HTTP Foundation [and the] Event Dispatcher. We're now about to check Routing and YAML.

He starts with a basic overview of the component and what kind of top-level handling it provides. He describes the UrlMatcherInterface and its role in the routing process and a simple collection of Route instances that implement it. Then he gets into the YAML component, providing a simple example defining the routes for your application. He shows how it's converted from the YAML structure into a PHP-based (array) output and is then dumped into a RouteCollection to define the resulting routes.

tagged: symfony routing ultimate developer guide tutorial series yaml

Link: https://gnugat.github.io/2016/02/17/ultimate-symfony-routing.html

Abdul Malik Ikhsan:
Using Routed Middleware class as Controller with multi actions in Expressive
Jan 06, 2016 @ 11:54:38

In this post to his site Abdul Malik Ikhsan shows you how to use a middleware class that does some extra routing as a "controller" in your Zend Expressive application.

If you are familiar with frameworks with provide controller with multi actions functionality, like in Zend Framework 1 and 2, you may want to apply it when you use ZendExpressive microframework as well. Usually, we need to define 1 routed middleware, 1 __invoke() with 3 parameters ( request, response, next ). [...] What if we want to use only one middleware class which facilitate [multiple] pages?

He shows how to take a sample route configuration for an "album" endpoint and handle it via an AbstractPage class that performs a bit of reflection on the request to route things the right way. Then the "controller" is created by extending this abstract class and functions are defined for each action, complete with access to the request, response and next middleware objects.

tagged: zend zendexpressive routing middleware controller reflection actions tutorial

Link: https://samsonasik.wordpress.com/2016/01/03/using-routed-middleware-class-as-controller-with-multi-actions-in-expressive/

Laravel Podcast:
Episode 18 - Laravel 5 Routing, the War over PHP Annotations, and The Secret Weapon
Oct 20, 2014 @ 11:05:05

The Laravel Podcast has released their latest episode, Episode #18: Laravel 5 Routing, the War over PHP Annotations, and The Secret Weapon(tm). Join hosts Shawn McCool, Taylor Otwell and Jeffrey Way as they talk all things Laravel.

In this episode, we discuss new Laravel 5 features including annotated routing and middlewares. We discuss some motivations and guiding forces that make Laravel what it is. Also, hints about Jeffrey and Taylor's secret new project. The referenced article by @everzet can be found here: http://everzet.com/post/99045129766/introducing-modelling-by-example.

You can listen to this latest episode either by using the in-page audio player, by downloading the mp3 or by subscribing to their feed.

tagged: laravel podcast ep18 routing annotations secretweapon

Link: http://www.buzzsprout.com/11908/212256-episode-18-laravel-5-routing-the-war-over-php-annotations-and-the-secret-weapon-tm