installation.rst 3.4 KB

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