-
-
Notifications
You must be signed in to change notification settings - Fork 331
Vanilla - added generic PSR-compatible middleware #689
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
Conversation
|
@UlrichEckhardt @DominicDetta Please check this PR out and let me know what you think about my take on this feature. |
UlrichEckhardt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looked at the code a bit, so I haven't tried it yet, but that's now on my list for today. Here are a few remarks up front already.
…e and PSR support.
|
Thanks for the review, everything should be fixed now. |
|
An example Slim project is now also available here - https://github.com/underground-works/clockwork-examples/tree/master/Integrations/Slim#readme |
|
Good morning! I've been toying around with this a bit and found a few more issues:
That said, I personally find the implementation increasingly hard to follow. In particular the duality with the implementation switching between PSR and globals is making this difficult. Maybe making this a configuration flag which is set in the constructor would help a bit, splitting it into separate classes would be my preferred choice though, but that's a major change. One aspect of this is also that the core Just to prevent misunderstandings, I think this adds value and that it doesn't cause any regressions, so I'd be favorable to merging it, despite previous criticisms! Uli |
|
Just updated my demo repository:
The reason I'm mentioning this is that both of these have PHPUnit tests included, which check whether the demo API, the Clockwork API and the Clockwork web UI works. The tests there differ also a bit because of my uncertainty about where the web UI is supposed to be located URL-wise. Cheers! :) |
|
Thanks for the feedback! Yes, I assume in the examples, that the enable behavior is already changed. That will be done in a separate PR though. Oops, the default setting for the web UI assets public path was one level off, so they were not actually copied to the public dir as they were supposed to. This should be resolved in the latest commit. So let me try to explain how the paths work (and good thing you've mentioned this, because I've realised we are missing a bit of the implementation here):
I kind of agree the Vanilla helper class is starting to get a little bit complicated and might be a good candidate for a rework at some point. I'm currently assuming a 5.x release for this feature, so I didn't want to do any big changes at this time. I especially don't like that part, where the response factory gets randomly passed as a third argument to the |
|
Heya! Let's merge this, and then make it better. It definitely adds value already, so there is no point in holding it back. Concerning the things to improve, the web UI isn't working out of the box for me yet. Key to this is actually documented: "Path where to install the Web UI assets, should be publicly accessible". For me, this is not the case since I route every request through my Slim stack. Yes, for e.g. Nginx, you can tell it to just serve the file if it exists and is not a Let's get this moving! Uli |
|
That last changes looks fine, too. Let's merge this! |
php-http/discoveryhas to be installed for zero-configuration use.Example use in a Slim application:
With the
php-http/discoverypackage installed, the response factory will be auto-detected (if one is installed), making the initialization as simple as:You can also instantiate the middleware with a custom Clockwork instance (useful if you want to register the instance with a DI container for example) and disable routing if you want to set it up on your own:
Note, because the Slim skeleton project registers the routing middleware as the last (outermost) middleware, you will need to add Clockwork middleware in
public/index.phpjust before the$app->handle()call, instead ofapp/middleware.php.