Symfony Blog Bundle
HarentiusBlogBundle - bundle for a blog/simple portal (or complex, if using bundle inheritance and extension). View of this site.
As a backend, SonataAdminBundle is used. Implemented:
1. Admin panel (WYSIWYG, ckeditor), image/audio uploading, player.
2. Tags, categories, archives, tag cloud
3. Statistics
4. RSS-feed (requires modification)
5. "Smart" caching of everything, content is served very fast
To "ease the soul":
1. Tests
Installation
1) At the time of writing, the most recent version of Symfony was 2.7, so it will be guaranteed to work with this version. The installation of HarentiusBlogBundle was tested on a "naked" Symfony, but theoretically it can be used in an existing project.
For stand-alone installation, first install Symfony 2.7:
composer.phar create-project symfony/framework-standard-edition test "2.7.*"
(Skip this step for existing projects).
Due to the use of bower-asset/ckeditor-more-plugin:dev-master in the admin panel, you need to add the following to composer.json for the installation of HarentiusBlogBundle:
"minimum-stability": "dev",
"prefer-stable": true,
(In the future I plan to eliminate this step). You also need to specify the asset installation path:
"extra": {
...
"asset-installer-paths": {
"npm-asset-library": "web/assets/vendor",
"bower-asset-library": "web/assets/vendor"
}
}
Now, let's proceed to installing the bundle:
$ composer.phar require harentius/blog-bundle
In order to make it work, you need to connect multiple bundles:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new WhiteOctober\BreadcrumbsBundle\WhiteOctoberBreadcrumbsBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\TranslationBundle\SonataTranslationBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new Presta\SitemapBundle\PrestaSitemapBundle(),
new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
new Eko\FeedBundle\EkoFeedBundle(),
new Harentius\BlogBundle\HarentiusBlogBundle(),
);
// ...
}
3) Now, include the configuration and routing files. HarentiusBlogBundle already has configuration examples. You can simply include them using imports, or, if you prefer, copy the contents to your application and configure them as needed.
Configuration
app/config/config.yml:
imports:
...
- { resource: "@HarentiusBlogBundle/Resources/config/config.yml" }
- { resource: "@HarentiusBlogBundle/Resources/config/security.yml" }
If you are using the configuration with HarentiusBlogBundle, remove
imports:
...
- { resource: security.yml }
(Symfony does not allow storage of security configuration in multiple files).
Routes:
blog:
resource: "@HarentiusBlogBundle/Resources/config/routing.yml"
prefix: /
admin:
resource: "@HarentiusBlogBundle/Resources/config/routing-admin.yml"
prefix: /admin
Bundle configuration:
harentius_blog:
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: 6
list:
posts_per_page: 20
# For avoiding internal apc cache conflicts if run multiple sites on one server.
cache:
apc_global_prefix: blog
statistics_cache_lifetime: 3600
Configure assetic:
assetic:
debug: "%kernel.debug%"
use_controller: false
filters:
cssrewrite:
apply_to: "\.css$"
less:
node: %nodejs.path%
node_paths: [%nodejs.modules_path%]
apply_to: "\.less$"
coffee:
bin: %bin_coffee%
apply_to: "\.coffee$"
5) Install/update the database depending on the type of installation:
app/console doctrine:schema:create
or
app/console doctrine:schema:update
6) Load initial values: admin credentials, default: admin/admin, settings, etc.:
app/console blog:database:populate
That's it, the bundle is installed. Unfortunately, it ended up being quite difficult, and I hope to simplify it in the future. Any comments/suggestions are welcome (here or on github).