installation.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. [SonataAdminBundle]
  11. git=http://github.com/sonata-project/SonataAdminBundle.git
  12. target=/bundles/Sonata/AdminBundle
  13. [KnpMenuBundle]
  14. git=https://github.com/KnpLabs/KnpMenuBundle.git
  15. target=/bundles/Knp/Bundle/MenuBundle
  16. [KnpMenu]
  17. git=https://github.com/KnpLabs/KnpMenu.git
  18. target=/knp/menu
  19. and run::
  20. bin/vendors install
  21. Configuration
  22. -------------
  23. Next, be sure to enable the bundles in your autoload.php and AppKernel.php
  24. files:
  25. .. code-block:: php
  26. <?php
  27. // app/autoload.php
  28. $loader->registerNamespaces(array(
  29. // ...
  30. 'Sonata' => __DIR__.'/../vendor/bundles',
  31. 'Knp\Bundle' => __DIR__.'/../vendor/bundles',
  32. 'Knp\Menu' => __DIR__.'/../vendor/knp/menu/src',
  33. // ...
  34. ));
  35. // app/AppKernel.php
  36. public function registerBundles()
  37. {
  38. return array(
  39. // ...
  40. new Sonata\jQueryBundle\SonatajQueryBundle(),
  41. new Sonata\AdminBundle\SonataAdminBundle(),
  42. new Knp\Bundle\MenuBundle\KnpMenuBundle(),
  43. // ...
  44. );
  45. }
  46. The bundle also contains several routes. Import them by adding the following
  47. code to your application's routing file:
  48. .. code-block:: yaml
  49. # app/config/routing.yml
  50. admin:
  51. resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
  52. prefix: /admin
  53. _sonata_admin:
  54. resource: .
  55. type: sonata_admin
  56. prefix: /admin
  57. Now, install the assets from the different bundles:
  58. ``php app/console assets:install web --symlink``.
  59. At this point you can access to the dashboard with the url:
  60. ``http://yoursite.local/admin/dashboard``.
  61. .. note::
  62. If you're using XML or PHP to specify your application's configuration,
  63. the above configuration and routing will actually be placed in those
  64. files, with the correct format (i.e. XML or PHP).
  65. The last important step is security, please refer to the dedicated section of this documentation.
  66. Users management
  67. ----------------
  68. By default, the AdminBundle does not come with any user management, however it is most likely the application
  69. requires such feature. The Sonata Project includes a ``SonataUserBundle`` which integrates the ``FOSUserBundle``.
  70. The ``FOSUserBundle`` adds support for a database-backed user system in Symfony2. It provides a flexible framework
  71. for user management that aims to handle common tasks such as user login, registration and password retrieval.
  72. The ``SonataUserBundle`` is just a thin wrapper to include the ``FOSUserBundle`` into the ``AdminBundle``. The
  73. ``SonataUserBundle`` includes :
  74. * A default login area
  75. * A default ``user_block`` template which is used to display the current user and the logout link
  76. * 2 Admin classes : User and Group
  77. * A default class for User and Group.
  78. There is a little magic in the ``SonataAdminBundle`` if the bundle detects the ``SonataUserBundle`` class, then
  79. the default ``user_block`` template will be changed to use the one provided by the ``SonataUserBundle``.
  80. The install process is available on the dedicated `SonataUserBundle's documentation area <http://sonata-project.org/bundles/user/master/doc/reference/installation.html>`_