installation.rst 2.6 KB

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