I'm new to Symfony and I'm creating a blog for personal use.
But when I try to add fields to an entity using the command php bin/console make:entity an error pops out.
Argument 2 passed to Symfony\Bundle\MakerBundle\Validator::validateDoctrineFieldName() must be an instance of
Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given, call
ed in C:\Users\user\Documents\CODING\Symfony\calidad\vendor\symfony\maker-bundle\src\Maker\MakeEntity.p
hp on line 303
I would gladly appreciate all of your help.
It lets me create an entity, but not adding fields.
Here I paste my composer.json:
"require": {
"php": ">=7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"sensio/framework-extra-bundle": "^5.6",
"symfony/asset": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/twig-bundle": "4.4.*",
"symfony/web-server-bundle": "4.4.*",
"symfony/yaml": "4.4.*",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"
},
"require-dev": {
"sensiolabs/security-checker": "^6.0",
"symfony/debug-bundle": "^4.4",
"symfony/maker-bundle": "^1.20",
"symfony/monolog-bundle": "^3.0",
"symfony/stopwatch": "^4.4",
"symfony/twig-bundle": "^4.4",
"symfony/var-dumper": "^4.4",
"symfony/web-profiler-bundle": "^4.4"
},
Thanks!
That's a bug in doctrine/doctrine-bundle v2.1.1 - make sure to have either the former version v2.1.0 or the later one, v2.1.2, installed.
This is due to incorrect information in the symfony composer configuration file
To solve the problem, re-enter this instruction after installing symfony.
This command solves your problem.
composer require symfony/maker-bundle --dev
Related
On any attempts to call "php bin/console make:entity" I get the following error:
In DoctrineHelper.php line 180:
Class "Doctrine\Persistence\Mapping\Driver\AnnotationDriver" does not exist
I checked vendor, and it appears there is no file called AnnotationDriver.php there but I'm unsure on how to proceed.
using the following:
"type": "project",
"license": "proprietary",
"require": {
"php": ">=7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"curl/curl": "^2.3",
"doctrine/annotations": "^1.13",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.11",
"easycorp/easyadmin-bundle": "*",
"friendsofsymfony/rest-bundle": "^3.3",
"guzzlehttp/guzzle": "^7.4",
"lcobucci/jwt": "*",
"nelmio/cors-bundle": "^2.2",
"phpdocumentor/reflection-docblock": "^5.3",
"sensio/framework-extra-bundle": "^6.2",
"symfony/asset": "*",
"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-foundation": "4.4.*",
"symfony/monolog-bundle": "^3.7",
"symfony/property-access": "4.4.*",
"symfony/property-info": "4.4.*",
"symfony/proxy-manager-bridge": "4.4.*",
"symfony/security-bundle": "4.4.*",
"symfony/serializer": "4.4.*",
"symfony/twig-bundle": "4.4.*",
"symfony/validator": "4.4.*",
"symfony/yaml": "4.4.*"
}
in my composer.json.
I tried upgrading and downgrading doctrine/orm but it didn't help.
I think you are the same person I just answered on symfony github discussion.
Here is my answer:
So I checked online for a similar issue and I found this.
You need to change your composer.json and downgrade your doctrine/orm to 2.11 until you migrate to symfony 5.4 because symfony 4.4 support has been dropped.
So modify your composer.json with:
"doctrine/orm": "^2.11",
And also:
"conflict": {
"symfony/symfony": "*",
"doctrine/orm": "2.12.0"
},
Don't forget to run composer update
In my Symfony/Sonata application's php.ini file, I have opcache.blacklist_filename set to /usr/src/app/config/opcache-exclude.txt. In a phpinfo() call on my test server, that file shows up in the correct place. Here is the content of the file:
/usr/src/app/vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php
/usr/src/app/vendor/sonata-project/admin-bundle/src/SonataAdminBundle.php
/usr/src/app/vendor/symfony/security-core/Authorization/TraceableAccessDecisionManager.php
/usr/src/app/vendor/sonata-project/admin-bundle/src/*/*.php
/usr/src/app/vendor/sonata-project/admin-bundle/src/*/*/*.php
/usr/src/app/vendor/sonata-project/core-bundle/src/CoreBundle/SonataCoreBundle.php
/usr/src/app/vendor/sonata-project/core-bundle/src/*/*.php
/usr/src/app/vendor/sonata-project/core-bundle/src/*/*/*.php
/usr/src/app/vendor/symfony/security-core/Authorization/*
However, when I load my Sonata application, I still get this error, which is the same error that shows up when no blacklist is used:
Fatal error: Cannot redeclare twig_truncate_filter() (previously declared in vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php:38)
Am I using the wrong format in my exclusion file? How can I fix this so that the file's contents do not get ignored?
====
Update #1: When I simplify the contents of the blacklist file to this:
/usr/src/app/vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php
/usr/src/app/vendor/sonata-project/admin-bundle/src/SonataAdminBundle.php
/usr/src/app/vendor/symfony/security-core/Authorization/TraceableAccessDecisionManager.php
... I still get essentially the same error:
Compile Error: Cannot declare class Twig_Extensions_Extension_Text,
because the name is already in use in Text.php line 15
(Yes, this is technically a different error, but it's essentially saying the same thing: The contents of Text.php are already declared in the opcache and cannot be redeclared.)
====
Update #2: Running php -v shows 7.4.19 as the version. Here is a bit of version info that shows up when I use composer info:
twig/extra-bundle v3.3.1
twig/twig v2.12.2
Running composer why twig/twig shows this output:
app-insights-php/app-insights-php-bundle 0.2.5 requires twig/twig (^1.2|^2)
friendsofsymfony/user-bundle v2.1.2 requires twig/twig (^1.28 || ^2.0)
sonata-project/admin-bundle 3.55.0 requires twig/twig (^2.10)
sonata-project/block-bundle 3.18.2 requires twig/twig (^1.34 || ^2.0)
sonata-project/core-bundle 3.17.2 requires twig/twig (^1.34 || ^2.0)
sonata-project/formatter-bundle 4.1.3 requires twig/twig (^2.4)
sonata-project/media-bundle 3.21.0 requires twig/twig (^2.10)
sonata-project/page-bundle 3.13.0 requires twig/twig (^2.10)
sonata-project/seo-bundle 2.9.0 requires twig/twig (^1.40 || ^2.9 || ^3.0)
sonata-project/translation-bundle 2.5.0 requires twig/twig (^2.12)
sonata-project/user-bundle 5.x-dev requires twig/twig (^2.9)
symfony-cmf/routing-bundle 2.1.1 requires twig/twig (^1.35 || ^2.4.4)
symfony/twig-bridge v4.4.16 requires twig/twig (^1.41|^2.10|^3.0)
symfony/twig-bundle v4.4.16 requires twig/twig (^1.41|^2.10|^3.0)
symfony/web-profiler-bundle v4.4.16 requires twig/twig (^1.41|^2.10|^3.0)
twig/extensions v1.5.4 requires twig/twig (^1.27|^2.0)
twig/extra-bundle v3.3.1 requires twig/twig (^2.4|^3.0)
====
Edit #3: There is no use of include_once() or require_once() in this app, beyond the normal autoloaders and configuration loaders found in many Symfony applications. This problem goes away when opcache is turned off. So it's definitely related to opcaching.
====
Edit #4: Here is my composer.json file.
{
"type": "project",
"license": "proprietary",
"name": "exozet/oesterreich-werbung-cms",
"description": "the new cms for Ă–sterreich Werbung based on symfony with sonata",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-curl": "*",
"ext-iconv": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-simplexml": "*",
"ext-zip": "*",
"ext-zend-opcache": "*",
"app-insights-php/app-insights-php-bundle": "^0.2.5",
"app-insights-php/doctrine-dependency-logger": "^0.2.0",
"cocur/slugify": "^3.2",
"dracoblue/craur": "^2.1",
"elao/enum": "^1.7",
"friendsofsymfony/elastica-bundle": "^5.1",
"friendsofsymfony/rest-bundle": "^2.5",
"friendsofsymfony/user-bundle": "^2.0",
"galbar/jsonpath": "^1.0",
"guzzlehttp/guzzle": "6.3.3",
"jms/serializer-bundle": "3.8.0",
"knplabs/knp-gaufrette-bundle": "^0.6.1",
"knplabs/knp-menu-bundle": "^2.0",
"lightsaml/sp-bundle": "^1.2",
"madcoda/php-youtube-api": "^1.2",
"microsoft/azure-storage-blob": "^1.4",
"microsoft/azure-storage-file": "^1.2",
"microsoft/azure-storage-queue": "^1.3",
"microsoft/azure-storage-table": "^1.1",
"nelmio/api-doc-bundle": "^4.3",
"predis/predis": "^1.1",
"sensio/framework-extra-bundle": "^5.1",
"sonata-project/admin-bundle": "^3.20",
"sonata-project/datagrid-bundle": "^2.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.10",
"sonata-project/formatter-bundle": "^4.1",
"sonata-project/media-bundle": "^3.2",
"sonata-project/page-bundle": "^3.12",
"sonata-project/translation-bundle": "^2.5",
"sonata-project/user-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "^1.4",
"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/lock": "4.4.*",
"symfony/messenger": "4.4.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/process": "4.4.*",
"symfony/security-bundle": "4.4.*",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.1",
"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": "^3.3",
"webmozart/assert": "^1.5"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.2",
"hautelook/alice-bundle": "^2.5",
"squizlabs/php_codesniffer": "*",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*",
"symfony/web-server-bundle": "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": "*",
"egeloen/ckeditor-bundle": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"ckeditor:install --clear=drop": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts",
"/bin/sh -c \"if [ -f contrib/setup.sh ]; then contrib/setup.sh; fi\""
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
}
}
}
====
Edit #5:
Here is the output of composer why twig/extensions:
sonata-project/admin-bundle 3.55.0 requires twig/extensions (^1.5)
sonata-project/core-bundle 3.17.2 requires twig/extensions (^1.5)
Here is the content of my preload.php file:
<?php
if (file_exists(dirname(__DIR__).'/var/cache/dev/srcApp_KernelDevContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/dev/srcApp_KernelDevContainer.preload.php';
}
if (file_exists(dirname(__DIR__).'/var/cache/dev/App_KernelDevContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/dev/App_KernelDevContainer.preload.php';
}
... and the referenced App_KernelDevContainer.preload.php file contains this logic that you can see here:
https://gist.github.com/patrickmaynard/0f2cff49628fe068b989a7024cd21e34
The errors
Compile Error: Cannot declare class Twig_Extensions_Extension_Text, because the name is already in use in Text.php line 15
Fatal error: Cannot redeclare twig_truncate_filter() (previously declared in vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php:38)
sound a lot like you're having multiple declarations of same method or class or you're calling include()/require() multiple times explicitly or implicitly.
Do you use include() or require() anywhere that could be called depending on opcache being effective or not?
When you use PHP autoloader, the only explicit include() calls you should have are one call to load the autoloader and all the other calls in the autoloader implementation only. And make sure you don't have include_once() nor require_once() anywhere in your codebase because those do not mix well with autoloader.
The only reason to blacklist something from the opcache should be if you need to generate code that should be reloaded. It shouldn't be used to workaround code errors (e.g. incorrect include() chains).
I just installed fresh Symfony framework skeleton with annotations and Doctrine and it not works. I have got an error
Argument 1 passed to Sensio\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
my composer file
{
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^2.2",
"doctrine/orm": "^2.7",
"sensio/framework-extra-bundle": "^5.5",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
"symfony/web-server-bundle": "4.4.*"
},
Please help.
I got the exact same problem today after installing the new symfony binary, composer update worked for me.
I have added to the config/packages/sensio_framework_extra.yaml
this lines and it working
sensio_framework_extra:
router:
annotations: false
request:
converters: true
disable: ['doctrine.orm']
I have a new error after upgrading, that should not be related to the upgrade.
I am using SendInBlue Php Library in my project, loaded in my composer with :
"sendinblue/api-v3-sdk": "*#dev",
Used in my Service with:
use SendinBlue\Client\Api\SMTPApi;
use SendinBlue\Client\Model\SendEmail;
Called with :
$api_instance = new SMTPApi();
Since the upgrade I have a new error:
Attempted to load class "SMTPApi" from namespace "SendinBlue\Client\Api".
Did you forget a "use" statement for another namespace?
I tried clear cache, have rm -rf remove cache, Invalidate my phpStorm Cache + Restart, remove the two USE statement, and then look what is displayed when I try to create a new instance, but it's still the same USE statement that is added.
If I COMMAND+CLICK on the class called, it does show the related class (SMTPApi).
I am totally lost on what could be the problem here, is it symfony upgrade related ? Is it composer update that changed other things ?
for more information, here is the header of my Service:
namespace App\Services;
use FOS\UserBundle\Mailer\MailerInterface;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Router;
use SendinBlue\Client\Api\SMTPApi;
use SendinBlue\Client\Model\SendEmail;
And here is my composer:
{ [...]
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.69",
"beelab/tag-bundle": "^1.4.0",
"friendsofsymfony/user-bundle": "^2.1",
"google/apiclient": "^2.0",
"gumlet/php-image-resize": "^1.9",
"kunalvarma05/dropbox-php-sdk": "^0.2.1",
"lildude/phpsmug": "^4.0",
"sendinblue/api-v3-sdk": "*#dev",
"sensio/framework-extra-bundle": "^5.1",
"sensiolabs/security-checker": "^4.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "^4.2",
"symfony/console": "^4.2",
"symfony/debug-pack": "^1.0",
"symfony/dependency-injection": "^4.2",
"symfony/dotenv": "^4.2",
"symfony/flex": "^1.0",
"symfony/form": "^4.2",
"symfony/framework-bundle": "^4.2",
"symfony/lock": "^4.2",
"symfony/maker-bundle": "^1.4",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/swiftmailer-bundle": "^3.0",
"symfony/translation": "^4.2",
"symfony/twig-bundle": "4.2",
"symfony/web-server-bundle": "^4.2",
"symfony/yaml": "^4.2"
},
"require-dev": {
"easycorp/easy-log-handler": "^1.0.2",
"symfony/debug-bundle": "^3.3|^4.2",
"symfony/profiler-pack": "^1.0",
"symfony/var-dumper": "^3.3|^4.2"
},
[...]
}
As said up here, needed to revert the library. Maybe now it's fixed by the creator on GIT.
I want to install Sonata Dashboard bundle, so I follow these steps.
After installing and configuring I get an error:
Compile Error: Declaration of Application\Sonata\DashboardBundle\Entity\Dashboard::getId() must be compatible with Sonata\DashboardBundle\Model\Dashboard::getId(): ?int
I use Symfony 3.4, php 7.2 and composer.json looks like:
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"enqueue/amqp-lib": "^0.8.23",
"friendsofsymfony/rest-bundle": "^2.3",
"friendsofsymfony/user-bundle": "^2.1",
"incenteev/composer-parameter-handler": "^2.0",
"jms/serializer-bundle": "^2.3",
"liip/monitor-bundle": "^2.6",
"nelmio/api-doc-bundle": "^3.2",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"sonata-project/admin-bundle": "^3.34",
"sonata-project/block-bundle": "^3.12",
"sonata-project/cache": "1.x-dev",
"sonata-project/cache-bundle": "2.4",
"sonata-project/classification-bundle": "^3.6",
"sonata-project/core-bundle": "^3.9",
"sonata-project/dashboard-bundle": "^0.3.0",
"sonata-project/datagrid-bundle": "2.3",
"sonata-project/doctrine-extensions": "^1.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.5",
"sonata-project/easy-extends-bundle": "^2.5",
"sonata-project/formatter-bundle": "^3.4",
"sonata-project/google-authenticator": "^2.1",
"sonata-project/media-bundle": "^3.12",
"sonata-project/news-bundle": "3.4",
"sonata-project/notification-bundle": "^3.5",
"sonata-project/seo-bundle": "^2.5",
"sonata-project/user-bundle": "^4.1",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"symfony/templating": "3.4.8",
"twig/twig": "^1.0||^2.0"
},
Any ideas what can be wrong?
Looks like the generated entity misses the return type hints… probably a bug in Sonata Easy Extends bundle. You can add type hint by finding and modifying Application\Sonata\DashboardBundle\Entity\Dashboard