我有错误[问题末尾的解决方案]
Fatal error: Class 'symblog\Blogger\BlogBundle\SymblogBundle' not found in /var/www/Symfony/app/AppKernel.PHP on line 20
我创建了问题How to install or integrate bundles in Symfony2,但给出的解决方案对我没有帮助,因为我已经做了那里的建议.我正在按照教程symblog.co.uk,除了我创建的
app/config/routing.yml
一个
*.PHP resource
提前致谢!
The command was not able to configure everything automatically. You must do the following changes manually.
和说明:
- Edit the app/autoload.PHP file and register the bundle namespace at the top of the registerNamespaces() call: 'symblog\Blogger\BlogBundle' => '/var/www/Symfony/blog',
我跟着他.
AppKernel.PHP
class AppKernel extends Kernel { public function registerBundles() { $bundles = array( //.. new symblog\Blogger\BlogBundle\SymblogBundle(),);
/app/config/routing.yml
SymblogBundle: resource: "@SymblogBundle/Resources/config/routing.PHP" prefix: /
根据要求:/app/config/config.yml
imports: - { resource: parameters.ini } - { resource: security.yml } framework: #esi: ~ #translator: { fallback: %locale% } secret: %secret% charset: UTF-8 router: { resource: "%kernel.root_dir%/config/routing.yml" } form: true csrf_protection: true validation: { enable_annotations: true } templating: { engines: ['twig'] } #assets_version: SomeVersionScheme session: default_locale: %locale% auto_start: true # Twig Configuration twig: debug: %kernel.debug% strict_variables: %kernel.debug% # Assetic Configuration assetic: debug: %kernel.debug% use_controller: false # java: /usr/bin/java filters: cssrewrite: ~ # closure: # jar: %kernel.root_dir%/java/compiler.jar # yui_css: # jar: %kernel.root_dir%/java/yuicompressor-2.4.2.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% jms_security_extra: secure_controllers: true secure_all_services: false
[编辑] @Clamidity的答案后解决方案非常简单,捆绑包通常位于src / Blogger / SymBlogBundle / BloggerSymBlogBundle.PHP
虽然使用控制台进行了配置,但它关于捆绑软件的位置,默认为/../src,但我更改为/../blog.当然它不起作用,Symfony正在寻找错误的位置.我所做的是将/ blog中的文件夹移动到/ src,一切都很顺利.
它有一些可能的东西.我会掩盖我能想到的任何事情.
原文链接:/php/135147.html>通常捆绑包放在src文件夹中.所以你的包的路径应该是这样的.
src/Blogger/SymBlogBundle/BloggerSymBlogBundle.PHP
(请注意,包名称遵循文件名约定)
> BloggerSymBlogBundle.PHP内部确保您具有类似于以下内容的内容:
<?PHP namespace Blogger\SymBlogBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class BloggerSymBlogBundle extends Bundle { }
(请注意,此处也遵循相同的名称约定)
>在autoload.PHP中,应注册的命名空间是捆绑包名称/路径的“Blogger”部分.这是因为捆绑包本身位于Blogger文件夹中:
'Blogger' => __DIR__.'/../src',
(请注意,列出的文件夹是Blogger文件夹的父文件夹)
>现在在AppKernel.PHP中根据您设置和注册的命名空间注册捆绑包:
new Blogger\SymBlogBundle\BloggerSymBlogBundle(),
*注意 – 您的资源和对此捆绑包的引用具有上述配置
BloggerSymBlogBundle
所以你的PHP路由将通过使用:
@BloggerSymBlogBundle/Resources/config/routing.PHP