Reputation: 304
Best everyone,
There is one thing in Laravel 4 I just can't understand if you create a namespace in my case cms
and you want to use for instance View::make
or Input::all()
laravel wil tell you it could not be found what is correct since those methods are in the global namespace and not in cms
so to get it to work you can refer to it with adding a backslash before the method that will it wil user the global namespace. however i find that confusing isn't there a way to have a use
or something that imports all the Input, Hash, Redirect
enz.. So you could use it without adding \
.
Upvotes: 2
Views: 772
Reputation: 714
Not sure I completely follow, do you mean: using View::all() without doing \View::all() in a cms Namespaced file?
If so you can import namespaces by using the use keyword and alias them by using the as keyword
e.g.
use MyNameSpace\View; // Imports only
use MyNameSpace\View as MyView; // Imports and Aliases
class {
....
}
For more details please see http://php.net/manual/en/language.namespaces.importing.php
Upvotes: 2