1

So, I am fairly new to Laravel and working on huge laravel project. I need a way by which I can create Events and Listeners folders in my subdirectory with php artisan event:generate command or php artisan make:event and php artisan make:listener commands.

I have tried running these commands but it creates Events and Listeners in root directory under app/Events and app/Listeners.

We have a different directory structure where apart from the app we have src/directory1/directroy2/directroy3. And under directory3 we have Http controllers, Models, Providers, etc.

I would like my new Events and Listeners to be created under directory3 using artisan command.

Also, if I don't use artisan commands and create Events and Listeners folder manually, will it work? I know commands should be preferable methods for developers but what if I want to do manually?

I tried following other threads mentioned in the comment section. It didn't help.

I did php artisan make:event src/directory1/directory2. What happened is I got src/directory1/directory2 under the Events folder in the app directory. What I want is I have an src directory at the same level where the app is. I want to do something under src/directory1/directory2/directory3 directory structure. You can remove your flag as it didn't help

Yaser Darzi
  • 1,480
  • 12
  • 24
corecoder
  • 11
  • 6
  • Possible duplicate of [Create model in a custom path in laravel](https://stackoverflow.com/questions/37251322/create-model-in-a-custom-path-in-laravel) – Salim Djerbouh Oct 02 '19 at 13:25
  • This is for models. I want some workaround for events. What if I define my events and listeners in EventServiceProvider.php under directory3 and do event:generate there? Will that thread help? – corecoder Oct 02 '19 at 13:29
  • @CaddyDZ I tried following that thread. I did php artisan make:event src/directory1/directory2. What happened is I got src/directory1/directory2 under Events folder in app directory. What I want is I have src directory at same level where app is. I want to do something under src directory structure. You can remove your flag as it didn't help. – corecoder Oct 02 '19 at 13:33
  • 1
    artisan doesn't have a flag to set a custom path for events. you can always create the class and move it manually. just don't forget to update the namespace. – Erich Oct 02 '19 at 14:02

0 Answers0