installation.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Installation
  2. ============
  3. 1. Using Composer (recommended)
  4. -------------------------------
  5. To install JMSSerializerBundle with Composer just add the following to your
  6. `composer.json` file:
  7. .. code-block :: js
  8. // composer.json
  9. {
  10. // ...
  11. require: {
  12. // ...
  13. "jms/serializer-bundle": "dev-master"
  14. }
  15. }
  16. .. note ::
  17. Please replace `dev-master` in the snippet above with the latest stable
  18. branch, for example ``1.0.*``.
  19. Then, you can install the new dependencies by running Composer's ``update``
  20. command from the directory where your ``composer.json`` file is located:
  21. .. code-block :: bash
  22. $ php composer.phar update
  23. Now, Composer will automatically download all required files, and install them
  24. for you. All that is left to do is to update your ``AppKernel.php`` file, and
  25. register the new bundle:
  26. .. code-block :: php
  27. <?php
  28. // in AppKernel::registerBundles()
  29. $bundles = array(
  30. // ...
  31. new JMS\SerializerBundle\JMSSerializerBundle($this),
  32. // ...
  33. );
  34. 2. Using the ``deps`` file (Symfony 2.0.x)
  35. ------------------------------------------
  36. First, checkout a copy of the code. Just add the following to the ``deps``
  37. file of your Symfony Standard Distribution:
  38. .. code-block :: ini
  39. [JMSSerializerBundle]
  40. git=git://github.com/schmittjoh/JMSSerializerBundle.git
  41. target=bundles/JMS/SerializerBundle
  42. Then register the bundle with your kernel:
  43. .. code-block :: php
  44. <?php
  45. // in AppKernel::registerBundles()
  46. $bundles = array(
  47. // ...
  48. new JMS\SerializerBundle\JMSSerializerBundle($this),
  49. // ...
  50. );
  51. This bundle also requires the Metadata library (**you need the 1.1 version, not the 1.0
  52. version** which ships with the Symfony Standard Edition.):
  53. .. code-block :: ini
  54. [metadata]
  55. git=http://github.com/schmittjoh/metadata.git
  56. version=1.1.0
  57. Make sure that you also register the namespaces with the autoloader:
  58. .. code-block :: php
  59. <?php
  60. // app/autoload.php
  61. $loader->registerNamespaces(array(
  62. // ...
  63. 'JMS' => __DIR__.'/../vendor/bundles',
  64. 'Metadata' => __DIR__.'/../vendor/metadata/src',
  65. // ...
  66. ));
  67. Now use the ``vendors`` script to clone the newly added repositories
  68. into your project:
  69. .. code-block :: bash
  70. $ php bin/vendors install