github/gitignore · Laravel.gitignore
Laravel .gitignore Template Explained
Why Laravel.gitignore ignores vendor, node_modules, .env, the public/storage symlink, Vite builds, Passport keys and auth.json.
Laravel.gitignore is for Laravel applications that install dependencies with Composer and npm. It combines rules similar to the .gitignore that ships with Laravel projects with files from development environments such as Homestead and Vagrant.
The most important entry is .env. Laravel reads the database password, APP_KEY, and mail and payment API keys all from .env, so if this file is committed, every secret of the application is exposed.
Rules explained
| Pattern | What it ignores and why |
|---|---|
/vendor/node_modules/ | DependenciesFolders recreated by composer install and npm install. Commit composer.lock and package-lock.json so everyone installs the same versions. |
.env.env.backup.env.production | Environment filesApplication secrets and per-environment settings. Share the list of variables through .env.example; this template does not ignore that file. |
public/storagepublic_html/storagestorage/*.key | Storage link and keysThe symlink created by php artisan storage:link and Passport's OAuth private key (oauth-private.key). The link is recreated on each server, and the key is secret. |
/public/buildpublic/hotpublic_html/hotnpm-debug.logyarn-error.log | Frontend buildsBuild output from Vite and the hot file that signals the dev server is running. If the hot file is committed, the production server tries to load assets from a dev server that does not exist. |
.phpunit.result.cache/.phpunit.cache | Test cachesA cache in which PHPUnit remembers things such as the order of failed tests. |
Homestead.yamlHomestead.json/.vagrant.phpactor.json/storage/pail | Development environment and toolsPersonal Homestead settings, Vagrant state, Phpactor settings and Laravel Pail log files. |
auth.json | Composer authenticationThe Composer authentication file that stores tokens and passwords for private package repositories. |
bootstrap/compiled.phpapp/storage/ | Legacy pathsThe compiled file and storage path from the Laravel 4 era. They are not created by recent versions. |
Practical notes
- Commit
.env.examplewith placeholders instead of real values. - The
app,frameworkandlogsfolders understorage/contain nested .gitignore files that Laravel ships by default; do not delete them. - If
.envended up in history, changeAPP_KEYwithphp artisan key:generateand rotate the database and API passwords too.
Original template
Laravel.gitignore
/vendor/node_modules/npm-debug.logyarn-error.log# Laravel 4 specificbootstrap/compiled.phpapp/storage/# Laravel 5 & Lumen specificpublic/storagepublic/hot# Laravel 5 & Lumen specific with changed public pathpublic_html/storagepublic_html/hotstorage/*.key.envHomestead.yamlHomestead.json/.vagrant.phpunit.result.cache/.phpunit.cache/public/build/storage/pail.env.backup.env.production.phpactor.jsonauth.json
Templates from github/gitignore/Laravel.gitignore @356fd7b (2026-09-11) · CC0-1.0