.gitignore pour Symfony
29 règles d’exclusion pour Symfony, prêtes à copier dans votre dépôt.
Framework d'application web PHP
Le .gitignore complet pour Symfony
# Generated by LFGitignore - https://lfgitignore.com
# Created: 2025-08-02 05:19:27 UTC
# Technologies: Symfony
### Symfony ###
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
/app/spool/*
/var/cache/*
/var/logs/*
/var/sessions/*
!var/cache/.gitkeep
!var/logs/.gitkeep
!var/sessions/.gitkeep
/var/log/*
!var/log/.gitkeep
/app/config/parameters.yml
/app/config/parameters.ini
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/
/web/bundles/
/web/uploads/
/app/phpunit.xml
/phpunit.xml
/build/
/composer.phar
**/Entity/*~
/.web-server-pid
Ce que ces règles Symfony ignorent vraiment
Chaque motif ci-dessous, et pourquoi il a sa place dans votre .gitignore.
Cache and logs (Symfony2)
| Motif | Ce qu’il ignore |
|---|---|
/app/cache/* |
Cache and logs (Symfony2) |
/app/logs/* |
Cache and logs (Symfony2) |
!app/cache/.gitkeep |
Cache and logs (Symfony2) |
!app/logs/.gitkeep |
Cache and logs (Symfony2) |
Email spool folder
| Motif | Ce qu’il ignore |
|---|---|
/app/spool/* |
Email spool folder |
Cache, session files and logs (Symfony3)
| Motif | Ce qu’il ignore |
|---|---|
/var/cache/* |
Cache, session files and logs (Symfony3) |
/var/logs/* |
Cache, session files and logs (Symfony3) |
/var/sessions/* |
Cache, session files and logs (Symfony3) |
!var/cache/.gitkeep |
Cache, session files and logs (Symfony3) |
!var/logs/.gitkeep |
Cache, session files and logs (Symfony3) |
!var/sessions/.gitkeep |
Cache, session files and logs (Symfony3) |
Logs (Symfony4)
| Motif | Ce qu’il ignore |
|---|---|
/var/log/* |
Logs (Symfony4) |
!var/log/.gitkeep |
Logs (Symfony4) |
Parameters
| Motif | Ce qu’il ignore |
|---|---|
/app/config/parameters.yml |
Parameters |
/app/config/parameters.ini |
Parameters |
Managed by Composer
| Motif | Ce qu’il ignore |
|---|---|
/app/bootstrap.php.cache |
Managed by Composer |
/var/bootstrap.php.cache |
Managed by Composer |
/bin/* |
Managed by Composer |
!bin/console |
Managed by Composer |
!bin/symfony_requirements |
Managed by Composer |
/vendor/ |
Managed by Composer |
Assets and user uploads
| Motif | Ce qu’il ignore |
|---|---|
/web/bundles/ |
Assets and user uploads |
/web/uploads/ |
Assets and user uploads |
PHPUnit
| Motif | Ce qu’il ignore |
|---|---|
/app/phpunit.xml |
PHPUnit |
/phpunit.xml |
PHPUnit |
Build data
| Motif | Ce qu’il ignore |
|---|---|
/build/ |
Build data |
Composer PHAR
| Motif | Ce qu’il ignore |
|---|---|
/composer.phar |
Composer PHAR |
Backup entities generated with doctrine:generate:entities command
| Motif | Ce qu’il ignore |
|---|---|
**/Entity/*~ |
Backup entities generated with doctrine:generate:entities command |
Embedded web-server pid file
| Motif | Ce qu’il ignore |
|---|---|
/.web-server-pid |
Embedded web-server pid file |
Comment utiliser ce .gitignore pour Symfony
- Copiez les règles Symfony ci-dessus, ou téléchargez directement le fichier.
- Créez un fichier nommé .gitignore à la racine de votre dépôt Git et collez-y les règles.
- Si certains de ces fichiers sont déjà suivis, lancez git rm -r --cached . puis recommitez — Git n’applique les règles d’exclusion qu’aux fichiers non suivis.
- Commitez le .gitignore pour que toute l’équipe partage les mêmes règles.