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

An odd human being who happens to have a variety of ever-changing interests, but right now they are programming, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert/drink flavors, obsessing about finding out how some things works, automation, anime, video games... Ran online dessert shops Cookies PH and Catzie's Cakery in her past life.

Leave a Reply

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