Framework: Artisan call make:controller wrong path

Created on 23 Sep 2016  路  11Comments  路  Source: laravel/framework

  • Laravel Version: 5.3.10
  • PHP Version: 5.6.20
  • Database Driver & Version: redis

    Description:

Today I try to create App namespace under controllers.
Type in console php artisan make:controller App\AppController and get success message.

After I searching the controller I see that AppController is actually in App namespace in the same place where is Models not in App\Http\Controllers\App\.

C:\git\app>php artisan make:controller App\Http\Controllers\App\AppController
Controller created successfully.

C:\git\app>php artisan make:controller App\Http\Controllers\App\App\AppController
Controller already exists!

C:\git\app>php artisan make:controller App\Http\Controllers\App\App\App\App\AppController
Controller already exists!

The controllers Are in App\Http\Controllers\AppController.php
With namespace App\Http\Controllers\App;

Most helpful comment

@maki10 This is not an error with the framework itself. It is how you are creating your controllers. Also the code you referred in this link refers to namespace not path.

All 11 comments

Use should use double back-slash instead of single. Change \ to \\

php artisan make:controller App\\AppController

@nammaianh No, that doesn't work either...

Oh, sorry! Didn't see that you are using Windows

How about using double quote?

php artisan make:controller "App\AppController"

@nammaianh Same, making the controller under App namespace

I think mr. Otwell wanna do this if the controller start with App namespace

I still think this is an issue because we know where are our controllers Namespace is.

@nammaianh if Otwell wanna do this how to explain this php artisan make:controller App\Http\Controllers\App\AppController make controller in controllers namespace without folder App and giving namespace App\Http\Controllers\App

@nammaianh you can see that wish path is \Http\Controllers in this link
So this is an issue..

@maki10 This is not an error with the framework itself. It is how you are creating your controllers. Also the code you referred in this link refers to namespace not path.

@srmklive +1 my bad,
@themsaid For your pull request still not working php artisan make:controller App\AppController, but working with php artisan make:controller App\Http\Controllers\App\AppController

https://github.com/laravel/framework/pull/15575
Fixed in PR. In order to create controller under App\Http\Controllers\ in folder and namespace App, must be provide full path to controller in my case App\Http\Controllers\App\AppController

Was this page helpful?
0 / 5 - 0 ratings