# How to use PHP namespaces?

Hi all. Tell me how to cope with classes when processing through index.php? You know, a lot of online examples, but as always explain the base from which a little that is clear.
Interested in the situation when running the autoloader. How to register namespaces? That is, there is space foo\bar\User foo\bar\Admin foo\bar\Book of the bunch.
How to write code is not understood, but name to bring in index.php
use foo\bar\User foo\bar\Admin foo\bar\Book, ...
July 8th 19 at 12:06
July 8th 19 at 12:08
Solution
Pages.php. Is in the folder Backend/Models

<?php
namespace Backend\Models;

use Common\Model\Model as BaseModel;

class Pages extends Model {

protected $table = 'pages'; protected$key;

public function allPages() {

while(!\$rows = parent::findAll()){

throw new \Exception('no articles');

and so on......</code-->
July 8th 19 at 12:10
If index.php located in the same directory, where classes connect like this:
spl_autoload_extensions('.php');
spl_autoload_register();

If index.php is in a subdirectory first change directory to the root, then connect classes:
chdir(dirname(__DIR__));
spl_autoload_register();