How to generate laravel request in namespace path for laravel 5

I am familiar with the larvel artisan team

Brand: inquiry

however, I cannot get it to put it in a directory. For example, I have a directory structure

app / Http / Requests / User

and I would like to place the request in this folder with the names respectively, but

php artisan make:request User\CreateUserRequest 

does not work.

+7
php laravel laravel-5
source share
4 answers

artisan make:request User\\CreateUserRequest

thanks @ DarrylCoder for responding to comments

+9
source share

Toggle forward slash ( / ):

 php artisan make:request User/CreateUserRequest 
+1
source share

Make sure you have it in composer.json :

 "autoload": { "classmap": [ "database", "tests/TestCase.php" ], "psr-4": { "App\\": "app/" } }, 

You should have this part of psr-4 (it is set by default here).

Now you better not use app/Requests/User , but app/Http/Requests/User , because Requests should be placed in the Http directory.

Now, when you run php artisan make:request User\CreateUserRequest , you should get a response from the artisan:

\ Request created successfully.

and in your app/Http/Requests/User directory you should have a CreateUserRequest.php file

I checked it a minute ago and everything works fine. Of course, it is possible that in the version that you installed, you have a bug or you changed some other application settings so that you can try updating it to the newest version (I tested it in the version that I downloaded a couple of days ago).

0
source share

php artisan make:request Auth\\CreateUserRequest

which will make the request file in the Requests\Auth folder

OR

php artisan make:request Auth/CreateUserRequest

0
source share

All Articles