installation.rst 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Installation
  2. ============
  3. Download bundles
  4. ----------------
  5. To begin, add the dependent bundles to the ``vendor/bundles`` directory. Add
  6. the following lines to the file ``deps``::
  7. [SonatajQueryBundle]
  8. git=http://github.com/sonata-project/SonatajQueryBundle.git
  9. target=/bundles/Sonata/jQueryBundle
  10. [SonataUserBundle]
  11. git=http://github.com/sonata-project/SonataUserBundle.git
  12. target=/bundles/Sonata/UserBundle
  13. [SonataAdminBundle]
  14. git=http://github.com/sonata-project/SonataAdminBundle.git
  15. target=/bundles/Sonata/AdminBundle
  16. [MenuBundle]
  17. git=http://github.com/knplabs/KnpMenuBundle.git
  18. target=/bundles/Knp/Bundle/MenuBundle
  19. [KnpMenu]
  20. git=https://github.com/knplabs/KnpMenu.git
  21. target=/knp/menu
  22. and run::
  23. bin/vendors install
  24. Configuration
  25. -------------
  26. Next, be sure to enable the bundles in your autoload.php and AppKernel.php
  27. files:
  28. .. code-block:: php
  29. <?php
  30. // app/autoload.php
  31. $loader->registerNamespaces(array(
  32. // ...
  33. 'Sonata' => __DIR__.'/../vendor/bundles',
  34. 'Knp' => array(
  35. __DIR__.'/../vendor/bundles',
  36. __DIR__.'/../vendor/knp/menu/src',
  37. ),
  38. // ...
  39. ));
  40. // app/AppKernel.php
  41. public function registerBundles()
  42. {
  43. return array(
  44. // ...
  45. new Sonata\jQueryBundle\SonatajQueryBundle(),
  46. new Sonata\AdminBundle\SonataAdminBundle(),
  47. new Knp\Bundle\MenuBundle\KnpMenuBundle(),
  48. // ...
  49. );
  50. }
  51. The bundle also contains several routes. Import them by adding the following
  52. code to your application's routing file:
  53. .. code-block:: yaml
  54. # app/config/routing.yml
  55. admin:
  56. resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
  57. prefix: /admin
  58. _sonata_admin:
  59. resource: .
  60. type: sonata_admin
  61. prefix: /admin
  62. Now, install the assets from the different bundles:
  63. ``php app/console assets:install web --symlink``.
  64. At this point you can access to the dashboard with the url:
  65. ``http://yoursite.local/admin/dashboard``.
  66. .. note::
  67. If you're using XML or PHP to specify your application's configuration,
  68. the above configuration and routing will actually be placed in those
  69. files, with the correct format (i.e. XML or PHP).
  70. The last important step is security, please refer to the dedicated section.