Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BhSimon's avatar

Enums in their own folder

Is there a way to make Laravel automatically put enums into a subfolder of 'app' when using php artisan make:enum? It’s one of those convenience things I’d like to figure out so I do not always need to specify the folder when making an enum – or moving them when I forget!

0 likes
4 replies
tykus's avatar

AFAIK, no. However, the command will automatically create Enum classes in app/Enums or app/Enumerations if one of those directories already exists; so you either can create the directory before making any Enum classes, or specify the namespace whenever making the first Enum class, e..g.

php artisan make:enum Enums\\UserTypes
# creates app/Enums/UserTypes.php
martinbean's avatar

AFAIK, no. However, the command will automatically create Enum classes in app/Enums or app/Enumerations if one of those directories already exists

@tykus The latter was by request of me 😅

But yeah, if you just call make:enum in a fresh project, it’ll dump it in the app directory by default.

2 likes
cosmic_learning's avatar

Laravel doesn’t do that automatically by default, but you can set up a custom stub or use a little workaround.

One simple way is to create your own artisan command that extends the original make:enum and sets the path to something like app/Enums by default.

Please or to participate in this conversation.