-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controller Filters #150
Comments
Is there a thread we can discuss this on on the CI forum? I know I threw my 2 cents a couple of weeks ago when it came to route middleware on the forums, but having worked a lot with Rails with a larger dev team, the filtering system in controller quickly becomes a headache as compared to middleware functionality. I understand the point of view of 'We cannot simply do route middleware since CI does not restrict routes to be defined.', but the benefit of having all of your middleware/filters in one file is that it is easily definable and much easier to document and read as your application grows. Now I'm not going to pretend I'm an expert in building a framework, but would it be possible to have CI check the routes.php file even if automagical routing is on to check for middleware/filters? Or maybe have a separate filters file where you can input an array of controller/actions that will be associated with a filter of some sort? I'm just looking at my current use cases (3 CI 3.0 apps in production and 2 Laravel 5.2 in production) and the ease of use of being able to identify and modify my filters/middleware in one spot is what makes the psr7 middleware system such a breeze compared to my older rails apps where I had to make sure all my filters were correct in each controller, which can ended up giving me sever code anxiety when i had 3-4 devs working on project. In my current codeigniter apps, I find myself having multiple base controllers which I extend on depending on the functionality. This could become an nuisance when filters start cascading down controllers. |
Good points. There is a thread now where I've asked for input on it. |
Based on discussion in the forum, the description has been updated with current thoughts. |
Implemented and merged in 18aafdc |
Inspired by Rail's ActionController filters and PSR7's Middleware concepts, we should look into incorporating some form of actions that can be run before and after controller methods.
We cannot simply do route middleware since CI does not restrict routes to be defined. This makes the most sense in the CI world view - so don't ask. :)
Hooks may be able to work for this, though they have always been used in the past as a global way to interact with the hook points, but is worth considering.
*EDIT: BASED ON DISCUSSION IN THE FORUM (see thread below) I THINK WE'VE LANDED ON SOMETHING LIKE: *
Some refactors:
The text was updated successfully, but these errors were encountered: