installation.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Installation
  2. ============
  3. Make sure you have ``Sonata`` and ``Knplabs`` exists, if not create them::
  4. mkdir src/Sonata
  5. mkdir src/Knplabs
  6. To begin, add the dependent bundles to the ``src/`` directory. If using
  7. git, you can add them as submodules::
  8. git submodule add git@github.com:sonata-project/jQueryBundle.git src/Sonata/jQueryBundle
  9. git submodule add git@github.com:sonata-project/BluePrintBundle.git src/Sonata/BluePrintBundle
  10. git submodule add git@github.com:sonata-project/BaseApplicationBundle.git src/Sonata/BaseApplicationBundle
  11. git submodule add git@github.com:sonata-project/MenuBundle.git src/Knplabs/MenuBundle
  12. Next, be sure to enable the bundles in your application kernel:
  13. .. code-block:: php
  14. // app/AppKernel.php
  15. public function registerBundles()
  16. {
  17. return array(
  18. // ...
  19. new Sonata\jQueryBundle\SonatajQueryBundle(),
  20. new Sonata\BluePrintBundle\SonataBluePrintBundle(),
  21. new Sonata\BaseApplicationBundle\SonataBaseApplicationBundle(),
  22. new Knplabs\Knplabs\KnplabsMenuBundle(),
  23. // ...
  24. );
  25. }
  26. Configuration
  27. -------------
  28. To use the ``BaseApplicationBundle``, add the following to your application
  29. configuration file.
  30. .. code-block:: yaml
  31. # app/config/config.yml
  32. sonata_base_application: ~
  33. menu.twig: ~
  34. The bundle also contains several routes. Import them by adding the following
  35. code to your application's routing file:
  36. - Add the BaseApplicationBundle's routing definition
  37. .. code-block:: yaml
  38. # app/config/routing.yml
  39. base_application:
  40. resource: '@SonataBaseApplicationBundle/Resources/config/routing/base_application.xml'
  41. prefix: /admin
  42. admin:
  43. resource: '@SonataBaseApplicationBundle/Resources/config/routing/base_application.admin'
  44. prefix: /admin
  45. At this point you can access to the dashboard with the url: ``http://yoursite.local/admin/dashboard``.
  46. .. note::
  47. If you're using XML or PHP to specify your application's configuration,
  48. the above configuration and routing will actually be placed in those
  49. files, with the correct format (i.e. XML or PHP).
  50. Declaring new Entity
  51. --------------------
  52. Once you have created an admin class, you must declare the class to use it. Like ::
  53. .. code-block:: yaml
  54. # app/config/config.yml
  55. sonata_base_application:
  56. entities:
  57. post:
  58. label: Post
  59. group: blog
  60. class: Sonata\NewsBundle\Admin\PostAdmin
  61. entity: Application\Sonata\NewsBundle\Entity\Post
  62. controller: SonataNewsBundle:PostAdmin
  63. tag:
  64. label: Tag
  65. group: blog
  66. class: Sonata\NewsBundle\Admin\TagAdmin
  67. entity: Application\Sonata\NewsBundle\Entity\Tag
  68. controller: SonataNewsBundle:TagAdmin
  69. comment:
  70. label: Comment
  71. group: blog
  72. class: Sonata\NewsBundle\Admin\CommentAdmin
  73. entity: Application\Sonata\NewsBundle\Entity\Comment
  74. controller: SonataNewsBundle:CommentAdmin