Welcome Guest, Not a member yet? Register   Sign In
Controller Suffix
#11

Thanks, and you are right, I have never worked in a larger team. I can also see now the benefits of freeing up controllers from url's and having a map of the entire application.

Thanks again,

Paul.
Reply
#12

(This post was last modified: 08-15-2016, 07:46 AM by spjonez.)

ivantcholakov Wrote:Time ago I have taken a solution from here: http://code.tutsplus.com/tutorials/6-cod...--net-8308
But this must be adapted carefully for CodeIgniter 3.

This method works well we've been using it for a while. My addon Cinder uses it as well. Instead of manually defining all routes you overload the router methods and append '_controller' to the path it uses to load a controller.

I haven't updated this repo in a long time but here's an example: https://github.com/monsterlane/codeignit...Router.php

You should be able to start with that and update it by comparing your version of CI's system/core/Router.php with the methods defined in that file for any changes other than the suffix stuff.
Reply
#13

(08-15-2016, 03:00 AM)PaulD Wrote: Thanks, and you are right, I have never worked in a larger team. I can also see now the benefits of freeing up controllers from url's and having a map of the entire application.

Thanks again,

Paul.

No problem. 

One great thing for you to do as practice is build a basic 'blog' or 'todo list' in other languages and/or frameworks. I would focus on frameworks that are highly opinionated. It will give you a perspective of how other people are doing things and how you can maybe implement some of those things into your application. That was the greatest learning experience for myself.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#14

I like magic routing for testing but I don't like the idea of allowing controller direct access.

That's why we decided to build an admin module that regenerates routes.php file from what is defined in the database. This way we only allow certain routes and we block the others with 404.

I am still not sure if this is the best way but it seems very pratical so far.
Reply
#15

(08-15-2016, 12:14 PM)Ivo Miranda Wrote: I like magic routing for testing but I don't like the idea of allowing controller direct access.

That's why we decided to build an admin module that regenerates routes.php file from what is defined in the database. This way we only allow certain routes and we block the others with 404.

I am still not sure if this is the best way but it seems very pratical so far.

That's an interesting take on it and I see the benefits if you have non-technical people working with you that need to have the ability to shut off endpoints and so on. Unfortunately, until CI4.0 rolls around, users can still access anything not in your routes.php by just figuring out the controller name.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB