php artisan controller:make API\UserController
, generates controllers\APIUserController.php
, instead op controllers\API\UserController.php
.
And instead of
class APIUserController extends BaseController {
it should be
namespace API;
class UserController extends \BaseController {
Wouldn't it make sense to use the namespace? Or perhaps an option like php artisan controller:make UserController --namespace=API
(but that seems unnecessary verbose)
I just tried this out, am I doing something wrong?
php artisan make:controller \Api\Admin\UserController
produced ApiAdminUserController.php
so I tried:
php artisan make:controller \\Api\\Admin\\UserController
, which created the right directories, but the namespace was malformed namespace App\Http\Controllers\\Api\Admin;
My base controller namespace in RouteServiceProvider.php
looks like this: protected $namespace = 'App\Http\Controllers';
EDIT: nevermind.. it's correct, I had a leading \\
in the namespace when I generated the controller indicating the root; makes sense
I have the same problem
@jmarcher try php artisan make:controller Api\\Admin\\UserController
@amitailanciano thanks, works like a charm!
I use php artisan make:controller Api/Admin/UserController
, it works, too.
If you type \
in your shell, shell will try to escape \
, i.e.
echo Api\Admin\UserController
will actually print ApiAdminUserController
This is a non-issue related to laravel
Most helpful comment
I use
php artisan make:controller Api/Admin/UserController
, it works, too.If you type
\
in your shell, shell will try to escape\
, i.e.echo Api\Admin\UserController
will actually printApiAdminUserController
This is a non-issue related to laravel