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

Laravel 5 bindings not initialising on first request, subsequent requests okay. #3728

behinddesign opened this issue Nov 12, 2016 · 2 comments


Copy link

@behinddesign behinddesign commented Nov 12, 2016

Laravel 5 module isn't allowing the IoC bindings introduced in version 2.2.2 to be bound for the first request. I've tracked this down to the logic in the __construct / doRequest of Laravel5.php.

On construct it's initialised, during which the bindings are applied as part of initialise

This means that automatically, on the first request there can never be any bindings set at all due to this piece of code :

So to confirm, here's the flow of a typical test pseudo style

  • start the test
  • construct the l5 connector
  • apply the bindings via initilise (no binding set yet)
  • set singletons / binds etc in the test (binds are set but not applied)
  • run request against laravel (no bindings applied due to the firstRequest check)
  • change page
  • apply the bindings via initilise (bindings now applied)

After dumping some debug around the code :

Test: tests/functional/InitialLoadCest.php:tryToTestBindings
Scenario --
"construct l5 module"
" first request? 1"
"apply bindings"
 I have singleton "SomeInterface#000000006e01e7310000558df9aaf7e0"
"bind singleton" <=== No further apply bindings before request is made
 I am on route "design.index"

So for my work around to this I'll need to make a request to some page which doesn't require the IoC binding and then follow through with the proper requests.

Let me know if you need a test project supplied, however the logic for this issue is fairly straight forward unless I've missed something glaringly obvious.

Copy link

@janhenkgerritsen janhenkgerritsen commented Nov 14, 2016

There was a problem with the tests for this functionality that resulted in this issue going undetected. I fixed the tests and the issue itself.

Thanks for reporting this issue!

Copy link

@behinddesign behinddesign commented Nov 14, 2016

Thanks for the fix and keep up the good work! Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.