|
| 1 | +How to Create and store a Symfony2 Project in Subversion |
| 2 | +======================================================== |
| 3 | + |
| 4 | +.. tip:: |
| 5 | + |
| 6 | + This entry is specifically about Subversion, and based on principles found |
| 7 | + in :doc:`/cookbook/workflow/new_project_git`. |
| 8 | + |
| 9 | +Once you've read through :doc:`/book/page_creation` and become familiar with |
| 10 | +using Symfony, you'll no-doubt be ready to start your own project. The |
| 11 | +preferred method to manage Symfony2 projects is using `git`_ but some people |
| 12 | +are stuck with `Subversion`_ and don't have a choice. In this cookbook article, |
| 13 | +you'll learn how to manage your project using `svn`_ in a similar manner you |
| 14 | +would do with `git`_. |
| 15 | + |
| 16 | +.. caution:: |
| 17 | + |
| 18 | + This is **a** method to import your Symfony2 project in a Subversion |
| 19 | + repository. There are several ways to do and this one is simply one that |
| 20 | + works. Furthermore, it is quite complex to do so you should probably |
| 21 | + consider using `git`_ anyway. |
| 22 | + |
| 23 | +Subversion repository |
| 24 | +--------------------- |
| 25 | + |
| 26 | +For this article we will suppose that your repository layout follows the |
| 27 | +widespread standard structure : |
| 28 | + |
| 29 | +.. code-block:: text |
| 30 | +
|
| 31 | + myproject/ |
| 32 | + branches/ |
| 33 | + tags/ |
| 34 | + trunk/ |
| 35 | +
|
| 36 | +.. tip:: |
| 37 | + |
| 38 | + Most of the subversion hosting should follow this standard practice. This |
| 39 | + is the recommended layout in `Version Control with Subversion`_ and the |
| 40 | + layout used by most free hosting (see :ref:`svn-hosting`). |
| 41 | + |
| 42 | +Initial Project Setup |
| 43 | +--------------------- |
| 44 | + |
| 45 | +To get started, you'll need to download Symfony2 and get the basic Subversion setup : |
| 46 | + |
| 47 | +1. Download the `Symfony2 Standard Edition`_ without vendors. |
| 48 | + |
| 49 | +2. Unzip/untar the distribution. It will create a folder called Symfony with |
| 50 | + your new project structure, config files, etc. Rename it to whatever you |
| 51 | + like. |
| 52 | + |
| 53 | +3. Checkout the Subversion repository that will host this project. Let's say it |
| 54 | + is hosted on `Google code`_ and called ``myproject``: |
| 55 | + |
| 56 | + .. code-block:: bash |
| 57 | + |
| 58 | + $ svn checkout http://myproject.googlecode.com/svn/trunk myproject |
| 59 | +
|
| 60 | +4. Copy the Symfony2 project files in the subversion folder: |
| 61 | + |
| 62 | + .. code-block:: bash |
| 63 | +
|
| 64 | + $ mv Symfony/* myproject/ |
| 65 | +
|
| 66 | +5. Let's now set the ignore rules, this is the complex part compared to `git`_. |
| 67 | + You need to add some specific files/folders to the subversion repository and |
| 68 | + edit ``svn:ignore`` properties: |
| 69 | + |
| 70 | + .. code-block:: bash |
| 71 | +
|
| 72 | + $ cd myproject/ |
| 73 | + $ svn add --depth=empty app app/cache app/logs app/config web |
| 74 | + $ svn propedit svn:ignore . |
| 75 | + vendor |
| 76 | + $ svn propedit svn:ignore app/ |
| 77 | + bootstrap* |
| 78 | + $ svn propedit svn:ignore app/config/ |
| 79 | + parameters.ini |
| 80 | + $ svn propedit svn:ignore app/cache/ |
| 81 | + * |
| 82 | + $ svn propedit svn:ignore app/logs/ |
| 83 | + * |
| 84 | + $ svn propedit svn:ignore web |
| 85 | + bundles |
| 86 | + $ svn ci -m "commit basic symfony ignore list (vendor, app/bootstrap*, app/config/parameters.ini, app/cache/*, app/logs/*, web/bundles)" |
| 87 | +
|
| 88 | +.. tip:: |
| 89 | + |
| 90 | + This part is a bit painful but this is the only way to make sure that those |
| 91 | + files and folders will **never** appear in your project repository. |
| 92 | + |
| 93 | +6. The rest of the files can now be added and commited to the project: |
| 94 | + |
| 95 | + .. code-block:: bash |
| 96 | +
|
| 97 | + $ svn add --force . |
| 98 | + $ svn ci -m "add basic Symfony Standard 2.X.Y" |
| 99 | +
|
| 100 | +7. Copy ``app/config/parameters.ini`` to ``app/config/parameters.ini.dist``. |
| 101 | + The ``parameters.ini`` file is ignored by svn (see above) so that |
| 102 | + machine-specific settings like database passwords aren't committed. By |
| 103 | + creating the ``parameters.ini.dist`` file, new developers can quickly clone |
| 104 | + the project, copy this file to ``parameters.ini``, customize it, and start |
| 105 | + developing. |
| 106 | + |
| 107 | +8. Finally, download all of the third-party vendor libraries: |
| 108 | + |
| 109 | + .. code-block:: bash |
| 110 | + |
| 111 | + $ php bin/vendors install |
| 112 | +
|
| 113 | +.. tip:: |
| 114 | + |
| 115 | + `git`_ has to be installed to run ``bin/vendors``, this is the protocol |
| 116 | + used to fetch vendor libraries. |
| 117 | + |
| 118 | +At this point, you have a fully-functional Symfony2 project, followed in your |
| 119 | +Subversion repository. The development can start with commits in the Subversion |
| 120 | +repository. |
| 121 | + |
| 122 | +You can continue to follow along with the :doc:`/book/page_creation` chapter |
| 123 | +to learn more about how to configure and develop inside your application. |
| 124 | + |
| 125 | +.. tip:: |
| 126 | + |
| 127 | + The Symfony2 Standard Edition comes with some example functionality. To |
| 128 | + remove the sample code, follow the instructions on the `Standard Edition Readme`_. |
| 129 | + |
| 130 | +.. _cookbook-managing-vendor-libraries: |
| 131 | + |
| 132 | +Managing Vendor Libraries with bin/vendors and deps |
| 133 | +--------------------------------------------------- |
| 134 | + |
| 135 | +Every Symfony project uses a large group of third-party "vendor" libraries. |
| 136 | + |
| 137 | +By default, these libraries are downloaded by running the ``php bin/vendors install`` |
| 138 | +script. This script reads from the ``deps`` file, and downloads the given |
| 139 | +libraries into the ``vendor/`` directory. It also reads ``deps.lock`` file, |
| 140 | +pinning each library listed there to the exact git commit hash. |
| 141 | + |
| 142 | +In this setup, the vendors libraries aren't part of your repository, |
| 143 | +not even as submodules. Instead, we rely on the ``deps`` and ``deps.lock`` |
| 144 | +files and the ``bin/vendors`` script to manage everything. Those files are |
| 145 | +part of your repository, so the necessary versions of each third-party library |
| 146 | +are version-controlled, and you can use the vendors script to bring |
| 147 | +your project up to date. |
| 148 | + |
| 149 | +Whenever a developer clones a project, he/she should run the ``php bin/vendors install`` |
| 150 | +script to ensure that all of the needed vendor libraries are downloaded. |
| 151 | + |
| 152 | +.. sidebar:: Upgrading Symfony |
| 153 | + |
| 154 | + Since Symfony is just a group of third-party libraries and third-party |
| 155 | + libraries are entirely controlled through ``deps`` and ``deps.lock``, |
| 156 | + upgrading Symfony means simply upgrading each of these files to match |
| 157 | + their state in the latest Symfony Standard Edition. |
| 158 | + |
| 159 | + Of course, if you've added new entries to ``deps`` or ``deps.lock``, be sure |
| 160 | + to replace only the original parts (i.e. be sure not to also delete any of |
| 161 | + your custom entries). |
| 162 | + |
| 163 | +.. caution:: |
| 164 | + |
| 165 | + There is also a ``php bin/vendors update`` command, but this has nothing |
| 166 | + to do with upgrading your project and you will normally not need to use |
| 167 | + it. This command is used to freeze the versions of all of your vendor libraries |
| 168 | + by updating them to the version specified in ``deps`` and recording it |
| 169 | + into the ``deps.lock`` file. |
| 170 | + |
| 171 | +.. _svn-hosting: |
| 172 | + |
| 173 | +Subversion hosting solutions |
| 174 | +---------------------------- |
| 175 | + |
| 176 | +The biggest difference between `git`_ and `svn`_ is that Subversion *needs* a |
| 177 | +central repository to work. You then have several solutions : |
| 178 | + |
| 179 | +- Self hosting: create your own repository and access it either through the |
| 180 | + filesystem or the network. To help in this task you can read `Version Control |
| 181 | + with Subversion`_. |
| 182 | + |
| 183 | +- Third party hosting: there are a lot of serious free hosting solutions |
| 184 | + available like `GitHub`_, `Google code`_, `SourceForge`_ or `Gna`_. Some of them offer |
| 185 | + git hosting as well. |
| 186 | + |
| 187 | +.. _`git`: http://git-scm.com/ |
| 188 | +.. _`svn`: http://subversion.apache.org/ |
| 189 | +.. _`Subversion`: http://subversion.apache.org/ |
| 190 | +.. _`Symfony2 Standard Edition`: http://symfony.com/download |
| 191 | +.. _`Standard Edition Readme`: https://github.com/symfony/symfony-standard/blob/master/README.md |
| 192 | +.. _`Version Control with Subversion`: http://svnbook.red-bean.com/ |
| 193 | +.. _`GitHub`: http://github.com/ |
| 194 | +.. _`Google code`: http://code.google.com/hosting/ |
| 195 | +.. _`SourceForge`: http://sourceforge.net/ |
| 196 | +.. _`Gna`: http://gna.org/ |
0 commit comments