PHP

Announcing the release of Lumen 5.2


Lumen is a micro framework carved out of Laravel.

Slim, Flight, Silex are all examples of micro frameworks that you can easily employ to build your strictly API applications without using almighty Laravel or CakePHP or Symfony or even Zend.

There are so many components you wouldn’t need in the full-fledged frameworks when building APIs and several micro-services, thus the need for micro-frameworks like Lumen.

Lumen 5.2.0 was released about 2 hours ago and it’s design has shifted towards focusing on stateless APIs. Two major components were removed to achieve this:

1. Sessions

2. Views

If you need them, you’ll have to upgrade to Laravel 5.2

Changes Introduced in Lumen 5.2.0

1. Authentication.

Since sessions have been removed, authentication is now based on stateless authentication via headers and API tokens.

You now have complete control over the AuthServiceProvider

To use Lumen’s authentication features, uncomment the call to register AuthServiceProvider in bootstrap/app.php around line 82 like so:

In AuthServiceProvider.php, we have this:

The viaRequest method accepts a callback function  which accepts the incoming request and returns the user instance. By default it assumes api_token, as a developer, you can state whatever parameter you want to actually enforce.

You can access the authenticated user still using Auth::user() like we have in the Laravel Framework but you need to uncomment $app->withFacades() in the bootstrap/app.php file:

One more thing,

For your routes that need authentication, you need to uncomment

$app->routeMiddleware in bootstrap/app.php file:

and then use auth as a middleware on those routes the same way you set middlewares in Laravel 5.2

2. Testing Helpers

There are several testing helper functions in Lumen, since sessions have been removed, all of the form interaction testing helpers have been removed.

3. IronMQ removed

The IronMQ queue driver has been moved into its own package and is no longer shipped with the core framework.  http://github.com/LaravelCollective/iron-queue

Conclusion

The upgrade guide from Lumen 5.1 to Lumen 5.2 is here. Check it out.

Please, let me know if you have any questions or observations in the comments section.

PROSPER OTEMUYIWA

About PROSPER OTEMUYIWA

Food Ninja, Code Slinger, Technical Trainer, Accidental Writer, Open Source Advocate and Developer Evangelist.