This version of the bundle requires Symfony 4.3 or higher.
Open a command console, enter your project directory and execute:
$ composer require goulmima/blog-bundle
By default, this command will download the latest release version of the bundle (the recommended way).
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project (if you are using symfony flex, this is done automatically):
// config/bundles.php
return [
// ...
Goulmima\BlogBundle\GoulmimaBlogBundle::class => ['all' => true],
];
# config/routes.yaml
goulmima_blog:
resource: '@GoulmimaBlogBundle/Controller/'
type: annotation
prefix: /some_prefix
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Goulmima\BlogBundle\Entity\BlogPost as GoulmimaBlogPost;
/**
* @ORM\Entity()
*/
class MyBlogPost extends GoulmimaBlogPost
{
// you can add your own attributes ...
}
$ php bin/console make:migration
$ php bin/console doctrine:migrations:migrate
# config/packages/goulmima_blog.yaml
goulmima_blog:
post:
class: 'App\Entity\MyBlogPost'
You can access to GoulmimaBlogBundle
services through :
- Normal Symfony
Dependency Injection
.
Example from a controller :
namespace App\Controller;
use Goulmima\BlogBundle\Utils\Aggregation\AggregatorInterface;
/**
* @param AggregatorInterface $aggregator
* @return Response
*
* @Route("/default", name="default")
*/
public function index(AggregatorInterface $aggregator)
{
// retrieve sum of registered posts based on given `goulmima_blog.post.class`
$result = $aggregator->getSum();
}
- Using directly the
DefaultController
of the bundle.
Doing like so, you can access to sum of registered posts, by going to /some_prefix
or whatever the entry point you give to the bundle's routes
without any additional configuration.
goulmima_blog:
db_driver: 'orm' # see 'mongodb', api entry point ...
post:
class: 'App\Entity\BlogPost'
stats:
# type : amcharts4 full chart name using snake_case style
# axis : attribute name based on for axis
# abscissa : used function to get y = myFunction(x)
- { type: 'date_based_data', axis: 'createdAt', abscissa: 'myFunction' }
- { type: 'simple_column_chart', axis: 'createdAt', abscissa: 'myAnotherFunction' }