我试图在新的Symfony2项目中使用我自己的捆绑包。 我已经创建了项目,并使用composer安装了所有必需的包。
这是我的项目的composer.json文件
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/", "SymfonyStandard\\": "app/SymfonyStandard/" }
},
"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",
"trancynn/devana-book-app": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"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::removeSymfonyStandardFiles",
"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::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"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"
}
}
}
之后,我在AppKernel的registerBundles方法中加载所有必需的包,如下所示:
new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
new FOS\OAuthServerBundle\FOSOAuthServerBundle(),
new FOS\RestBundle\FOSRestBundle(),
new Voryx\RESTGeneratorBundle\VoryxRESTGeneratorBundle(),
new Nelmio\CorsBundle\NelmioCorsBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Nikola\DevanaBookAppBundle\NikolaDevanaBookAppBundle(),
但现在,运行服务器会导致致命错误:
Fatal error: Class 'Nikola\DevanaBookAppBundle\NikolaDevanaBookAppBundle' not found in C:\Users\Nikola\Desktop\symftest\mytest\app\AppKernel.php on line 25
我真的看不出有什么不对。 万一你需要它,这就是我的Bundle的composer.json
{
"name": "trancynn/devana-book-app",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
{
"name": "Nikola Ninkovic",
"email": "ninkovicnikola00@gmail.com"
}
],
"minimum-stability": "dev",
"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": "@stable",
"friendsofsymfony/rest-bundle": "@stable",
"friendsofsymfony/oauth-server-bundle": "@stable",
"hwi/oauth-bundle": "@stable",
"voryx/restgeneratorbundle": "@stable"
},
"autoload": {
"psr-0": { "Nikola\\DevanaBookAppBundle": "" }
},
"target-dir": "Nikola/DevanaBookAppBundle"
}