installation.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. _sonata_base_application:
  43. resource: .
  44. type: sonata_base_application
  45. prefix: /admin
  46. At this point you can access to the dashboard with the url: ``http://yoursite.local/admin/dashboard``.
  47. .. note::
  48. If you're using XML or PHP to specify your application's configuration,
  49. the above configuration and routing will actually be placed in those
  50. files, with the correct format (i.e. XML or PHP).
  51. Declaring new Entity
  52. --------------------
  53. Once you have created an admin class, you must declare the class to use it. Like ::
  54. .. code-block:: yaml
  55. # app/config/config.yml
  56. sonata_base_application:
  57. entities:
  58. post:
  59. label: Post
  60. group: blog
  61. class: Sonata\NewsBundle\Admin\PostAdmin
  62. entity: Application\Sonata\NewsBundle\Entity\Post
  63. controller: SonataNewsBundle:PostAdmin
  64. tag:
  65. label: Tag
  66. group: blog
  67. class: Sonata\NewsBundle\Admin\TagAdmin
  68. entity: Application\Sonata\NewsBundle\Entity\Tag
  69. controller: SonataNewsBundle:TagAdmin
  70. comment:
  71. label: Comment
  72. group: blog
  73. class: Sonata\NewsBundle\Admin\CommentAdmin
  74. entity: Application\Sonata\NewsBundle\Entity\Comment
  75. controller: SonataNewsBundle:CommentAdmin