Namespaces plays an important feature of php. Namespaces are used to solve 2 major issues.
1) Authors of libraries
2) Applications encounter
Laravel 4.x also provide namespace to solve those issues.
The files are app/controllers/FilesController.php and app/models/File.php. I am trying to make a new File in FilesController.php.
Namespacing is pretty easy once you get that hang of it.
Take the following example:
app/models/File.php
namespace App\Models;
class File {
public function someMethodThatGetsFiles()
{
}
}
app/controllers/FileController.php
namespace App\Controllers;
use App\Models\File;
class FileController {
public function someMethod()
{
$file = new File();
}
}
By this way we can use namespaces in laravel 4.x
0 Comment(s)