Articles/PHP/PHP Group Multiple use Declarations

PHP Group Multiple use Declarations

As of PHP 7, you can now group your imported classes, functions, and constants from under the same namespace.

November 5, 2016·1 min read

As of PHP 7, you can now group your imported classes, functions, and constants from under the same namespace. Let's look at an example to show you how you can start using this today in your projects.

Previously you'd have to write out your imports like so:

PHP
<?php

use App\Category;
use App\Product;

Now you can group them since they are within the same namespace of App like so.

PHP
<?php

use App\{Category, Product};