tigin tigin - 5 months ago 47
PHP Question

SonataBlock, SonataAdmin and Other Sonata bundles keep showing "Validation" error

Compile Error: Declaration of Sonata\FormatterBundle\Block\FormatterBlockService::validateBlock() must be compatible with Sonata\BlockBundle\Block\BlockAdminServiceInterface::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block)

At the same time:

PHP Fatal error: Declaration of Sonata\AdminBundle\Block\AdminListBlockService::validateBlock() must be compatible with Sonata\BlockBundle\Block\BlockServiceInterface::validateBlock(Sonata\AdminBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) in /phpProjects/vendor/sonata-project/admin-bundle/Block/AdminListBlockService.php on line 105

Here is my composer.json

"php": ">=5.4",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~1.3@dev",
"knplabs/knp-menu-bundle": "1.1.*@dev",
"sonata-project/core-bundle": "~2.2@dev",
"sonata-project/intl-bundle": "~2.2",
"sonata-project/cache-bundle": "~2.2@dev",
"sonata-project/easy-extends-bundle": "~2.1",
"sonata-project/admin-bundle": "~2.3@dev",
"sonata-project/doctrine-orm-admin-bundle": "~2.3@dev",
"sonata-project/block-bundle": "~2.2",
"sonata-project/exporter": "1.*",
"sonata-project/user-bundle": "~2.3@dev",
"sonata-project/formatter-bundle": "~2.3",
"sonata-project/datagrid-bundle": "~2.2@dev",
"sonata-project/media-bundle": "~2.3@dev",
"jms/serializer-bundle": "~0.11",
"jms/security-extra-bundle": "~1.5@dev",
"jms/di-extra-bundle": "~1.4@dev",
"jms/translation-bundle": "1.1.*@dev",
"friendsofsymfony/jsrouting-bundle": "~1.1",
"genemu/form-bundle": "2.2.*@dev",
"wbx/file-bundle": "dev-master",

Answer

The best solution, add dependency only directly use

I write to below

    "friendsofsymfony/user-bundle": "~1.3",
    "sonata-project/user-bundle": "3.0.1",
    "sonata-project/cache-bundle": "~2.2@dev",
    "sonata-project/intl-bundle": "~2.2",
    "sonata-project/doctrine-orm-admin-bundle": "3.0.1",
    "sonata-project/doctrine-mongodb-admin-bundle": "3.0.0"

SonataAdminBundle is SonataUserBundle's dependency. Remove SonataAdminBundle and let SonataUserBundle install the bundle. The others the same...

This is the best solution.