Symfony2 can't load bundle [closed]
Asked Answered
S

0

6

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"

}
Sulk answered 21/9, 2015 at 22:15 Comment(7)
Looking at your github repository, I can see that there is a typo in your psr-0 namespace declaration. Take a look again at your files and make sure it's spelled right.Nayarit
Well, I fixed it and made a new commit, and also fixed it locally. Problem is still here :/Sulk
Re-check your files again. I had no trouble registering your bundle only in AppKernel.php. Your namespace should be registered correctly under vendor/composer/autoload_namespaces.php.Nayarit
Well, It was my mistake, sorry. Typo was the cause of the error. Thanks :)Sulk
Maybe you should answer your own question, in order to point out that you don't need help anymore. Cheers!Contemplation
@Nayarit I think you should write the answer not in comment :) or maybe NikolaIndustrial
I'm voting to close this question as off-topic because typo-basedJennelljenner

© 2022 - 2024 — McMap. All rights reserved.