3

I am creating a controller in laravel inside one folder called Admin but it just creating AdminAdminContoller, using this command

artisan make:controller Admin\AdminController --resource

To to create folder Admin and then AdminController inside that folder ?

1
  • working fine on my local machine, just tested Commented Mar 29, 2018 at 11:08

3 Answers 3

11

You can try

php artisan make:controller Admin\\AdminController --resource

It will create the AdminController in Admin folder.

You can also use --plain or --resource to generate your desired Controller.

php artisan make:controller Admin\\AdminController --resource

The backslash (\) character is used to mark special characters so that they are not interpreted by the shell. so Adding another backslash (\) will escape the second backslash (\).

In some terminals below command can also work.

php artisan make:controller Admin/AdminController --resource

You can find more about backslash (\) here

Hope this helps

Sign up to request clarification or add additional context in comments.

2 Comments

Explanation: backslash is an escape character in quite some shells, so you need to escape it with another backslash. It should also work to put the path and filename in quotes, though: php artisan make:controller "Admin\AdminController"
One more interesting fact is that adding a single backslash (\) will not work on SO too.
2

You can use slash instead of the double backslash.

php artisan make:controller Admin/AdminController --resource

Comments

0

You can use the php artisan admin:make command to generate a controller for your 'Package' model in Laravel. Here's how:

Run the following command:

php artisan admin:make PackageController --model='App\Models\Package'

Note:

  1. admin:make is the command for generating admin panels in Laravel.
  2. PackageController is the name of the controller you want to create.
  3. --model='App\Models\Package' specifies the model class that the controller will be associated with.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.