1

When i use Enum in laravel it gives me error during package installation and composer commands: Generating optimized autoload files

Class App\Enums\Gender:string located in MyProject\app\Enums\Gender.php does not comply with psr-4 autoloading standard. Skipping.

I Want to use php(8.1) feature Enum in laravel(9)

3
  • What have you tried to resolve the problem? Where are you stuck? Is this a PHP problem, a Laravel problem, or a Composer problem? Commented Nov 7, 2022 at 13:38
  • @NicoHaase When I use enum in Controller and Views it works but when I installed sompackages the errors occurs during composer package installations. So I tried to add a space after semicolon in enums the problem solved. " enum enumName: string{ } " so the problem solved. Commented Nov 14, 2022 at 13:58
  • Please add all clarification to your question by editing it Commented Nov 14, 2022 at 14:05

1 Answer 1

1

There should be space between "Gender:" and "string".
I change this:

enum Gender:string { 
    case Male = 'male';
    case Female = 'female';
} 

to this:

enum Gender: string { 
    case Male = 'male';
    case Female = 'female';
}

The problem Solved.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.