does it support module specific event & event listener? if yes then how to generate? I don't see any command in the documentation.
Hi,
I've already used that in my module so I can share with my experience. First of all you need to create EventServiceProvider inside your module. After that create events and listeners.
php artisan module:make-provider EventServiceProvider
php artisan module:make-event SomethingWasCreated
php artisan module:make-listener DoSomething --event=SomethingWasCreated
Here's the stub for EventServiceProvider:
<?php namespace Modules\...\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
];
}
Then add proper events into $listen array in EventServiceProvider.
At the end add EventServiceProvider with full namespace into module.json file under providers array. That's it. You should be able to start work with events and listeners.
@msieprawski does it accept php artisan module:make-provider EventServiceProvider <module-name> module name parameter and can I create observer class as well ?
@webreinvent yeah it does support second parameter which is a name of module. But you can call php artisan module:use ModuleName and then simply create what you need.
If you mean model observer then I can't see it on list.
observer not exist, here's response https://github.com/nWidart/laravel-modules/issues/74 from the author
@msieprawski thanks 馃憤
Important to note that anything from the usual laravel framework _will_ work in your module as well 馃槃
I have started getting following error if I run php artisan module:make-event UserCreated:
earlier it was working fine.
F:\xampp56\htdocs\ph>php artisan module:make-event UserCreated
[Illuminate\Contracts\Filesystem\FileNotFoundException]
File does not exist at path F:\xampp56\htdocs\ph\storage\app/modules/modules.used
Any idea how to fix it?
need passing one module name, example: php artisan module:make-event UserCreated yourModuleName
please let me know how to make broadcast event in this module ?
I want create two broadcast events on two different modules and run on single private channel, how to do that?
That's explained in the laravel docs. Please refer to those documentation.
Most helpful comment
Hi,
I've already used that in my module so I can share with my experience. First of all you need to create
EventServiceProviderinside your module. After that create events and listeners.php artisan module:make-provider EventServiceProviderphp artisan module:make-event SomethingWasCreatedphp artisan module:make-listener DoSomething --event=SomethingWasCreatedHere's the stub for
EventServiceProvider:Then add proper events into
$listenarray inEventServiceProvider.At the end add
EventServiceProviderwith full namespace intomodule.jsonfile under providers array. That's it. You should be able to start work with events and listeners.