// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^3.7", // v3.7.0
"doctrine/doctrine-bundle": "^2.7", // 2.7.0
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.12", // 2.12.3
"knplabs/knp-time-bundle": "^1.18", // v1.19.0
"pagerfanta/doctrine-orm-adapter": "^3.6", // v3.6.1
"pagerfanta/twig": "^3.6", // v3.6.1
"sensio/framework-extra-bundle": "^6.2", // v6.2.6
"stof/doctrine-extensions-bundle": "^1.7", // v1.7.0
"symfony/asset": "6.1.*", // v6.1.0
"symfony/console": "6.1.*", // v6.1.2
"symfony/dotenv": "6.1.*", // v6.1.0
"symfony/flex": "^2", // v2.4.5
"symfony/framework-bundle": "6.1.*", // v6.1.2
"symfony/http-client": "6.1.*", // v6.1.2
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/proxy-manager-bridge": "6.1.*", // v6.1.0
"symfony/runtime": "6.4.3", // v6.4.3
"symfony/twig-bundle": "6.1.*", // v6.1.1
"symfony/ux-turbo": "^2.0", // v2.3.0
"symfony/webpack-encore-bundle": "^1.13", // v1.15.1
"symfony/yaml": "6.1.*", // v6.1.2
"twig/extra-bundle": "^2.12|^3.0", // v3.4.0
"twig/twig": "^2.12|^3.0" // v3.4.1
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.2
"symfony/debug-bundle": "6.1.*", // v6.1.0
"symfony/maker-bundle": "^1.41", // v1.44.0
"symfony/stopwatch": "6.1.*", // v6.1.0
"symfony/web-profiler-bundle": "6.1.*", // v6.1.2
"zenstruck/foundry": "^1.21" // v1.21.0
}
}
14 Comments
Slug behavior didn't work when I experimented in PHP 7, below is my code:
The config is:
`stof_doctrine_extensions:
Services.yaml config is:
`parameters:
services:
`
Error:
Controller "App\Controller\ProductController::show" requires the "$product" argument that could not be resolved. Cannot autowire argument $product of "App\Controller\ProductController::show()": it needs an instance of "App\Entity\Product" but this type has been excluded in "config/services.yaml".
Hey @sujal_k, the
slugfield of your entity needs to beuniquein order to work with the param converterCheers!
It's actually this that I found and because I was working in latest version of Symfony, so: https://symfony.com/blog/new-in-symfony-7-1-mapped-route-parameters
I found the same problem!
You can fix this like that, just add the following lines to the
config/packages/doctrine.yaml:In the latest versions of Symfony, that property will be
falseby default.Thanks! That worked for me.
Worked for me. Thanks Jared
Symfony v7.1.5
Symfony CLI v5.10.2
PHP v8.3.12
Hey @Jared
In the docs it says that config is enabled by default. https://symfony.com/doc/current/doctrine.html#automatically-fetching-objects-entityvalueresolver
Cheers!
Yeah, but in this case you will get a doctrine deprecation message. Moreover, without these lines you will get an error as it said above.
Didn't know about the deprecation message.
Are you sure about the error? What I understand from the docs is that that behavior is enabled by default
doctrine.orm.controller_resolver.auto_mapping: trueauto_mapping was disabled by default in my 7.1 install as well :-/
That's interesting. It seems like the documentation is wrong
Yeah, I am sure. After adding these lines, the deprecation message and the error are gone.
I have removed the db, recreated it but now I got the following error when
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Le champ 'slug' ne peut être vide (null)
Here is the content of the VinylMix for the slug file:
Ok. I found the problem, the library was not automatically uploaded
use Gedmo\Mapping\Annotation\Slug;
Hey Benoit-L,
It seems like the Sluggable behavior does not work for that field. It might be for many reasons. First of all, check that you have used the correct namespace above the entity class, there should be
use Gedmo\Mapping\Annotation\Slug;line in the use statements. Also, make sure you enabled the sluggable extension, see this code block: https://symfonycasts.com/screencast/symfony-doctrine/sluggable#codeblock-35894f3389 . And finally, make sure you clear the cache just in case, it might be a simple cache issue :)Cheers!
"Houston: no signs of life"
Start the conversation!