sulu / ExampleNewsBundle

Sulu news example bundle
5 stars 3 forks source link

Sulu ExampleNewsBundle Tutorial

This is a step-by-step tutorial how to create an extension for Sulu. Each step is explained as a pull request against the previous step and with additional information in a blog-post on blog.sulu.io. It was built with the releases 1.1.* of Sulu.

Documentation

The master contains the whole code to run the example. The code foreach step comes in a single branch that build on the previous one. The first branch 00-symfony-bundle is a simple bundle-bootstrap which was generated by Symfony's generate:bundle command.

The steps are explained as pull requests, each building upon the previous branch and contains descriptions in form of comments and a link to the related blog-post.

Installation

To install the example use a fresh clone from sulu-standard and run following commands to clone this Repository into the right folder.

mkdir src/Example
cd src/Example
git clone https://github.com/sulu-io/ExampleNewsBundle.git NewsBundle

Apply following patch to enable and configure ExampleNewsBundle:

diff --git a/app/AbstractKernel.php b/app/AbstractKernel.php
index 8d149aa..e180d35 100644
--- a/app/AbstractKernel.php
+++ b/app/AbstractKernel.php
@@ -66,6 +66,8 @@ abstract class AbstractKernel extends SuluKernel

             // tools
             new Massive\Bundle\BuildBundle\MassiveBuildBundle(),
+
+            new Example\NewsBundle\ExampleNewsBundle(),
         ];

         if (in_array($this->getEnvironment(), ['dev', 'test'])) {
diff --git a/app/config/admin/routing.yml b/app/config/admin/routing.yml
index ae2ceb4..7047e47 100644
--- a/app/config/admin/routing.yml
+++ b/app/config/admin/routing.yml
@@ -88,3 +88,8 @@ client_website:
 sulu_search:
     resource: "@SuluSearchBundle/Resources/config/routing.yml"
     prefix: /admin/search
+
+example_news:
+    resource: "@ExampleNewsBundle/Resources/config/routing_api.xml"
+    type: rest
+    prefix: /admin/api

To build the translations follow the tutorial part 5.

At the end run following command to install assets of this bundle and update the database:

app/console assets:install --symlink --relative
app/console doctrine:schema:update --force

See also