Sorry, this video is only available to Pro accounts.

Upgrade your account to get access to all content.

PHP Namespaces

Created on April 10th, 2017

In this video you will learn about PHP namespaces. You will learn why the are useful and how to use them.

If you have a file located at App\Ninja\Weapon.php you will probably want to give it a namespace like the following:

<?php

namespace App\Ninja;

class Weapon {

}

Then, if you need to create a new instance of this Weapon class you can do so with the following:

<?php

use App\Ninja\Weapon;

$weapon = new Weapon;

PHP namespaces allow us to include classes in our project with the same name and it allows us to organize our code and classes better.

Comments (1)