Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Use of Symfony components inside BackBee

Use of Symfony components inside BackBee

BackBee is a next generation content manager built on top of Doctrine and Symfony components. Together, let's see how we use and extends this components to provide to our users a software with CMS features and a great CMF capacities.

Mickaël Andrieu

April 15, 2015
Tweet

More Decks by Mickaël Andrieu

Other Decks in Programming

Transcript

  1. 2 15 AVRIL 2015 What is BackBee ? Open source

    Content Manager, on top of Doctrine and Symfony components. An extensible but simple content manager 1 promise : FRONT = BACK
  2. 3 AVRIL 2015 The big picture : The « Standard

    Edition » BackBee Core BackBee Javascript Client Templating BackBee Infrastructure Applications Components Core API REST PHP Twig Smarty … Symfony Components Doctrine ORM Security / ACL Workflow Search Routing Events Profiler Logging Cache Config Bundle Contribution User Main Content … Bundle Auth Datastore FormBuilder … Translator TreeView LinkSelector i18n Request/Response REST
  3. 4 15 AVRIL 2015 Symfony & Doctrine contributions • Config

    • Console • Debug • DependencyInjection • EventDispatcher • ExpressionLanguage • FileSystem • HttpFoundation • HttpKernel • Routing • Security-Core • Security-ACL • Security-HTTP • Serializer • Translation • Validator • Yaml • Doctrine/Bridge • Doctrine/DBAL • Doctrine/ORM • Twig
  4. 5 15 AVRIL 2015 The contribution of Symfony in BackBee

    5 components required by BackBee Core • HttpKernel (Application, Bundles) • HttpFoundation (Request/Response) • Event Dispatcher • Dependency Injection • Security
  5. 6 15 AVRIL 2015 Use of HttpKernel inside BackBee -

    1/3 Backee is a Symfony Application $application = new \BackBee\Standard\Application(null, ‘default’); BackBee use environments and application contexts. Each BackBee Bundle can load his configuration
  6. 7 15 AVRIL 2015 Use of HttpKernel inside BackBee -

    2/3 new \BackBee\Standard\Application(); new \BackBee\Standard\Application('preprod'); new \BackBee\Standard\Application(null, 'Api');
  7. 8 15 AVRIL 2015 Use of HttpKernel inside BackBee -

    3/3 new \BackBee\Standard\Application('preprod'); Like in Symfony framework, the configuration are merged « on cascade » vendor/backbee/backbee/Config/config.yml repository/Config/config.yml repository/Config/preprod/config.yml
  8. 9 15 AVRIL 2015 Use of HttpFoundation inside BackBee -

    1/2 A FrontController is in charge of return a Response from a Request. class FrontController implements Symfony\Component\HttpKernel\HttpKernelInterface { /* main request handler */ public function handle(Request $request = null,$type = self::MASTER_REQUEST, $catch = true) /* handles the request when none other action was found. */ public function defaultAction($uri = null, $sendResponse = true) /* specific request handlers */ public function rssAction($uri = null) public function rpcAction() }
  9. 10 15 AVRIL 2015 Use of HttpFoundation inside BackBee -

    2/2 A RestController is in charge of return an API JsonResponse. abstract class AbstractRestController extends BackBee\Controller\Controller\Controller implements RestControllerInterface, FormatterInterface { // Default formatter for a object(s) public function formatCollection($collection, $format = 'json|jsonp') public function formatItem($item, $format = 'json') // Deserialize data into Doctrine entity. public function deserializeEntity(array $data, $entityOrClass) // Create a Symfony JsonResponse. protected function createJsonResponse($data = null, $status = 200, $headers = array()) }
  10. 11 15 AVRIL 2015 DependencyInjection inside BackBee - 1/2 Backee

    is very extensible and powerful thanks to « services » ~150 services, to manage Security, Doctrine, « Page Workflow » … Each Bundle can register services and commands
  11. 12 15 AVRIL 2015 DependencyInjection inside BackBee - 2/2 In

    application/CMS context, register a service is very easy. # /Users/Mickael/projects/MyApp/repository/Config/services.yml parameters: bbapp.cache.dir: 'C:\Users\Mickael\projects\MyApp\cache' secret_key: ThisSecretKeyMustBeChanged services: my_custom_service: class: MyApp\Bundle\AppBundle\Services\MyCustomService arguments: - @mailer - @logger - %secret_key% calls: - [setCache, [%bbapp.cache.dir%]]
  12. 13 15 AVRIL 2015 Use of Security inside BackBee -

    1/2 BackBee provide a very precise management of rights; Users and Roles, and also Groups; Complete rights for a page, a block, a simple content;
  13. 14 15 AVRIL 2015 Use of Security inside BackBee -

    2/2 # /Users/Mickael/projects/MyApp/repository/Config/groups.yml contributor: sites: resources: all actions: none layouts: resources: all actions: none workflow: resources: all actions: none pages: resources: all actions: [view, create, edit] contents: resources: all actions: all
  14. 15 15 AVRIL 2015 The BackBee Page Building - 1/3

    We build Pages, based on Layouts and Contents; Each content in BackBee is at least an AbstractClassContent instance; The PageBuilder service is very extensible;
  15. 18 15 AVRIL 2015 The Content manager Based on PHP|Java

    ContentRepository specification; Definition of Contents in YAML, without any cache/database action; BackBee provides a list of basic Elements;
  16. 19 15 AVRIL 2015 The Content manager - Content Repository

    from phpcr.github.com All content is stored as a tree of Nodes; A Node has named Properties with values; Values can be scalar, file data or references to other nodes;
  17. 20 15 AVRIL 2015 The Content manager – Content definition

    No effect on the cache, without updating the database. # /Users/Mickael/projects/MyApp/repository/ClassContent/article.yml article: extends: BackBee\ClassContent\Breve traits: [BackBee\Traits\MyTrait] properties: name: Article description: | "An article contains a title, a main image and a customisable body" category: [article] elements: title: BackBee\ClassContent\Element\text image: BackBee\ClassContent\Media\image body: BackBee\ClassContent\article\paragraph
  18. 22 15 AVRIL 2015 BackBee is open source Github, of

    course ! A « QUALITY » approch You are welcome