Sunday 15 January 2012

symfony2 - Symfony 2.5.5 & FOSUserBundle: the class ... was not found in the chain configured namespaces -



symfony2 - Symfony 2.5.5 & FOSUserBundle: the class ... was not found in the chain configured namespaces -

recently, started working symfony2. want add together user management engine site.

but i'm facing problem. i'm doing:

in terms of creating/installing basic symfony2 project:

$ composer create-project symfony/framework-standard-edition path/ "2.5.*" $ mv path/* ./ $ rm -r path/

ok, much symfony 2.5.5. next, download fosuserbundle , create custom bundle:

$ composer require friendsofsymfony/user-bundle '~2.0@dev' $ php app/console generate:bundle --namespace=meiblorn/corebundle --format=yml

create user class in meiblorn\corebundle\framework\domain namespace

/** * user: meiblorn * date: 15/10/14 * time: 20:17 */ namespace meiblorn\corebundle\framework\domain; utilize fos\userbundle\model\user fosuserbundleuser; utilize doctrine\orm\mapping orm; /** * @orm\entity * @orm\table( * name = "users" * ) */ class user extends fosuserbundleuser { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ protected $id; public function __construct() { parent::__construct(); // own logic } } ?>

configure security.yml , config.yml. finally, got this:

appkernel.php $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 fos\userbundle\fosuserbundle(), new meiblorn\corebundle\meiblorncorebundle(), ); config.yml imports: - { resource: parameters.yml } - { resource: security.yml } framework: #esi: ~ translator: { fallback: "%locale%" } secret: "%secret%" router: resource: "%kernel.root_dir%/config/routing.yml" strict_requirements: ~ form: ~ csrf_protection: ~ validation: { enable_annotations: true } templating: engines: ['twig'] #assets_version: someversionscheme default_locale: "%locale%" trusted_hosts: ~ trusted_proxies: ~ session: # handler_id set null utilize default session handler php.ini handler_id: ~ fragments: ~ http_method_override: true # twig configuration twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%" # assetic configuration assetic: debug: "%kernel.debug%" use_controller: false bundles: [ ] #java: /usr/bin/java filters: cssrewrite: ~ #closure: # jar: "%kernel.root_dir%/resources/java/compiler.jar" #yui_css: # jar: "%kernel.root_dir%/resources/java/yuicompressor-2.4.7.jar" # doctrine configuration doctrine: dbal: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: utf8 orm: auto_generate_proxy_classes: "%kernel.debug%" auto_mapping: true # swiftmailer configuration swiftmailer: transport: "%mailer_transport%" host: "%mailer_host%" username: "%mailer_user%" password: "%mailer_password%" spool: { type: memory } fos_user: db_driver: orm firewall_name: prod user_class: meiblorn\corebundle\framework\domain\user security.yml security: encoders: fos\userbundle\model\userinterface: sha512 role_hierarchy: role_admin: role_user role_super_admin: role_admin providers: fos_userbundle: id: fos_user.user_provider.username firewalls: prod: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider logout: true anonymous: true dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false access_control: - { path: ^/login$, role: is_authenticated_anonymously } - { path: ^/register, role: is_authenticated_anonymously } - { path: ^/resetting, role: is_authenticated_anonymously } - { path: ^/admin/, role: role_admin } this problem in browser: http://localhost/test.meiblorn.com/web/app_dev.php/ mappingexception: class 'meiblorn\corebundle\framework\domain\user' not found in chain configured namespaces fos\userbundle\model in /library/webserver/documents/test.meiblorn.com/vendor/doctrine/common/lib/doctrine/common/persistence/mapping/mappingexception.php line 37 @ mappingexception::classnotfoundinnamespaces('meiblorn\corebundle\framework\domain\user', array('fos\userbundle\model')) in /library/webserver/documents/test.meiblorn.com/vendor/doctrine/common/lib/doctrine/common/persistence/mapping/driver/mappingdriverchain.php line 113 @ mappingdriverchain->loadmetadataforclass('meiblorn\corebundle\framework\domain\user', object(classmetadata)) in /library/webserver/documents/test.meiblorn.com/vendor/doctrine/orm/lib/doctrine/orm/mapping/classmetadatafactory.php line 117 @ classmetadatafactory->doloadmetadata(object(classmetadata), object(classmetadata), false, array()) in /library/webserver/documents/test.meiblorn.com/vendor/doctrine/common/lib/doctrine/common/persistence/mapping/abstractclassmetadatafactory.php line 318 also doctrine doesn't create tables mapping when calling doctrine:schema:update please, help me prepare exception update! how fix

final configuration namespace

orm: auto_generate_proxy_classes: "%kernel.debug%" auto_mapping: false mappings: fosuserbundle: ~ meiblorncorebundle: type: annotation dir: %kernel.root_dir%/../src/meiblorn/corebundle/framework/entity prefix: meiblorn\corebundle\framework\entity # alias: mymodels # is_bundle: true

first need configure psr-4 autoload in composer.js, example

"autoload": { "psr-4": { "meiblorn\\corebundle\\": "src/meiblorn/corebundle/" } },

then phone call composer dumpautoload.

secondly, believe doctrine expects entities live in folder entity/, seek move model: src/meiblorn/corebundle/framework/domain/user.php src/meiblorn/corebundle/entity/user.php or how alter symfony 2 doctrine mapper utilize custom directory instead of entity directory under bunle

symfony2 doctrine mapping fosuserbundle mappingexception

No comments:

Post a Comment