{{ session_flash() }}
安装完成后MopaBootstrapBundle
,我在第19行的app/Resources/views/app.html.twig中获得了意外的"样式表"标签(期望在第19行附近定义的"块"标签的结束标记).从未遇到过它!这是
config.yml
:
imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: services.yml } - { resource: "@AdminUserBundle/Resources/config/services.yml" } # Put parameters here that don't need to change on each machine where the app is deployed # http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration parameters: locale: en sonata_block: default_contexts: [cms] blocks: # Enable the SonataAdminBundle block sonata.admin.block.admin_list: contexts: [admin] framework: #esi: ~ #translator: { fallbacks: ["%locale%"] } secret: "%secret%" router: resource: "%kernel.root_dir%/config/routing.yml" strict_requirements: ~ form: ~ csrf_protection: ~ validation: { enable_annotations: true } #serializer: { enable_annotations: true } templating: engines: ['twig'] #assets_version: SomeVersionScheme default_locale: "%locale%" trusted_hosts: ~ trusted_proxies: ~ session: # handler_id set to null will use default session handler from php.ini handler_id: ~ fragments: ~ http_method_override: true translator: ~ # Twig Configuration twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%" # Doctrine Configuration doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8 # if using pdo_sqlite as your database driver: # 1. add the path in parameters.yml # e.g. database_path: "%kernel.root_dir%/data/data.db3" # 2. Uncomment database_path in parameters.yml.dist # 3. Uncomment next line: # path: "%database_path%" orm: auto_generate_proxy_classes: "%kernel.debug%" naming_strategy: doctrine.orm.naming_strategy.underscore 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 # other valid values are 'mongodb', 'couchdb' and 'propel' firewall_name: main user_class: Admin\UserBundle\Entity\User group: group_class: Admin\UserBundle\Entity\UserGroup mopa_bootstrap: form: ~ # Adds twig form theme support menu: ~ # enables twig helpers for menu
这是app.html.twig文件:
{% from 'MopaBootstrapBundle::flash.html.twig' import session_flash %} {% block html_tag %} {% endblock html_tag %} {% block head %} {% block head_style %} {# Override this block to add your own files! #} {# To use this without less or sass use the base.html.twig template as your base # Be sure you understand whats going on: have a look into # https://github.com/phiamo/MopaBootstrapBundle/blob/master/Resources/doc/css-vs-less.md #} {% block stylesheets %} {% stylesheets filter='cssrewrite' '@MopaBootstrapBundle/Resources/public/bootstrap/dist/css/bootstrap.min.css' %} {% endblock stylesheets %} {% endblock head_style %} {% endblock %} {% block head_bottom %} {% endblock head_bottom %} {% endblock head %} {% block body_tag %} {% endblock body_tag %} {% block body_start %} {% endblock body_start %} {% block body %} {% block navbar %} {% endblock navbar %} {% block container %} {% block container_div_start %}{% endblock container_div_start %} {% block header %}{% endblock container_div_end %} {% endblock container %} {% block body_end_before_js %} {% endblock body_end_before_js %} {% block foot_script %} {% block content_foot_script %} {% endblock content_foot_script %} {# To only use a subset or add more js overwrite and copy paste this block To speed up page loads save a copy of jQuery in your project and override this block to include the correct path Otherwise the regeneration is done on every load in dev more with use_controller: true #} {% block foot_script_assetic %} {# Please add the javascripts you need in your project #} {% endblock foot_script_assetic %} {% endblock foot_script %} {% endblock body %} {% block body_end %} {% endblock body_end %}{% endblock header %} {% block content_div_start %}??????? ???? ???
{% endblock content_div_start %} {% block flashes %} {% if app.session.flashbag.peekAll|length > 0 %}{% endblock content_div_end %} {% block footer_tag_start %} {% endblock footer_tag_end %} {% block container_div_end %}{% endif %} {% endblock flashes %} {% block content %} {% endblock content %} {% block content_div_end %}{{ session_flash() }}
小智.. 33
似乎symfony 2.8默认情况下不附带AsseticBundle.您需要手动安装它.
1)安装
composer require symfony/assetic-bundle
2)添加到AppKernel.php
$bundles = array( [...] new Symfony\Bundle\AsseticBundle\AsseticBundle(), [...] );
3)添加到config.yml
assetic: debug: "%kernel.debug%" use_controller: false bundles: [ ] filters: cssrewrite: ~
应该这样做.
似乎symfony 2.8默认情况下不附带AsseticBundle.您需要手动安装它.
1)安装
composer require symfony/assetic-bundle
2)添加到AppKernel.php
$bundles = array( [...] new Symfony\Bundle\AsseticBundle\AsseticBundle(), [...] );
3)添加到config.yml
assetic: debug: "%kernel.debug%" use_controller: false bundles: [ ] filters: cssrewrite: ~
应该这样做.