Laravel 5: Create controller under new folder and routing

So here I am on a Sunday, trying to make progress with a personal Laravel 5 site I need to work on. As I bear with the noise outside in the street (some crazy neighbors set up a swimming pool IN THE STREET! :oops:), I’m trying to figure out how too create a new Laravel 5 controller and place it inside a sub-folder.

Thanks to a StackOverflow answer as my guide, it’s now working. Here, I’ll share how I did it. Just replace “New” with whatever name you want.

First, create NewController.php on this folder: app\Http\Controllers\New\

Then the first part of the code should be like:

My call for the blade file in index() looks like this:

In app\Http\routes.php, add this:

$router->get(‘/new’, ‘New\PostsController@index’);

Last, run composer dump-autoload or php artisan dump

Guide: Laravel Controller Subfolder routing

Related Posts:

Posts that may be related to "Laravel 5: Create controller under new folder and routing":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *