Yii Framework Forum: What do you think about middleware approach? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

What do you think about middleware approach?

#1 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 14 March 2016 - 07:33 AM

Middlewares approach is used in Java web apps for years. After being adopted well in JavaScript server frameworks recently and acceptance of PSR-7 it starts its raise in PHP community.

https://mwop.net/blo...-and-psr-7.html

What do you think about it?
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,467
  • Joined: 10-October 10
  • Location:Denmark

Posted 17 March 2016 - 02:36 PM

Are there any good resources/articles/blog posts about this?

It sounds ... interesting
"Less noise - more signal"
0

#3 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,467
  • Joined: 10-October 10
  • Location:Denmark

Posted 17 March 2016 - 02:39 PM

If I got it right, Middleware is some closure-like thing that you can plug in to manipulate request and response objects.

Here is how it is implemented in Slim:
http://www.slimframe...middleware.html
"Less noise - more signal"
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 17 March 2016 - 04:11 PM

Yes, you got it right. It's a bare thing which is getting request and response references and could do something with these. $next thing for passing processing to other middlewares. It could be read as $allOtherMiddlewaresDoSomethingWith($request, $response).
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
1

#5 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,467
  • Joined: 10-October 10
  • Location:Denmark

Posted 17 March 2016 - 04:37 PM

This would mean that the people who prefer the Laravel approach (Slim, Express.js, etc.) to routing could just plug in their favorite routing middleware and have the cake while eating it :)
Provided that the middleware follows the PSR-7.
That sounds nice. ;)
"Less noise - more signal"
0

#6 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 18 March 2016 - 05:07 AM

Well, Laravel approach is alike but isn't compatible with everything else. Slim and Expressive are.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

#7 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 15 June 2016 - 06:46 AM

https://philsturgeon...php-middleware/
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

#8 User is offline   Zorobabel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 03-January 16

Posted 29 August 2016 - 08:41 AM

Hey guys, just to share some info: Laravel is not MVC framework anymore.

https://twitter.com/...388365752692736

Middleware approach is interesting, I used it in a Node.js app, but need to analyze its true benefits.
0

#9 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 30 August 2016 - 03:40 AM

It still is if we're talking about what's called MVC by most of the web frameworks.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

#10 User is offline   Zorobabel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 03-January 16

Posted 30 August 2016 - 12:53 PM

View Postsamdark, on 30 August 2016 - 03:40 AM, said:

It still is if we're talking about what's called MVC by most of the web frameworks.


Yes. I meant: The don't consider "MVC" guys anymore.
0

#11 User is offline   Zorobabel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 03-January 16

Posted 30 August 2016 - 12:56 PM

If you are instered, I found this beautiful framework that uses this approach:

Feathers

Have a nice day.

PD: Yii is so beautiful :)
0

#12 User is offline   katz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 17-June 11

Posted 02 December 2016 - 03:16 AM

I've been using middlewares (mostly for APIs), there are cons and pros, but overall, our team love the middleware approach. It makes development more simple and transparent
0

#13 User is offline   arleigh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 04-December 16

Posted 05 December 2016 - 08:34 AM

I think it would be cool to see a middleware yii extension as an alternative routing system
0

#14 User is offline   Evanguicy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-March 17
  • Location:Szczecin

Posted 27 March 2017 - 01:33 AM

Hi Alex I would love to check it but the website is not working. Did you deleted it or you have some hosting problems atm? Cheers
0

#15 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 27 March 2017 - 06:42 AM

Works for me.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users