installation.rst 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Installation
  2. ============
  3. Set up the SonataUserBundle
  4. ---------------------------
  5. Add the bundle to your project:
  6. git://github.com/sonata-project/SonataUserBundle.git
  7. // dependency bundle
  8. git://github.com/sonata-project/SonataEasyExtendsBundle.git
  9. git://github.com/sonata-project/SonataAdminBundle.git
  10. Adjust your autoload.php so they are found.
  11. In your AppKernel you enable the bundles:
  12. .. code-block:: php
  13. <?php
  14. // app/appkernel.php
  15. public function registerbundles()
  16. {
  17. return array(
  18. // ...
  19. // You have 2 options to initialize the SonataUserBundle in your AppKernel,
  20. // you can select which bundle SonataUserBundle extends
  21. // extend the ``FOSUserBundle``
  22. new Sonata\UserBundle\SonataUserBundle('FOSUserBundle');
  23. // OR
  24. // the bundle will NOT extend ``FOSUserBundle``
  25. new Sonata\UserBundle\SonataUserBundle();
  26. new Sonata\AdminBundle\SonataAdminBundle(),
  27. new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
  28. // ...
  29. );
  30. }
  31. Generate the ApplicationSonataUserBundle
  32. ----------------------------------------
  33. At this point, the bundle is not yet ready. You need to generate the correct
  34. entities for the media::
  35. php app/console sonata:easy-extends:generate SonataUserBundle
  36. If you specify no parameter, the files are generated in app/Application/Sonata...
  37. but you can specify the path with ``--dest=src``
  38. .. note::
  39. The command will generate domain objects in an ``Application`` namespace.
  40. So you can point entities' associations to a global and common namespace.
  41. This will make Entities sharing easier as your models will allow to
  42. point to a global namespace. For instance the user will be
  43. ``Application\Sonata\UserBundle\Entity\User``.
  44. Set up the ApplicationSonataUserBundle
  45. --------------------------------------
  46. Now, add the new `Application` Bundle into the kernel
  47. .. code-block:: php
  48. <?php
  49. public function registerbundles()
  50. {
  51. return array(
  52. // Application Bundles
  53. new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
  54. // Vendor specifics bundles
  55. new Sonata\UserBundle\SonataUserBundle(),
  56. new Sonata\AdminBundle\SonataAdminBundle(),
  57. new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
  58. );
  59. }
  60. Update the ``autoload.php`` to add a new namespace:
  61. .. code-block:: php
  62. <?php
  63. $loader->registerNamespaces(array(
  64. 'Sonata' => __DIR__.'../vendor/bundles',
  65. 'Application' => __DIR__,
  66. // ... other declarations
  67. ));
  68. Configuration
  69. -------------
  70. Then add these bundles in the config mapping definition (or enable `auto_mapping <http://symfony.com/doc/2.0/reference/configuration/doctrine.html#configuration-overview>`_):
  71. .. code-block:: yaml
  72. # app/config/config.yml
  73. doctrine:
  74. orm:
  75. entity_managers:
  76. default:
  77. mappings:
  78. ApplicationSonataUserBundle: ~
  79. SonataUserBundle: ~