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

TutsPlus.com:
Set Up Routing in PHP Applications Using the Symfony Routing Component
Jul 16, 2018 @ 18:14:04

On the TutsPlus.com site today there's a new tutorial where they spotlight one of the components in the Symfony framework: the routing component. The tutorial outlines some of the basics about the component, installing it and putting it to use.

The Symfony Routing Component is a very popular routing component which is adapted by several frameworks and provides a lot of flexibility should you wish to set up routes in your PHP application.

If you've built a custom PHP application and are looking for a feature-rich routing library, the Symfony Routing Component is more than a worth a look. It also allows you to define routes for your application in the YAML format. Starting with installation and configuration, we'll go through real-world examples to demonstrate a variety of options the component has for route configuration.

The tutorial starts with the commands to get the component installed (via Composer) and other related components for YAML parsing, HTTP handling and configuration parsing. It then provides examples of:

  • setting up the instance and defining some basic routes
  • how route matching works
  • loading routes from a YAML file

The tutorial finishes with an example of an "all in one" router that pulls in the route configuration and creates a new Router instance with them ready and waiting to handle requests.

tagged: routing symfony component tutorial yaml configuration http

Link: https://code.tutsplus.com/tutorials/set-up-routing-in-php-applications-using-the-symfony-routing-component--cms-31231

Master Zend Framework:
What Are Delegator Factories and Why You Should Use Them
Jun 27, 2018 @ 17:17:24

On the Master Zend Framework site Matthew Setter has posted a tutorial introducing you to delegator factories and what they're useful for in Zend Framework-based applications.

Ever wanted to dynamically expand the functionality of an object which you retrieve from your dependency injection container, based on different needs, yet without creating messy, hard to maintain configurations? If so, then you're going to want to know about a powerful technique called Delegator Factories.

He starts with a brief definition of what the factories are and the basics of what they allow you to do (briefly stated, they decorate DI services from the container). He then gets into a practical example, showing the update of a script from v2 to v3 of Zend Expressive, to wrap route definitions in a delegator to handle the difference. Complete code is provided as well showing the initial version of the routing code and the application of the delegator.

tagged: delegator factory zendframework zendexpressive tutorial routing

Link: https://masterzendframework.com/what-are-delegator-factories/

Laravel News:
Laravel Route Tips to Improve Your Routing
Apr 05, 2018 @ 16: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 @ 18: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 @ 15: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 @ 16: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/

TutsPlus.com:
Programming With Yii2: Routing and URL Creation
Dec 13, 2016 @ 18: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 @ 16: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 @ 14: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 @ 16: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


Trending Topics: