nWidart / laravel-modules

Module Management In Laravel
https://docs.laravelmodules.com
MIT License
5.52k stars 959 forks source link

publish views from module #179

Closed eness closed 7 years ago

eness commented 7 years ago

Hey there,

I've just created a sample Blog module then fired the command php artisan module:publish Blog

What I have expected to see is everything under Blog/Resources/views/* folder would be copied to actual resources/views/blog/ folder but nothing happens. The registerViews() method of the default service provider's points out that it's going to publish views but it doesn't.

Is there anything that I've been missing? And another question raises so if I will have to copy (publish) Resources/* folder to laravel's default resources folder, what's the benefit of using that kind of modular hierarchy?

armababy commented 7 years ago

Hey,

The registerViews only registers views (as the method name implies) so you can call them via view('blog::my_view') to actually publish views to resources folder you have to use publishes method on the service provider. Command php artisan module:publish Zxcv actually publishes everything from Module/Assets folder into the public/module/<whats_in_assets>.

Also, you don't have to publish anything, views are accessible as they are, if you are publishing that means you want someone to override your default module views.

Long story short if you are only one who works on the module, you can keep everything contained only inside your module. (Except when you need assets for browser you would publish assets).

I would suggest you browse trough documentation and code about all of this.

dark-wind commented 6 years ago

This is very useful

view('blog::my_view')