Laravel 5 make:controller creating controller in app folder instead of controller folder

In Laravel 5, it is not required to specify the path. By default, it will generate the controller in the directory.

So, the controller can be created like this:

php artisan make:controller controllerName

However, if you would like to create it in a custom directory then refer to the line below:

php artisan make:controller pathName/controllerName

The controller can be created into specific path as followed:

php artisan make:controller controllerName

However, if you would like to create it in a custom directory then refer to the line below:

below will create on root path (outside app directory)

php artisan make:controller App\\../pathName/controllerName

If want inside app directory then it should be

php artisan make:controller App\\pathName/controllerName

Tested on Laravel 6.x


After trying php artisan make:controller Directory\PageController, Laravel 5.1 would create a controller named DirectoryPage Controller in my app directory. The solution for me was to escape the backslash with another backslash so the following worked for me:

php artisan make:controller Directory\\\\PageController

Laravel created a Pagecontroller in the app/Directory. Just thought I would share with everyone.