Support the ongoing development of Laravel.io →
Configuration Views Architecture
Last updated 2 years ago.
0

Views are not classes and thus cannot be autoloaded with psr-0

Take another look at the repository you linked to. The views folder is not under the namespace but still in the default location for Laravel.

Because composer supports psr-4 this task of being able to autoload new classes becomes much easier. You can keep the default Laravel directory structure and change the autoload section in the composer.json to the following.

"psr-4": {
    "Acme\\Blog\\Controllers\\": "app/controllers",
    "Acme\\Blog\\Models\\": "app/models"
},

You can also add migrations, seeds, tests, etc as well if you put those under the same namespace.

Last updated 2 years ago.
0

@spekkionu

Thanks for your reply, but I found a solution.

Create a service provider to module and add namespace to view, just like like that:

\View::addNamespace('NamespaceModule', __DIR__ . '/../Views');

And make view like that:

return \View::make('NamespaceModule::module.index');
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.