installation.rst 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/AdminBundle.git src/Sonata/AdminBundle
  11. git submodule add git@github.com:sonata-project/MenuBundle.git src/Knplabs/Bundle/MenuBundle
  12. Next, be sure to enable the bundles in your application kernel:
  13. .. code-block:: php
  14. // app/autoload.php
  15. $loader->registerNamespaces(array(
  16. // ...
  17. 'Sonata' => __DIR__.'/../src',
  18. 'Knplabs' => __DIR__.'/../src',
  19. // ...
  20. ));
  21. // app/AppKernel.php
  22. public function registerBundles()
  23. {
  24. return array(
  25. // ...
  26. new Sonata\jQueryBundle\SonatajQueryBundle(),
  27. new Sonata\BluePrintBundle\SonataBluePrintBundle(),
  28. new Sonata\AdminBundle\SonataAdminBundle(),
  29. new Knplabs\Bundle\MenuBundle\KnplabsMenuBundle(),
  30. // ...
  31. );
  32. }
  33. Configuration
  34. -------------
  35. The bundle also contains several routes. Import them by adding the following
  36. code to your application's routing file:
  37. - Add the AdminBundle's routing definition
  38. .. code-block:: yaml
  39. # app/config/routing.yml
  40. admin:
  41. resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
  42. prefix: /admin
  43. _sonata_admin:
  44. resource: .
  45. type: sonata_admin
  46. prefix: /admin
  47. At this point you can access to the dashboard with the url: ``http://yoursite.local/admin/dashboard``.
  48. .. note::
  49. If you're using XML or PHP to specify your application's configuration,
  50. the above configuration and routing will actually be placed in those
  51. files, with the correct format (i.e. XML or PHP).
  52. Declaring new Entity
  53. --------------------
  54. Once you have created an admin class, you must declare the class to use it. Like ::
  55. .. code-block:: xml
  56. # app/config/config.xml
  57. <service id="sonata.news.admin.post" class="Sonata\NewsBundle\Admin\PostAdmin">
  58. <tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/>
  59. <argument>Sonata\NewsBundle\Entity\Post</argument>
  60. <argument>SonataNewsBundle:PostAdmin</argument>
  61. </service>