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

Laravel News:
Laravel 5.7 Guest User Gates
Sep 06, 2018 @ 15:49:45

On the Laravel News site they highlight a change in the way that the "gates" handling works in the v5.7 release of the popular framework. In this change you can now allow "guest" users into certain parts of your system.

In Laravel 5.6 and below authorization gates and policies automatically return false for unauthenticated users. New in Laravel 5.7, you can now allow guests to go through authorization checks by using a nullable type-hint or setting the default value as null:

[...] By using a nullable type hint the $user variable will be null when a guest user is passed to the gate, and you can then make decisions about authorizing the action. If you allow nullable types and return true, then the guest will have authorization.

The post includes a code snippet showing how to put it to use and the resulting 403 page they would get otherwise. You can find out more about other new features of Laravel v5.7 in this other article.

tagged: laravel gate user tutorial nullable feature framework

Link: https://laravel-news.com/laravel-5-7-guest-user-gates-policies

Sameer Borate:
New features in PHP 7.1
Feb 13, 2017 @ 16:57:45

The PHP 7.1.x releases are some of the latest versions of the language. There's plenty of new features that came along with this new release. In this new post to his CodeDiesel blog Sameer Borate looks at some of these new features (including code snippets to illustrate).

The PHP development team announced PHP 7.1.0 on 01 Dec 2016. This release is the first point release in the 7.x series. There are a few features – like the void return type – which have been introduced. Below are a few new selected features in PHP 7.1.

In the post he covers:

  • void functions (return type)
  • nullable types
  • symmetric array destructuring
  • class constant visibility

For each, code samples are provided and some of the benefits (and limitations) that come along with them.

tagged: feature php71 void nullable array class constant summary

Link: http://www.codediesel.com/php/new-features-in-php-7-1/


Trending Topics: