Skip to content
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

Remove container #2290

Merged
merged 4 commits into from Nov 3, 2017

Conversation

Projects
None yet
10 participants
@akrabat
Copy link
Member

commented Aug 13, 2017

Container is now completely optional. App now creates its own request and response in run() and the rest of the objects in DefaultServicesProvider were already defined within App.

Also removed the magic __call method on App that allows access to the container as there's no need for it.

Note that Pimple is a dev dependency for testing routing, CallableResolver and DeferredCallable.

AppTest has also been tidied a little.

@akrabat akrabat added the Slim 4 label Aug 13, 2017

@akrabat akrabat requested review from codeguy, silentworks and geggleto Aug 13, 2017

@akrabat akrabat force-pushed the akrabat:remove-container branch from 6716f8f to b12b87d Aug 13, 2017

@akrabat akrabat referenced this pull request Aug 13, 2017

Closed

Simplify container usage #2289

@coveralls

This comment has been minimized.

Copy link

commented Aug 13, 2017

Coverage Status

Coverage increased (+1.8%) to 94.798% when pulling b12b87d on akrabat:remove-container into ee32eb6 on slimphp:4.x.

@coveralls

This comment has been minimized.

Copy link

commented Aug 13, 2017

Coverage Status

Coverage increased (+1.8%) to 94.798% when pulling b12b87d on akrabat:remove-container into ee32eb6 on slimphp:4.x.

@coveralls

This comment has been minimized.

Copy link

commented Aug 13, 2017

Coverage Status

Coverage increased (+1.8%) to 94.798% when pulling 1a7e068 on akrabat:remove-container into ee32eb6 on slimphp:4.x.

@akrabat akrabat force-pushed the akrabat:remove-container branch from 1a7e068 to 0706f07 Aug 13, 2017

@coveralls

This comment has been minimized.

Copy link

commented Aug 13, 2017

Coverage Status

Coverage increased (+1.8%) to 94.798% when pulling 0706f07 on akrabat:remove-container into ee32eb6 on slimphp:4.x.

@akrabat

This comment has been minimized.

Copy link
Member Author

commented Aug 13, 2017

Ping @mnapoli, @geekish, @moufmouf for thoughts as you showed interest in the original issue about this.

Key thing is that Slim no longer has any concept of default services in the container. i.e. the container is just for the user's code.

@moufmouf

This comment has been minimized.

Copy link

commented Aug 13, 2017

It makes complete sense to me. 👍

@mnapoli

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2017

That's good news!

and the rest of the objects in DefaultServicesProvider were already defined within App.

I'm not sure I understand this part: can "core" services of Slim still be overridden? Is Slim doing something like $router = $container->has('router') ? $container->get('router') : $this->buildDefaultRouter() ? (this is pseudo-code)

@Sam-Burns

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2017

I'd suggest pinning to Pimple 3.1 in dev at a minimum, to try and fix the Travis warning.

@coveralls

This comment has been minimized.

Copy link

commented Aug 14, 2017

Coverage Status

Coverage increased (+1.8%) to 94.798% when pulling 8c295e3 on akrabat:remove-container into ee32eb6 on slimphp:4.x.

@coveralls

This comment has been minimized.

Copy link

commented Aug 14, 2017

Coverage Status

Coverage increased (+1.8%) to 94.798% when pulling 0b16b20 on akrabat:remove-container into ee32eb6 on slimphp:4.x.

@akrabat

This comment has been minimized.

Copy link
Member Author

commented Aug 14, 2017

and the rest of the objects in DefaultServicesProvider were already defined within App.

I'm not sure I understand this part: can "core" services of Slim still be overridden? Is Slim doing something like $router = $container->has('router') ? $container->get('router') : $this->buildDefaultRouter() ? (this is pseudo-code)

The App has methods like: set/getRouter(), set/getNotFoundHandler() etc.

@mnapoli

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2017

@akrabat OK so a question that's maybe a bit out of scope here but just to get it right: when using a container it might make sense to let the container create the "Application" class (the container would call setRouter(), etc. with the correct dependencies)?

