Skip to content

fix: make:enum creates Enums directory if none exists#59334

Closed
Waris10 wants to merge 1 commit intolaravel:13.xfrom
Waris10:fix/make-enum-creates-enums-directory
Closed

fix: make:enum creates Enums directory if none exists#59334
Waris10 wants to merge 1 commit intolaravel:13.xfrom
Waris10:fix/make-enum-creates-enums-directory

Conversation

@Waris10
Copy link

@Waris10 Waris10 commented Mar 23, 2026

What this fixes

When running make:enum in a fresh Laravel application (or any app without an existing Enums or Enumerations directory), the generated enum is dropped directly into app/ with namespace App; instead of the expected app/Enums/ with namespace App\Enums;.

This happens because getDefaultNamespace() falls back to the root namespace when neither folder exists, and no directory is created.

The fix

The default case in getDefaultNamespace() now returns $rootNamespace.'\\Enums' instead of $rootNamespace. The existing makeDirectory() call in the parent GeneratorCommand class handles the actual folder creation — so no additional infrastructure changes are needed.

Why this doesn't break existing behaviour

  • If app/Enums already exists → same behaviour as before
  • If app/Enumerations already exists → same behaviour as before
  • If neither exists → previously broken (dumped in app/), now correctly creates app/Enums/ and places the file there

Benefit to end users

Running make:enum Status on a fresh app now works exactly as a developer would expect — consistent with how other make:* commands handle their target directories. No manual folder creation needed.

Tests

Updated three existing tests that were asserting the old broken behaviour (namespace App; / app/*.php) to reflect the correct output. The two existing directory-specific tests are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants