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 and baker. When I have time to spare, I blog, play video games, watch series (usually anime), cook dishes, draw, or spend a little time with pets. When I have the rare luxury of time, I get to travel and record song covers too! 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 *