Welcome Guest, Not a member yet? Register   Sign In
Will we have an alternative for "middleware" in CodeIgniter4?
#1

I'm eager to know if we will have a tool or a struct to give us the power of middleware.

By middleware I mean a tools like we have in Laravel.

It's very common to see is the user logged in or does he have enough permissions or not. If that's ok, execute the requested method but if not, show an error or redirect him to login page.

Thank you
Reply
#2

Since CI is just PHP, you have the option to write your own tools (recommended) or adapt PHP code from other sources to fit your needs (assuming it is free of copyright or for which you have legal permission to use).

I'm not saying "you're on your own" but I want to emphasize the freedom which the CI framework gives you. You are NOT required or limited by pre-written "middleware" which may be bundled with other frameworks. CI is deliberately written to be extensible and NOT bloated with many tools, most of which you may never need or use.

There are abundant resources offered by other CI developers of which you should take advantage.

Reading this forum, you will see many examples of the various tools. There are also a number of books (a HUGE number) on basic PHP and CI coding.

When you get to the point of having specific question on a particular tool, DO feel welcome to post your code and question in this forum. We have some very knowledgeable and patient people who will offer assistance. Please ignore the trolls, they seldom last very long when ignored.
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#3

It's interesting the people that think Laravel features should be the norm. Why not just use Laravel? For me, I've had a few Laravel experiences now, and I keep coming back to CI as my favorite framework. I don't want CIravel, if you know what I'm saying.
Reply
#4

Are you thinking something like https://bcit-ci.github.io/CodeIgniter4/g...lters.html ?

The subject of "middleware" has come up within the council, and disregarding the misuse of the term (at odds with enterprise development interpretation), the way "they" handle it is incompatible with our HTTP request implementation. The notion of request handler chaining is getting a bit of traction, though. All we need is time, lots of it!
Reply
#5

(04-02-2017, 12:40 PM)ciadmin Wrote: Are you thinking something like https://bcit-ci.github.io/CodeIgniter4/g...lters.html ?

The subject of "middleware" has come up within the council, and disregarding the misuse of the term (at odds with enterprise development interpretation), the way "they" handle it is incompatible with our HTTP request implementation. The notion of request handler chaining is getting a bit of traction, though. All we need is time, lots of it!

Perfect. You got it.

That was exactly what I was looking for.

It's clear that I can simply use Laravel like many others, but I thought that CI itself could answer such need (which is really general and not toooo specific).

Anyway I should thank you for your understanding of the new CI4 Smile
Reply
#6

(04-02-2017, 12:11 PM)skunkbad Wrote: It's interesting the people that think Laravel features should be the norm. Why not just use Laravel? For me, I've had a few Laravel experiences now, and I keep coming back to CI as my favorite framework. I don't want CIravel, if you know what I'm saying.

I love CI and I think it's really nice as it was my 1st MVC framework , but I really like having middlewares too , they are not a Laravel concept ,  you can find them in many other non PHP frameworks such as Express js , Flask and Django ( in Python) ,  it is a nice concept that makes your code clear and neat !
Reply
#7

(04-02-2017, 12:40 PM)ciadmin Wrote: Are you thinking something like https://bcit-ci.github.io/CodeIgniter4/g...lters.html ?

The subject of "middleware" has come up within the council, and disregarding the misuse of the term (at odds with enterprise development interpretation), the way "they" handle it is incompatible with our HTTP request implementation. The notion of request handler chaining is getting a bit of traction, though. All we need is time, lots of it!

the link is dead !
Reply
#8

(05-12-2021, 01:00 PM)nsm Wrote: the link is dead !

The post is 4 years old !

Info for filters in CI4 is here - https://www.codeigniter.com/user_guide/i...lters.html
Reply
#9

(05-13-2021, 06:54 AM)craig Wrote:
(05-12-2021, 01:00 PM)nsm Wrote: the link is dead !

The post is 4 years old !

Yeah, people can’t read and they keep reviving super old thread. It’s driving me crazy!  Dodgy
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#10

To be fair, "middleware" (in the Laravel sense) is really just any component that modifies or reacts to the HTTP layer between the Controller's processing of the request and the response. In this regard CodeIgniter has a lot of middleware already, we just don't call it that. `Filters` (linked above) is probably the most explicit version of what this original question was asking about. There are also tons of modules published by the community that add some additional "middleware" like authentication. Head over to he AddIns forum, or you can peruse some of my modules: https://github.com/tattersoftware/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB