Reputation: 33
As far as I know, namespace is used for preventing class, function, ... collision in PHP. In Laravel 8 when we create a model for example, the name space is App\Models
and when we want to use this model, we have to use it like use App\Models\MyModel
. My question is when we use use Illuminate\Support\Arr
, why we don't use the full path explicitly vendor\laravel\framework\......
Upvotes: 0
Views: 108
Reputation: 3885
It’s part of the PSR-4 auto loading standard which replaces the PSR-0 auto loading standard. Composer compiled an autoload.php from your project’s and dependencies’ composer.json
. As part of the bootstrapping process that file is included in the application and registers each namespace.
Upvotes: 1