Laravel how to add subfolders and controllers to Controllers

Source: Internet
Author: User

First, create an admin folder in the controllers folder.

Method 1: directly create a controller in the background. For example, we can normally write our contents in admincontroller. php.

In the routing table,

Route: Get ('admin', '[email protected]');

We found that the Program reported an error, saying that the controller admincontroller could not be found.

Open the command line tool and go to the directory where the project is located, that is, artisan and composer. JSON,

Run the command composer dumpautoload or composer dump-autoload.

This is to optimize automatic loading.

After running the command, go to the composer directory in the vendor directory,

Let's take a look at our autoload_classmap.php file and find that there is an additional admincontroller record.

By the way, refresh the browser to see the content of the background controller.

However, this disadvantage is that you must run this command every time you add a new controller ..

Laravel how to add subfolders and controllers to Controllers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.