@akrabat

This comment has been minimized.

Copy link
Member Author

commented Aug 14, 2017

OK so a question that's maybe a bit out of scope here but just to get it right: when using a container it might make sense to let the container create the "Application" class (the container would call setRouter(), etc. with the correct dependencies)?

@mnapoli Yes. If you need to customise the App's dependencies, then letting the app, then letting the container create the App object would probably make sense.

@mnapoli

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2017

Awesome great then!

@mnapoli mnapoli referenced this pull request Aug 14, 2017

Open

Slim 4 support #22

@bnf

This comment has been minimized.

Copy link
Contributor

commented Aug 16, 2017

Slim\Collection and Slim\Interfaces\CollectionInterface seem to be unused with this change applied. May those be removed as well?

@geggleto

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2017

@akrabat this PR needs to be rebased.

@akrabat akrabat referenced this pull request Sep 24, 2017

Closed

Delete obsolete option #2304

akrabat added some commits Aug 13, 2017

Remove InvalidMethodException
It's not used as process() catches everything.
Remove Container
Container is now completely optional. App now creates its own request
and response in `run()` and the rest of the objects in
`DefaultServicesProvider` were already defined within `App`.

Also removed the magic `__call` method on `App` that allows access to
the container as there's no need for it.

Note that Pimple is a dev dependency for testing routing,
`CallableResolver` and `DeferredCallable`.

AppTest has also been tidied a little.

Closes #2288

@akrabat akrabat force-pushed the akrabat:remove-container branch from 0b16b20 to 4d3f342 Nov 3, 2017

@akrabat

This comment has been minimized.

Copy link
Member Author

commented Nov 3, 2017

Rebased to tip of 4.x

Removed Collection and CollectionInterface
These were only being used by Container which is now gone.
@akrabat

This comment has been minimized.

Copy link
Member Author

commented Nov 3, 2017

Slim\Collection and Slim\Interfaces\CollectionInterface seem to be unused with this change applied. May those be removed as well?

Yes, you're right @bnf. I've removed them.
Thanks!

@coveralls

This comment has been minimized.

Copy link

commented Nov 3, 2017

Coverage Status

Coverage increased (+1.9%) to 94.872% when pulling 8385ca7 on akrabat:remove-container into 0dab1d1 on slimphp:4.x.

@silentworks silentworks merged commit 6e1d776 into slimphp:4.x Nov 3, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+1.9%) to 94.872%
Details
@ViAndersson

This comment has been minimized.

Copy link

commented on 8385ca7 Nov 20, 2017

Wasn't this used by the Headers & Environment classes? Or is the entire PSR7 implementation going to be remade in 4.x?

This comment has been minimized.

Copy link
Member Author

replied Nov 20, 2017

Wasn't this used by the Headers & Environment classes? Or is the entire PSR7 implementation going to be remade in 4.x?

4.x uses Slim\Http

@akrabat akrabat added this to the 4.0 milestone Nov 26, 2017

@filips123

This comment has been minimized.

Copy link

commented Oct 19, 2018

How can we now use dependency injection for tools like Monolog?

@akrabat

This comment has been minimized.

Copy link
Member Author

commented Oct 19, 2018

How can we now use dependency injection for tools like Monolog?

Slim 4 accepts provision of your own PSR-11 compatible container and will use it to resolve actions, etc. Hence you now have more flexibility and can bring your choice of container to your Slim project.

@filips123

This comment has been minimized.

Copy link

commented Oct 19, 2018

@akrabat So I could set my own container, include dependencies (like Monolog) into it, and then access dependencies with $app->container->dependency?

This could be in the documentation for v4.

@akrabat

This comment has been minimized.

Copy link
Member Author

commented Oct 19, 2018

Technically, you'd have to pass your container into your action's constructor to have a $this->container available, but that's the general idea.

Docs for v4 are barely started.

@akrabat akrabat deleted the akrabat:remove-container branch Apr 18, 2019

@l0gicgate l0gicgate referenced this pull request Apr 25, 2019

Merged

Slim 4 Alpha Release #2665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.