Welcome Guest, Not a member yet? Register   Sign In
Controller Filters - Input needed
#6

(07-07-2016, 09:39 PM)kilishan Wrote: It does seem be very similar to what you're asking for.

To play devil's advocate for a moment - is this necessary?

For one thing, it makes things a little more implicit by taking the control and logic away from anything the user sees if they dive in and look at the routes and controller files. Which, in turn, makes it a little more difficult to learn the framework for new users. The thing that would be done in it's place is what we've all done in the past - simply call a check explicitly in our controllers. Now, it's a little more work to manage, true, but diving into the controller we know exactly what's going on.

Is there possibly a solution that keeps it relatively explicit, but still helps solve the problem?

That's the million dollar question Smile. All frameworks nowadays are trying simplify problems like these. It's just going to depend on where the CI council decides to go with it.

Is it necessary? No. In essence, you can just extend your base controller and add all the functionality in there. But again, neither is a validation library, query builder, cache driver as you can code them on your own. At the end of the day, I'm just a developer trying to find the easiest tool to use to get a project going quickly and in a clean and organized manner. The first time I ran into filters in Rails, I thought it was great and it cleaned up my code compared to my very early CI days. Then I saw php middleware and thought it was a massive upgrade in terms of ease of use, readability, and most importantly maintainability.

When building my projects with my devs, one of the criteria I use to decide design philosophies is how much code needs to be written to get it going, and how much code needs to be rewritten to change some functionality. With controller filters, I may have to change 50+ controllers to add or remove a filter, and that's without worrying about :before, :after. With a single filters file, I may have to change 1 line.
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


Messages In This Thread
Controller Filters - Input needed - by kilishan - 07-07-2016, 08:39 PM
RE: Controller Filters - Input needed - by arma7x - 07-10-2016, 06:46 AM
RE: Controller Filters - Input needed - by arma7x - 07-07-2016, 09:14 PM
RE: Controller Filters - Input needed - by albertleao - 07-07-2016, 10:10 PM
RE: Controller Filters - Input needed - by arma7x - 07-10-2016, 11:42 PM
RE: Controller Filters - Input needed - by arma7x - 07-12-2016, 01:55 AM
RE: Controller Filters - Input needed - by arma7x - 07-13-2016, 12:23 AM
RE: Controller Filters - Input needed - by arma7x - 07-14-2016, 12:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB