Search code examples
laravelclassstructure

Laravel 9.3, reorganize request classes structure


I have tried to reorganize my request classes. For example, I tried the following:

Instead of: use app\Http\Requests\UpdatePasswordRequest; (in the folder app\Requests.

I wanted: use app\Http\Requests\Account\Password\UpdatePasswordRequest: (in the folder app\Http\Requests\Account\Password\

At the: composer dump-auto I get a message like this: The class App\Http\Requests\UpdatePasswordRequest in E:/htdocs/project/app\Http\Requests\Account\Password\UpdatePasswordRequest.php does not conform to the psr-4 autoloading standard. Skip.

Is there a workaround for this, I want to organize my request files for clarity.


Solution

  • Your issue is that you have put .php in the namespace of the file so simple changing the namespace of the file to

    namespace Http\Requests\Account\Password;
    
    class UpdatePasswordRequest extends FormRequest
    

    This should do it!