I'm trying to use my own bundle in the new Symfony2 project. I've created the project and than installed all required bundles using composer.
Here's my project's composer.json file
{
"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"
}
}
}
After that, I load all the required bundles in my AppKernel's registerBundles method like this:
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(),
But now, running the server causes fatal error:
Fatal error: Class 'Nikola\DevanaBookAppBundle\NikolaDevanaBookAppBundle' not found in C:\Users\Nikola\Desktop\symftest\mytest\app\AppKernel.php on line 25
I really can't see what's wrong. In case you need it, here's my Bundle's composer.json
{
"name": "trancynn/devana-book-app",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
{
"name": "Nikola Ninkovic",
"email": "[email protected]"
}
],
"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"
}
psr-0
namespace declaration. Take a look again at your files and make sure it's spelled right. – NayaritAppKernel.php
. Your namespace should be registered correctly undervendor/composer/autoload_namespaces.php
. – Nayarit