PHP key concepts.
<?php
namespace App\Controllers\Admin;
Class MyController{
//...
}
?>Then in another class, we could use App\Cpontrollers\Admin\AuthController.
For Laverel
Lavarel only automatically load all the classes in the top namespace in the composer.json file. If the class does not have namespace ...; in the top of the PHP file, this class would use the top namespace.
Lavarel need to be told namespaces other than the top namespace.
$ composer dump-autoloadfrom use3.php.net
<?php
namespace foo;
use My\Full\Classname as Another;
// this is the same as use My\Full\NSname as NSname
use My\Full\NSname;
// importing a global class
use ArrayObject;
// importing a function (PHP 5.6+)
use function My\Full\functionName;
// aliasing a function (PHP 5.6+)
use function My\Full\functionName as func;
// importing a constant (PHP 5.6+)
use const My\Full\CONSTANT;
$obj = new namespace\Another; // instantiates object of class foo\Another
$obj = new Another; // instantiates object of class My\Full\Classname
NSname\subns\func(); // calls function My\Full\NSname\subns\func
$a = new ArrayObject(array(1)); // instantiates object of class ArrayObject
// without the "use ArrayObject" we would instantiate an object of class foo\ArrayObject
func(); // calls function My\Full\functionName
echo CONSTANT; // echoes the value of My\Full\CONSTANT
?>SplObject is good for storing object as an element of the set, or as a key to map. And according to the benchmark from Matt Butcher , it surpasses the Array when it comes to mapping the objects.