harentius/blog-bundle

Symfony Bundle,用于将简单的博客功能添加到现有的或新的Symfony项目中。

安装: 371

依赖者: 1

建议者: 0

安全: 0

星星: 19

关注者: 5

分支: 7

开放问题: 5

类型:symfony-bundle


README

codecov Maintainability Scrutinizer Code Quality

Symfony Bundle,用于将简单的博客功能添加到现有的或新的Symfony项目中。

需求

版本 ^4.0 - Symfony ^4.0, twig/twig:^2.0
版本 ^3.0 - Symfony ^3.0
版本 ^1.0|^2.0 - Symfony ^2.7

安装

1. 使用 Symfony Flex

待办事项

2. 不使用 Symfony Flex

  1. 安装包
$ composer.phar require harentius/blog-bundle
  1. 添加包(在config/bundles.php或Kernel中)
<?php
// config/bundles.php

return [
//...
    Harentius\BlogBundle\HarentiusBlogBundle::class => ['all' => true],
//...
    Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
    Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
    Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
    WhiteOctober\BreadcrumbsBundle\WhiteOctoberBreadcrumbsBundle::class => ['all' => true],
    Sonata\CoreBundle\SonataCoreBundle::class => ['all' => true],
    Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
    Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle::class => ['all' => true],
    Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
    Sonata\TranslationBundle\SonataTranslationBundle::class => ['all' => true],
    Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],
    FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true],
    Presta\SitemapBundle\PrestaSitemapBundle::class => ['all' => true],
    Eko\FeedBundle\EkoFeedBundle::class => ['all' => true],
    Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
    Hautelook\AliceBundle\HautelookAliceBundle::class => ['all' => true],
    Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['all' => true],
    Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['all' => true],
];

请注意,HarentiusBlogBundle可以为其他包提供默认配置。
要使此功能生效,HarentiusBlogBundle应该在其他包之前注册

HarentiusBlogBundle还具有默认的安全配置。因此,请确保它与您的应用程序配置不冲突或跳过使用它

  1. 包含路由
# config/routes.yaml
blog:
    resource: "@HarentiusBlogBundle/Resources/config/routing.yml"
    prefix: /
  1. 包含默认配置
    注意:如果您决定自己配置包(即DoctrineBundle、SecurityBundle等),则可以跳过此步骤
# config/packages/harentius_blog.yaml
imports:
    - { resource: '@HarentiusBlogBundle/Resources/config/config.yml' }

配置

配置参考

harentius_blog:
    # Localizations to be used by blog
    locales: ['en', 'uk']
    primary_locale: 'en'
    articles:
        # Path where previews stored
        image_previews_base_uri: /assets/images/preview/
    sidebar:
        # ~ - no cache, 0 - unlimited cache
        cache_lifetime: 3600
        # Max tags number (ordered by max popularity)
        tags_limit: 10
        # Percent tags size, unlimited variants number (valid values: [50, 100], [25, 50, 75, 100], etc)
        tag_sizes: [65, 80, 100]
    homepage:
        # ~ - no page, feed only or page slug
        page_slug: index
        # ~ - no feed
        feed:
            # ~ - all
            category: ~
            # Last articles number
            number: 5
    list:
        posts_per_page: 20
    # For avoiding internal apc cache conflicts if run multiple sites on one server.
    cache:
        apc_global_prefix: blog

安装/配置后操作

  1. 根据选择的安装类型创建/更新您的数据库
bin/console doctrine:database:create # If fresh installation
bin/console doctrine:schema:create
  1. 安装资源
bin/console assets:install --symlink
  1. 加载固定数据(可选)
bin/console hautelook:fixtures:load

其他资源

https://folkprog.net - 基于此包的博客示例。

https://github.com/harentius/folkprog - 包含此博客源代码的git仓库。