当我正在尝试加载我的symfony 2应用程序时,这个问题就出现了,
AppKernel.php第25行中的ClassNotFoundException:尝试从命名空间“Sonata \ DoctrineORMAdminBundle”加载类“SonataDoctrineORMAdminBundle”。 您是否忘记了另一个命名空间的“use”语句?
这是我的AppKernel.php文件,
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new kcc\AdminBundle\kccAdminBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
这个composer.json文件,
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": {
"": "src/",
"Sonata\\DoctrineORMAdminBundle\\": ""
}
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"jms/serializer-bundle": "*",
"weaverryan/derp-dangerzone": "dev-master",
"vimuths123/menucreator": "dev-master",
"sonata-project/admin-bundle": "^3.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.0",
"sensio/generator-bundle": "2.3.*",
"sonata-project/user-bundle": "^2.2",
"friendsofsymfony/rest-bundle": "^1.7",
"nelmio/api-doc-bundle": "^2.12",
"sonata-project/core-bundle": "^3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.3.9"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/vimuths123/menucreator"
}
]
}
我也试图更新作曲家,但由于这个问题它也无法更新
答案 0 :(得分:2)
首先要做的事情。您确定您的composer.json文件包含以下标记为&lt; ==重要:
的条目@RequestMapping(
method = RequestMethod.GET,
path = "/mappings")
@ResponseStatus(HttpStatus.OK)
@ApiImplicitParams({
@ApiImplicitParam(name = "page", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "size", dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "sort", dataType = "string", paramType = "query", allowMultiple = true),
@ApiImplicitParam(name = RestConfiguration.HEADER_ACCEPT_LANGUAGE, dataType = "string", paramType = "header", defaultValue = RestConfiguration.DEFAULT_LOCALE_TAG)
})
public PagedResources<MappingResource> getMappings(@ApiParam(required = true) @PathVariable final Integer customerId,
@ApiIgnore @PageableDefault final Pageable pageable,
HttpServletRequest request) {
ApplicationResourcesValidator.validateCustomerId(customerId);
if (customerRepository.findOne(customerId) == null) {
throw new CustomerNotFoundException(customerId);
}
customerIdProvider.set(customerId);
Page<UserdbFormMapping> mappings = userdbFormMappingRepository.findAllIfUserdbValid(pageable);
MappingResourceAssembler mappingResourceAssembler = new MappingResourceAssembler(
MappingController.class,
MappingResource.class,
customerId,
facebookApiClient,
userdbRepository,
userdbFormMappingRepository,
userdbFormMappingFieldRepository,
userdbFormSubscriptionLogCacheRepository,
persistenceManager);
LOGGER.info("serving " + request.getRequestURI());
return mappingPagedResourceAssembler.toResource(mappings, mappingResourceAssembler);
}
答案 1 :(得分:1)
写在documentation中,你必须由作曲家安装SonataDoctrineORMAdminBundle
:
composer require sonata-project/doctrine-orm-admin-bundle
如果您按照instructions on the symfony page进行操作可能会有帮助。
答案 2 :(得分:0)
只需运行此命令
composer install/update