.gitignore for Symfony

29 ignore rules for Symfony, ready to copy into your repository.

PHP web application framework

The complete .gitignore for 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

What these Symfony rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

Cache and logs (Symfony2)

Pattern What it ignores
/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

Pattern What it ignores
/app/spool/* Email spool folder

Cache, session files and logs (Symfony3)

Pattern What it ignores
/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)

Pattern What it ignores
/var/log/* Logs (Symfony4)
!var/log/.gitkeep Logs (Symfony4)

Parameters

Pattern What it ignores
/app/config/parameters.yml Parameters
/app/config/parameters.ini Parameters

Managed by Composer

Pattern What it ignores
/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

Pattern What it ignores
/web/bundles/ Assets and user uploads
/web/uploads/ Assets and user uploads

PHPUnit

Pattern What it ignores
/app/phpunit.xml PHPUnit
/phpunit.xml PHPUnit

Build data

Pattern What it ignores
/build/ Build data

Composer PHAR

Pattern What it ignores
/composer.phar Composer PHAR

Backup entities generated with doctrine:generate:entities command

Pattern What it ignores
**/Entity/*~ Backup entities generated with doctrine:generate:entities command

Embedded web-server pid file

Pattern What it ignores
/.web-server-pid Embedded web-server pid file

How to use this .gitignore for Symfony

  1. Copy the Symfony rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Framework .gitignore templates

See every Framework template