Skip to content

Incorrect Usage of setParameter for RouterCollection in "Create Framework" Tutorial #20823

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

Closed
techware01 opened this issue Mar 25, 2025 · 0 comments · Fixed by #20928
Closed
Labels
hasPR A Pull Request has already been submitted for this issue. Routing

Comments

@techware01
Copy link

techware01 commented Mar 25, 2025

I am following the "Create Framework" tutorial, specifically the section on "The DependencyInjection Component." I encountered an issue with the following line of code:

$container->setParameter('routes', include __DIR__.'/../src/app.php');

This line attempts to set a RouterCollection as a parameter, which results in an error:

PHP Fatal error:  Uncaught TypeError: Symfony\Component\DependencyInjection\Container::setParameter(): Argument #2 ($value) must be of type UnitEnum|array|string|int|float|bool|null, Symfony\Component\Routing\RouteCollection given, called in /web/front.php

In my understanding as such this method of using routes in the DI container is not possible.

@xabbuh xabbuh added Routing hasPR A Pull Request has already been submitted for this issue. labels May 1, 2025
javiereguiluz added a commit that referenced this issue May 5, 2025
This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

Update Create Framework tutorial

I played [Create your own PHP Framework ](https://symfony.com/doc/current/create_framework/index.html) for #20823 issue, and found missing import or extra import

Commits
-------

56b6e31 Update Create Framework tutorial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue. Routing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants