Skip to content
gitignore collection file
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Initial commit Mar 6, 2016 editorconfig Mar 18, 2016
laravel.gitignore .dev.example not ignore by default Mar 23, 2016
magento1.gitignore Update magento1.gitignore Jan 19, 2017
magento2.gitignore smart surname Mar 11, 2016
php.gitignore Update php.gitignore Sep 29, 2016
symfony2.gitignore maj sf Mar 11, 2016
unix.editorconfig editorconfig Mar 18, 2016
wordpress4.gitignore Update wordpress4.gitignore Apr 29, 2016

Smart Gitignore rules for PHP projects

This is a model of .gitignore file for your PHP project. It differs from other models you can see, in GitHub for example, because of the use of regular expressions and exceptions, making the file shorter and the rules smarter and more adaptative to any kind of projects.

French users : my original french article for more détails.

Download theses .gitignore contents by PHP-CLI

If you have local HTTP server with PHP-CLI/SAPI running, being in your project root path, type in console command :

  • PHP projects (main rules) :

php -r "readfile('');">>.gitignore

  • Additional rules for Symfony 2, 3, Silex, Oro Platform, AkeneoPIM :

php -r "readfile('');">>.gitignore

  • Additional rules for Laravel / Lumen :

php -r "readfile('');">>.gitignore

  • Additional rules for Magento 2 :

php -r "readfile('');">>.gitignore

  • Additional rules for Magento 1 :

php -r "readfile('');">>.gitignore

or php -r "readfile('');">>.gitignore if you want to exclude all core files from your repository.

  • Additional rules for Wordpress 4 :

php -r "readfile('');">>.gitignore

Hint #1 : you can also define global gitignore file for all your project :

git config --edit --global

Insert this (and adapt with the path you want) :

	excludesfile = C:\\Users\\MyUser\\.gitignore

So then you will avoid to annoy your teammates pushing new rules in the .gitignore projects for your IDE or tools.

Hint #2 : setup a Unix-style configuration of files for Git and your IDE

Very useful for PHP developers (production environments are always GNU/Unix family). You can force that in

  • In your IDE : you will need a EditorConfig plugin plugged in your IDE for that. Then, always project root path, type in console command :

php -r "readfile('');">>.editorconfig

  • In your Git config : type git config --edit --global for global config or git config --edit for only a project config.

Insert/Replace this in your file :

	eol = lf
	safecrlf = false
	autocrlf = input
	whitespace = cr-at-eol


If you can also add this in the config file to optimize your git experience :

    postBuffer = 524288000
    default = matching
    mnemonicPrefix = true
    # for windows : wincred. linux : store
    helper = wincred
    ui = auto
    branch = auto
    diff = auto
    interactive = auto
    status = auto
    rzh= reset HEAD
    df = diff
    st = status
    aa = add .
    acm= commit -am
    cm = commit -m
    ci = commit
    co = checkout
    br = branch
    lg = log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset'
    gl = log --oneline --all --graph --decorate
    oops    = commit --amend --no-edit
    pusha   = push -vu origin --all
    pushm   = push -vu origin master --tags
    pushd   = push -vu origin develop --tags
    pullm   = pull origin master
    pulld   = pull origin develop
    mapm    = branch --set-upstream-to=origin/master master
    mapd    = branch --set-upstream-to=origin/develop develop
You can’t perform that action at this time.