Using a SLIM App under another SLIM App

Hi there,
I’m learning to build an App with SLIM. I can make simple stuff that works.
I understand that you can add middleware to your slim App. But can this middleware be another SLim App.
If not by using middlewares, Could a Slim App “launch” other Slim App ?
Hoping it makes sense !

But can this middleware be another SLim App.

Let’s say you hadn’t even said that :smiley:

Could a Slim App “launch” other Slim App ?

Try redirect within your controller. In case of some more sophisticated use case, create http client :slightly_smiling_face:

Hello there,

Thanks for your reply.

Well because a SLIM App consume a request and return a response. the idea to consider it as a middleware comes quickly ( like it was possible in other frameworks like ZEND ) Anyway i understand it looks like a bad idea. And in fact, i’ve never even said that …

I see the point. In fact we are working on refactoring an old web portal. The portal was an an homemade framework combined with a web site that helps building different applications and give the users access to it …
So the portal is an application that give access and “control” other applications. That’s why i was thinking that way . We have begin testing SLIM which looks interesting and flexible.
We are currently testing one instance to develop the portal and the applications. But it begin to look quite complicate and difficult to handle … Perhaps it could be easier and more flexible to make the applications independant and use one instance of SLIM for each of them …Then elaborate a collection of middleware for authentication, security, … etc … We could also build a simple website to facilitate user’s access to the application.
I don’t really know if all of this makes any sense ? Anyway, what would you do in a situation like this ? Any insights , indications are welcomed.
Thanks & greetings from France

So the portal is an application that give access and “control” other applications. That’s why i was thinking that way .

If you need a kind of portal/gate to another application so you certainly need an httpClient integrated within your application.
Among few PSR-7 packages that are proposed for Slim4 installation there is at least one that delivers out of the box a great proposition for that, meanning Guzzle (I don’t know neither Nyholm nor Laminas). It is very sophisticated as for a functionalities but with all of that just trivial to use.
I really recomend Guzzle.

Greetings from Belgium :slight_smile:

1 Like

Merci bien.
I will check this one and try to make it work …
Have a good day / Bonne journée

Hey ! I’ve just made a small stupid implementation with Guzzle between 2 SLIM Apps.

And guess what ? It’s working. That’s great.
I’ve learned something new. Thanks a lot :clap:

Told ya :smiley:. I am very happy for you.

Hello there,
We had an audio conf’ with the rest of the team ( more experienced DEV than me but also new to SLIM). Some of them choose another solution:
They instantiate anew SLIM App. Then they create root like this /NewApp/Controller/User and then in this controller they instantiate a new SLIM App ( called NewApp ).
It looks doable but would it be viable solution ?
Thanks / Good Day

Both application and “application” consumes the same request. So you should better do it modular.
You can always plant a tree within a tree, its doable, but have you ever met a gardener doing that?
BTW “more experienced” DEV’s are always right :wink: no matter what, get used to that.
Ok, let put the jokes away. IMHO it does not make any sense what they’re doing.

Well Thanks for your response and your pictorial example …
Don’t know if we got experienced gardener :seedling: but i see your point.

Let’s make it like a sondage ! Anyone reading this please briefly respond
" Does instantiating a new SLIM APP under a SLIM APP is"
:arrow_right: : An awesome idea depending on what you want to achieve ? …
:arrow_left: : A really strange idea that can lead to serious difficulties ? …