【问题标题】:FosCommentBundle assetic exception to Symfony3Symfony3 的 FosCommentBundle 资产异常
【发布时间】:2017-07-26 09:14:31
【问题描述】:

我正在尝试将 FosCommentBundle 用于 Symfony3。

我使用documentation of bundle 完成所有安装步骤。

我添加 AppKernel 信息并创建数据库、更新架构并添加 Jquery3。

但是当我尝试检查 index.html.twig 时会出现以下错误。

There is no extension able to load the configuration for "assetic" (in C:\xampp\htdocs\blogbundle\app/config\config.yml). Looked for namespace "assetic", found "framework", "security", "twig", "monolog", "swiftmailer", "doctrine", "sensio_framework_extra", "fos_rest", "fos_comment", "jms_serializer", "debug", "web_profiler", "sensio_distribution", "web_server" in C:\xampp\htdocs\blogbundle\app/config\config.yml (which is being imported from "C:\xampp\htdocs\blogbundle\app/config/config_dev.yml").

我的 config.yml

fos_comment:
    db_driver: orm
    class:
        model:
            comment: AppBundle\Entity\Comment
            thread: AppBundle\Entity\Thread

assetic:
    bundles: [ "FOSCommentBundle" ]

routing.yml

app:
    resource: '@AppBundle/Controller/'
    type: annotation

fos_comment_api:
    type: rest
    resource: "@FOSCommentBundle/Resources/config/routing.yml"
    prefix: /api
    defaults: { _format: html }

实体: - 评论.php

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Comment as BaseComment;

/**
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Comment extends BaseComment
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * Thread of this comment
     *
     * @var Thread
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Thread")
     */
    protected $thread;
}

线程.php

<?php

namespace AppBundle\Entity;


use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Thread as BaseThread;

/**
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Thread extends BaseThread
{
    /**
     * @var string $id
     *
     * @ORM\Id
     * @ORM\Column(type="string")
     */
    protected $id;
}

【问题讨论】:

    标签: php-7 symfony-3.2 symfony-3.3


    【解决方案1】:

    您所要做的就是安装assetic bundle

    composer 需要 symfony/assetic-bundle 然后将其添加到 appkernel 中的 registerBundles

    新的 Symfony\Bundle\AsseticBundle\AsseticBundle(),

    并将其添加到 config.yml

    assetic:
       debug:          '%kernel.debug%'
       use_controller: '%kernel.debug%'
       filters:
            cssrewrite: ~
    

    【讨论】:

      猜你喜欢
      • 2018-02-09
      • 1970-01-01
      • 2018-01-16
      • 2016-08-03
      • 1970-01-01
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      相关资源
      最近更新 更多