You didn’t give an example of a function you’re trying to call that’s failing, but since you said " for any template calling on an App function" I assume you mean something like App::siteName()
. If that’s the case, you would need to change those to (probably) something like Controllers\App::siteName()
. When you change the namespace, you need to change any calls to classes in that namespace.
I tend to think of namespaces kind of like directories: When you’re in a namespace/directory then you can “see” everything in that namespace/directory easily, but anything in another namespace/directory needs instructions on how to get there appended to it.
If I’m on the command line and I want to call a function in the directory above my current working directory, I’d do something like this:
bash ../distant-script.sh
But if I wanted to run a script inside my current directory, I’d just do this:
bash adjacent-script.sh
Namespaces work the same way: If I’m in the App\Controllers
namespace and I create a class called FrontPage
, I can get at in a couple ways. if I’m “in” the App\Controllers
namespace (that is, I’m executing code in a file that begins with namespace App\Controllers
), then all I have to do is this:
new FrontPage();
But if I’m in the App
namespace, then I have to do this:
new Controllers\FrontPage();
Or if I’m in the AlwaysBlank\Tools
namespace, I would have to do this:
new \App\Controllers\FrontPage();
(Just like in directory navigation, \
at the beginning of your namespace will return you to your “root”).
Hopefully that helps.