0

StofDoctrineExtensionsBundleを使用してDoctrineExtensionsを構成した後、FOSUserBundleに問題があります。

まず、DoctrineExtensionsをインストールするには、app / config / config.ymlファイルから「auto_mapping:true」セグメントを削除する必要がありました。

auto_mappingがアクティブでない場合は、FOSUserBundle:〜をdefault:mappingsセグメントに含める必要があることがわかりました。

でも、やってみると

php app/console doctrine:schema:update --force

また

php app/console doctrine:generate:entities FOS

私は得る:

PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
Generating entities for namespace "FOS"
PHP Fatal error:  Access level to FOS\UserBundle\Entity\User::$username must be protected (as in class FOS\UserBundle\Model\User) or weaker in /var/www/rBay/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Entity/User.php on line 17
PHP Stack trace:
PHP   1. {main}() /var/www/rBay/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /var/www/rBay/app/console:22
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:105
PHP   4. Symfony\Component\Console\Application->doRun() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:78
PHP   5. Symfony\Component\Console\Command\Command->run() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:192
PHP   6. Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:238
PHP   7. Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getNamespaceMetadata() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php:109
PHP   8. Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getMetadataForNamespace() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:97
PHP   9. Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getAllMetadata() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:160
PHP  10. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:196
PHP  11. Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->getAllClassNames() /var/www/rBay/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:111
PHP  12. Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver->getAllClassNames() /var/www/rBay/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:132
PHP  13. require_once() /var/www/rBay/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php:194
PHP  14. Symfony\Component\ClassLoader\DebugClassLoader->loadClass() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/DebugClassLoader.php:0
PHP  15. require() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/DebugClassLoader.php:82

Fatal error: Access level to FOS\UserBundle\Entity\User::$username must be protected (as in class FOS\UserBundle\Model\User) or weaker in /var/www/rBay/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Entity/User.php on line 17

Call Stack:
0.0002     644752   1. {main}() /var/www/rBay/app/console:0
0.0132    3467080   2. Symfony\Component\Console\Application->run() /var/www/rBay/app/console:22
0.0155    3851816   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:105
2.3154   50066792   4. Symfony\Component\Console\Application->doRun() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:78
2.3187   50066792   5. Symfony\Component\Console\Command\Command->run() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:192
2.3192   50068328   6. Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:238
2.3208   50178008   7. Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getNamespaceMetadata() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php:109
2.3208   50178008   8. Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getMetadataForNamespace() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:97
2.3208   50178320   9. Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getAllMetadata() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:160
2.3307   50203984  10. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() /var/www/rBay/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:196
2.3308   50204456  11. Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->getAllClassNames() /var/www/rBay/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:111
2.3308   50205408  12. Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver->getAllClassNames() /var/www/rBay/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:132
2.3428   52000872  13. require_once('/var/www/rBay/src/MSoft/UserBundle/Entity/User.php') /var/www/rBay/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php:194
2.3428   52001400  14. Symfony\Component\ClassLoader\DebugClassLoader->loadClass() /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/DebugClassLoader.php:0
2.3431   52081336  15. require('/var/www/rBay/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Entity/User.php') /var/www/rBay/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/DebugClassLoader.php:82

念のため、設定ファイルの関連領域も添付します...

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%
    entity_managers:
        default:
            connection: default
            mappings:
                gedmo_translatable:
                    type: annotation
                    prefix: Gedmo\Translatable\Entity
                    dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
                    alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
                    is_bundle: false
                gedmo_translator:
                    type: annotation
                    prefix: Gedmo\Translator\Entity
                    dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
                    alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
                    is_bundle: false
                gedmo_loggable:
                    type: annotation
                    prefix: Gedmo\Loggable\Entity
                    dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
                    alias: GedmoLoggable # this one is optional and will default to the name set for the mapping
                    is_bundle: false
                gedmo_tree:
                    type: annotation
                    prefix: Gedmo\Tree\Entity
                    dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                    alias: GedmoTree # this one is optional and will default to the name set for the mapping
                    is_bundle: false
                MSoftAdminBundle: ~
                MSoftUserBundle: ~
                FOSUserBundle: ~

# Fosuser Configuration
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: MSoft\UserBundle\Entity\User

stof_doctrine_extensions:
    default_locale: en_US
    orm:
        default:
            tree: true
            sluggable: true

私は何が間違っているのですか?

4

2 に答える 2

2

解決しました。実行したときに問題が発生しました

php app/console doctrine:generate:entities FOS

ドクトリン エンティティ ジェネレーターよりも、そこにあるはずのないプロパティが追加され、問題が発生しました。ポイントは、クラス FOS\UserBundle\Entity\User は空のボディを持つ必要があり、ジェネレーターはその中に FOS\UserBundle\Model\User からすべてのフィールドを作成し、より高い保護レベル (「保護」ではなく「プライベート」) のみを使用することです。

于 2012-11-17T08:55:50.897 に答える
1

User クラスのすべてのプロパティは、パブリックではなく、保護する必要があります。

于 2012-11-17T06:39:03.920 に答える