Skip to content

Instantly share code, notes, and snippets.

@mattattui
Created August 7, 2011 18:49
Show Gist options
  • Save mattattui/1130644 to your computer and use it in GitHub Desktop.
Save mattattui/1130644 to your computer and use it in GitHub Desktop.
Starting a Symfony2 project with Git
  1. Download the Symfony2 standard distribution without vendors

  2. Unzip/untar the distribution. It will create a folder called Symfony with your new project structure, config files, etc. Rename it to whatever you like.

  3. Create a new file called .gitignore and paste the following into it:

      web/bundles/  
      app/bootstrap*  
      app/cache/*  
      app/logs/*  
      build/  
      vendor/  
      app/config/parameters.ini  
    
  4. Copy app/config/parameters.ini to app/config/parameters.ini-dist -- this will keep your passwords out of the git repository, and will also allow other developers to use different database settings, etc.

  5. Type git init to start a new repository

  6. git add * to add everything we've just done

  7. git commit -m "Initial commit"

  8. Now to get your vendors - run php bin/vendors install.

Notes:

  • Your repository isn't safe yet! You should either set up a bare clone on another server and push to it, or even more simply (if you don't mind paying or making it public), set it up on GitHub.
  • Whenever you need to update, update your deps and deps.lock files, then run bin/vendors install again (upgrade doesn't do what you probably think it does!)
  • In this setup, the vendors aren't part of your git repository, not even as submodules. Instead, we rely on the deps and deps.lock files and the bin/vendors script to manage these. Those files are part of your repository, so the necessary versions of each third-party library are version-controlled in git, and you can just use the vendors script to bring your project up to date.
  • It's important to set up your .gitignore file and commit it before you run the vendors script, because the script finishes by running Symfony2, which will create a bunch of cache files and stuff you probably don't want in your repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment