At this moment, I use Symfony 4.3, and I don't have any problem in dev.
When I want to install any specific new bundle , i have this error :
Attempted to load class "SonataDatagridBundle" from namespace "Sonata\DatagridBundle". Did you forget a "use" statement for another namespace?
I try to install knplabs/knp-snappy-bundle with specific version 1.5.2.
composer.json
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-curl": "*",
"ext-iconv": "*",
"ext-json": "*",
"doctrine/doctrine-bundle": "*",
"doctrine/event-manager": "*",
"doctrine/orm": "*",
"doctrine/persistence": "*",
"friendsofsymfony/ckeditor-bundle": "^2.2",
"mpdf/mpdf": "^8.0",
"sensio/framework-extra-bundle": "^5.1",
"sonata-project/admin-bundle": "^3.54",
"sonata-project/doctrine-orm-admin-bundle": "^3.12",
"symfony/apache-pack": "^1.0",
"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/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/twig-pack": "*",
"symfony/validator": "4.4.*",
"symfony/web-link": "4.4.*",
"symfony/yaml": "4.4.*",
"vich/uploader-bundle": "^1.13",
"knplabs/knp-snappy-bundle": "1.5.2",
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3",
"dompdf/dompdf": "dev-master",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "*",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*",
"symfony/var-dumper": "4.4.*",
"symfony/web-server-bundle": "4.4.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"symfony/flex": false
}
},
"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.*"
}
}
}
I tried a lot of command like :
composer update and then composer dump-autoload
also
composer update vendor/knplabs/knp-snappy-bundle:1.5.2 --with-dependencies
and
composer require knplabs/knp-snappy-bundle "^1.5.2"
but all time the same error.
my bundles.php
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Sonata\DatagridBundle\SonataDatagridBundle::class => ['all' => true],
Sonata\CoreBundle\SonataCoreBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true],
Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
I tried also to change and then do composer dump-autoload :
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
by
"autoload": {
"psr-4": {
"": "src/"
}
},
but everytime I get the same error.
When I run composer require or composer update, symfony do update of symfony flex and there is the problem, I ask for a way to update only KnpSnappyBundle without changing anything in vendor?