installation.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. Now, install the assets of the different bundles: ``php app/console assets:install web --symlink``.
  48. At this point you can access to the dashboard with the url: ``http://yoursite.local/admin/dashboard``.
  49. .. note::
  50. If you're using XML or PHP to specify your application's configuration,
  51. the above configuration and routing will actually be placed in those
  52. files, with the correct format (i.e. XML or PHP).
  53. Declaring new Entity
  54. --------------------
  55. Once you have created an admin class, you must declare the class to use it. Like ::
  56. .. code-block:: xml
  57. # app/config/config.xml
  58. <service id="sonata.news.admin.post" class="Sonata\NewsBundle\Admin\PostAdmin">
  59. <tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/>
  60. <argument>Sonata\NewsBundle\Entity\Post</argument>
  61. <argument>SonataNewsBundle:PostAdmin</argument>
  62. </service>