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

Slim 4 support #22

Closed
SergeAx opened this issue Jul 22, 2017 · 12 comments · Fixed by #47
Closed

Slim 4 support #22

SergeAx opened this issue Jul 22, 2017 · 12 comments · Fixed by #47

Comments

@SergeAx
Copy link

SergeAx commented Jul 22, 2017

Hello! Thank you for great project, I'm using it extensively and having a lot of fun an delight with all theese autowirings and nice config)

There is work in progress for Slim 4 for more than half a year:

https://github.com/slimphp/Slim/tree/4.x

Slim is going to keep it's honor of most interchangeble framework in PHP universe. PHP-DI\Slim-Bridge should definitely support new version, so I forked this repo and started to hack something together:

https://github.com/SergeAx/Slim-Bridge/tree/dev-4x

Alas. I stumbled upon nasty error about 'calling non-static method statically':

https://travis-ci.org/SergeAx/Slim-Bridge/jobs/256378905

Maybe someone here more familiar with PHP-DI and Slim-Bridge can easily point out an error?

@mnapoli
Copy link
Member

mnapoli commented Jul 23, 2017

Hi @SergeAx, thanks for the kind words!

Supporting Slim 4 is definitely planned, thanks for getting the work started. Your branch looks fine, however the problem with that test is, I believe, that the callableResolver is not used anymore.

Maybe Slim 4 changed how callable are resolved?

@SergeAx
Copy link
Author

SergeAx commented Jul 23, 2017

If you check Travis log you'll see the error is in src/ControllerInvoker.php:32. Curiously, line 32 is just an __invoke method declaration. It is also weird that PHPStorm debugger is unable to step into this call from here:

$routeResponse = $handler($callable, $request, $response, $this->arguments);

(Slim\Route.php:327)

$handler is DI\Bridge\Slim\ControllerInvoker and $callable is array('DI\Bridge\Slim\Test\Fixture\UserController', 'dashboard'), so everything looks solid, but somehow it's not.

The only explanation I have is that PHP is trying to cast array(2) to callable and fails because an object is not instantiated? But this worked fine with Slim 3, and Slim\Interfaces\InvocationStrategyInterface haven't changed since.

@SergeAx
Copy link
Author

SergeAx commented Jul 23, 2017

Sorry for posting too soon. You were right: Slim\Router weren't using callableResolver from container. After force set it via setCallableResolver() last test passed. You'll have PR in a minute, upstream branch name is up to you, dev-4x is first thing came to me.

@SergeAx SergeAx mentioned this issue Jul 23, 2017
@mnapoli
Copy link
Member

mnapoli commented Aug 1, 2017

Nice thanks!

@mnapoli
Copy link
Member

mnapoli commented Aug 14, 2017

Here is more information for Slim 4, they are planning to remove completely their container: slimphp/Slim#2290 (comment)

@mnapoli
Copy link
Member

mnapoli commented Nov 4, 2017

The PR has been merged, it seems that one course of action in this bridge would be to let PHP-DI create the Slim Application class. I haven't studied the details to see if it's the best yet.

@killua-eu
Copy link

Hey all, any news on the Slim 4 compatibility? Thanks!

@ghost
Copy link

ghost commented Aug 4, 2019

Bump, would also like to know if this is still happening.

@mnapoli
Copy link
Member

mnapoli commented Aug 4, 2019

Given the discussion at slimphp/Slim#2770 yes I think there would be value in writing a bridge that ports the current features.

I have no ETA at the moment, but I use both projects quite often so once I get my hands on Slim 4 I may get started.

@SergeAx
Copy link
Author

SergeAx commented Aug 4, 2019

Looks like https://github.com/slimphp/Slim-Skeleton for Slim 4 incorporated PHP-DI as a ЗЫК-compatible component, so we basically don't need slim-bridge for it anymore, right?

@mnapoli
Copy link
Member

mnapoli commented Aug 4, 2019

You might want it if you want to keep some features, for example auto-injecting services and parameters in controller parameters.

@fritsvt fritsvt mentioned this issue Aug 5, 2019
@mnapoli mnapoli mentioned this issue Aug 5, 2019
2 tasks
@mnapoli
Copy link
Member

mnapoli commented Aug 10, 2019

Current progress: #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants