42

I have a Laravel 4 project, and I would like to know which files should be ignored when using a version control software such as Git, Mercury or SVN?

The structure of my project looks like the following screen capture.

enter image description here

I'm pretty new to Composer so I'm not very clear about what goes to a repo and what not. If someone can post their .gitignore file or their SVN ignore property, it could be handy.

6
  • 7
    i think you can stick with the default .gitignore provided by the framework. by default it will ignore the vendor directory, plus the composer things and some others. i also add the entire app/storage folder to .gitignore, just because i dont want to version control the sessions, compiled views, cache, logs etc. Commented Jun 8, 2013 at 20:27
  • 4
    Another good one to ignore is workbench if you use it. That directory should only be used to develop packages. Commented Jun 9, 2013 at 2:16
  • @thinkers: If I clone your repository, I'll end up without an app/storage directory. I might want that in some cases, and I might not want that in other cases. I don't want the cache, logs, etc, but I think I do want the app/storage directory itself in the repo on a Laravel project. Commented Sep 27, 2013 at 2:05
  • @MikeSherrill'Catcall' instead you can add app/storage/<folder>/* to your .gitignore for every single folder you want to version control, then add a .gitkeep file in each of them. Commented Sep 29, 2013 at 18:52
  • 5
    You no longer need to add the storage directories to /.gitignore since there are already .gitignore files in those directories. (As of Laravel 4.0.8) Commented Oct 9, 2013 at 5:03

5 Answers 5

34

For reference, that .gitignore file can be found here:

/bootstrap/compiled.php
/vendor
composer.phar
composer.lock  # Remove this one after you create a project
.env.*.php
.env.php
.DS_Store
Thumbs.db

As noted in the below comment, you probably want to commit composer.lock in your project. Laravel ignores it by default so the authors of the laravel/laravel package don't accidently impose packages on you.

Your project should include the composer.lock file so you can install packages of stable versions (via composer install instead of composer update) properly in your production environments.

Sign up to request clarification or add additional context in comments.

10 Comments

"Commit your application's composer.lock (along with composer.json) into version control." -- getcomposer.org/doc/…
how about the storage/* folder?
I believe they are ignored already. Each directory within app/storage/ contains a .gitignore file to handle that.
What about /vendor? Why would that be in the ignore file?
So you don't add it unnecessarily into version control. Composer can install dependencies onto your production server for you. (composer install). Note that composer update will update to latest dependencies and download them while composer install will install based on items in composer.lock. You should keep composer.lock in version control and use $ composer install in production to ensure you get the version of software you expect. (Running composer update also updates composer.lock).
|
2

Note that the config file:

app/config/app.php

Has a cryptographic key in it that wouldn't be great to commit to a repository. Or, at least, the file needs to be overwritten in production.

1 Comment

That key (or any other sensitive information) can be overridden in production or any other environment without touching app/config/app.php. Just create a dot file in the root of you project as: .env.production.php and Laravel will override defined in any config file. Docs: laravel.com/docs/4.2/…
1

You might also want to see the Laravel docs here and here. This discusses how to setup different Laravel configurations for different environments and protect sensitive information. All your .env.local.php type files should not be included in version control. Note that the .env.*.php and .env.php is added in the default Laravel .gitignore file. You can see it here

Comments

1

Laravel has posted their .gitignore on GitHub, which can be found here.

As of today, it looks like this:

/bootstrap/compiled.php
/vendor
composer.phar
composer.lock
.env.*.php
.env.php
.DS_Store
Thumbs.db

1 Comment

composer.lock should be removed from .gitignore (getcomposer.org/doc/…)
0

GitHub has a repository of suggested .gitignore files for almost all kinds of projects at: http://github.com/github/gitignore

Alternatively, you can search it for your project using this handy and extremely useful online tool: http://www.gitignore.io

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.