i'm new to symfony framework.I've installed it by following the tutorial in the official documentation Setup.And i've created a new project with the following commande symfony new portfolio2 --full, i ran the commande symfony server:start and every think was as suspected a default page showed up with the header * Welcome to Symfony 4.4.13 .....*.I faced the problem when i was triying to create my first page by following the official documentation Create your First Page in Symfony.
I've configured the routes.yml file:
#index:# path: /# controller: App\Controller\DefaultController::index# config/routes.yaml# the "app_lucky_number" route name is not important yetapp_lucky_number: path: /lucky/number controller: App\Controller\LuckyController::number
i've added the LuckyController.php
<?php// src/Controller/LuckyController.phpnamespace App\Controller;use Symfony\Component\HttpFoundation\Response;class LuckyController{ public function number() { $number = random_int(0, 100); return new Response('<html><body>Lucky number: '.$number.'</body></html>' ); }}
but when i run the server and try to access http://localhost:8000/lucky/number, the following TypeError is shown
Argument 1 passed toSensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry or null, instance of Doctrine\Bundle\DoctrineBundle\Registry given, called in F:\projects\portfolio2\var\cache\dev\ContainerEnYgzlJ\srcApp_KernelDevDebugContainer.php on line 4306
TypeError
in F:\projects\portfolio2\vendor\sensio\framework-extra-bundle\src\Request\ParamConverter\DoctrineParamConverter.php (line 46)
41 /** 42 * @var array 43 */44 private $defaultOptions; 45 46 public function __construct(ManagerRegistry $registry = null, ExpressionLanguage $expressionLanguage = null, array $options = []) 47 { 48 $this->registry = $registry; 49 $this->language = $expressionLanguage; 5051 $defaultValues = [
i did exactly what the documentation says, also i tried to clear the var\cache but it didn't work.
i'm using PHP 7.2.4, symfony 4.4 and here is my composer.json:
{"type": "project","license": "proprietary","require": {"php": ">=7.1.3","ext-ctype": "*","ext-iconv": "*","composer/package-versions-deprecated": "^1.11","doctrine/annotations": "^1.0","doctrine/doctrine-bundle": "^2.1","doctrine/doctrine-migrations-bundle": "^3.0","doctrine/orm": "^2.7","phpdocumentor/reflection-docblock": "^5.2","sensio/framework-extra-bundle": "^5.1","symfony/asset": "4.4.*","symfony/console": "4.4.*","symfony/dotenv": "4.4.*","symfony/expression-language": "4.4.*","symfony/flex": "^1.3.1","symfony/form": "4.4.*","symfony/framework-bundle": "4.4.*","symfony/http-client": "4.4.*","symfony/intl": "4.4.*","symfony/mailer": "4.4.*","symfony/monolog-bundle": "^3.1","symfony/process": "4.4.*","symfony/property-access": "4.4.*","symfony/property-info": "4.4.*","symfony/security-bundle": "4.4.*","symfony/serializer": "4.4.*","symfony/translation": "4.4.*","symfony/twig-bundle": "4.4.*","symfony/validator": "4.4.*","symfony/web-link": "4.4.*","symfony/yaml": "4.4.*","twig/extra-bundle": "^2.12|^3.0","twig/twig": "^2.12|^3.0" },"require-dev": {"symfony/browser-kit": "^4.4","symfony/css-selector": "^4.4","symfony/debug-bundle": "^4.4","symfony/maker-bundle": "^1.0","symfony/phpunit-bridge": "^5.1","symfony/var-dumper": "^4.4" },"config": {"preferred-install": {"*": "dist" },"sort-packages": true },"autoload": {"psr-4": {"App\\": "src/" } },"autoload-dev": {"psr-4": {"App\\Tests\\": "tests/" } },"replace": {"paragonie/random_compat": "2.*","symfony/polyfill-ctype": "*","symfony/polyfill-iconv": "*","symfony/polyfill-php71": "*","symfony/polyfill-php70": "*","symfony/polyfill-php56": "*" },"scripts": {"auto-scripts": {"cache:clear": "symfony-cmd","assets:install %PUBLIC_DIR%": "symfony-cmd" },"post-install-cmd": ["@auto-scripts" ],"post-update-cmd": ["@auto-scripts" ] },"conflict": {"symfony/symfony": "*" },"extra": {"symfony": {"allow-contrib": false,"require": "4.4.*" } }}
Can you help me fix this issue? (if it possible with details about what causes the problem)
And thank you in advance.