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

Fix DI problem with Laravel 10 - add names for parameters for container #51

Merged

Conversation

nepda
Copy link
Contributor

@nepda nepda commented Oct 10, 2023

As described in #50, we had problems to parse geo JSON with Laravel 10.

The documentation about the make method says:

If some of your class's dependencies are not resolvable via the container, you may inject them by passing them as an associative array into the makeWith method.

Therefore, I changed the two code parts and adjusted the tests accordingly.

I allowed myself to migrate the PHPUnit configuration file as well.

@jimmypuckett
Copy link
Member

@nepda Thanks for this PR. We don't currently have a project that uses this code, so we don't interact with it much. I need a better way of testing what you have sent in. Can you expand on some of the tests or explain what you are doing with these changes so we can merge them?

Sorry for the delay.

@nepda
Copy link
Contributor Author

nepda commented Dec 4, 2023

Hi @jimmypuckett thanks for the reply!

Actually, the tests are failing if we don't use associative arrays for the service creation in the two files:

  • src/GeometryServiceProvider.php:32
  • src/Geometry.php:129

Because Laravel doesn't know how to resolve the parameters $geometry and $mapper to instances of \geoPHP and \Spinen\Geometry\Support\TypeMapper.

In my first comment, I quoted the Laravel documentation without a source, sorry for that. Here it is:

https://laravel.com/docs/10.x/container#the-make-method

I hope this clarifies why and what I've changed? If you need something else, please let me know.

@Antonin-netalis
Copy link

I can confirm using this branch fixed our problems upgrading an old project to laravel 10, thanks

@jimmypuckett jimmypuckett merged commit 20741ce into spinen:develop Apr 8, 2024
1 of 5 checks passed
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 this pull request may close these issues.

3 participants