If I make an Enum through artisan command (php artisan make:enum User/UserRole). So I have to do this (php artisan make:enum Enums/User/UserRole) to make Enums in the Enums namespace. But that's when things get interesting, after this I can just create Enums without mentioning the Enums namespace, and it will be put into the Enum directory.
Why is this happening and is it the normal behavior?
#Is this Artisan behavior normal?
8 messages · Page 1 of 1 (latest)
@sullen briar
Yes, if the Enums directory exists then they'll go there otherwise root - the only thing that's a little unusual (for me) is that when the directory doesn't exist it's not created hmm here's the command anyway..
https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Console/EnumMakeCommand.php
Thanks I just mentioned anyone and you were mentioned. I will look into it.
I wasn't mentioned - I don't know who 'anyone' is 🙂 I just saw so thought I'd answer..
Thanks anyway.
@split lava Here is the discussion link: https://github.com/laravel/framework/discussions/53674
GitHub
When generating enums using Artisan, they are currently placed in the root directory if the App/Enums directory does not exist. If the App/Enums directory is present, the generated enums are correc...
My crystal ball tells me that someone will come and say it's because - some projects use /Enums and others use the full /Enumerations - I've never seen that full word being used, but that's what the current code is obvs providing for - maybe some folks do it that way.. 🤷♂️