D
D
den-masonov2017-01-27 15:05:07
Laravel
den-masonov, 2017-01-27 15:05:07

How to create a controller in a subfolder (Laravel)?

Hello)
I need to create a controller in the Admin folder.
And here is a command in the console php artisan make:controller Admin\AdminController creates a controller in the controllers folder called AdminAdminController.
I work for homestead. Everything works on the video. He has an open server.
Laravel version 5.2.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gennady, 2019-10-15
@GssGenic

In routes \ web.php , for example, create a route
And Create a Controller in the App\Http\Controllers\Wiki
subfolder Put the controller file

<?php

namespace App\Http\Controllers\Wiki;
use App\Http\Controllers\Controller;

class HomeController extends Controller
{
    public function __construct()
    { 
    
    }
  
   public function index()
    {
    // Your Code
    }
}

What are we looking at.
1. In the Route path to Specify the Subdirectory, use '\'
2. In the Controller, do not forget that when creating a Class, it Extends the Controller class, the file of which is in the previous folder, and it needs to be referenced use App\Http\Controllers\Controller

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question