Oh Dear is the all-in-one monitoring tool for your entire website. We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that paired with a developer friendly API and kick-ass documentation. O, and you'll also be able to create a public status page under a minute. Start monitoring using our free trial now.

Using StackPHP middleware in Laravel 5

Link –

Middleware is a series of wrappers around your application that decorate the request and the response. By wrapping the app in decorators you can add new behavious from the outside. This image explains the idea more visually:

[caption id="attachment_475" align="alignnone" width="726"]onion source: StackPHP.com[/caption]

 

The concept isn't new, solutions already exists for many languages (eg. Ruby, Python, Node, ...)

The PHP equivalent is StackPHP. Here's an excellent post by Richard Bagshaw explaining it. There are a lot of StackPHP style middlewares available that you can use in your applications.

Laravel 5 uses middleware for putting an application in maintenance mode, CSRF protection, authentication and more. Unfortunately Laravel 5 middleware isn't compatible with StackPHP-style middleware. Barry vd. Heuvel created at package to convert StackPHP middleware to Laravel 5 middleware and explained the inner workings on his blog.

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

What are your thoughts on "Using StackPHP middleware in Laravel 5"?

Comments powered by Laravel Comments
Want to join the conversation? Log in or create an account to post a comment.