× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Recommended gitignore for PHP web projects

Jad Joubran
Nov 06, 2014
<p>Gitignore specifies intentionally untracked files to ignore by git.</p><p>It is very common in modern web PHP projects to use the following:</p><ul><li>Composer (PHP Dependency manager)</li><li>NPM (node package manager)</li><li>Bower (front-end package manager)</li></ul><p>Not to mention that multiple developers are working on the same project, and development machines could be either Linux, Mac or Windows.</p><p>Based on this setup, below is a recommended .gitignore file:</p><pre><code>.DS_Store Thumbs.db npm-debug.log /bower_components /node_modules /vendor</code></pre><p> </p><p>Explanation:</p><ul><li><strong>.DS_Store</strong> is created by OS X and stores custom metadata. These files are hidden on OS X but will show up for Windows and Linux users.</li><li><strong>Thumbs.db</strong> is similar to DS_Store, mainly used for thumbnail cache.</li><li><strong>npm-debug.log</strong> is created whenever npm encounters an issue (it could be an issue with package.json or internet disconnection). You should definitely ignore this file because it bloats your git revision history and might cause conflicts if several developers commit it.</li><li><strong>bower_components</strong> folder stores bower’s downloaded packages. Check my article on why and how you should exclude bower_components from your source control.</li><li><strong>node_modules</strong> folder stores npm’s downloaded packages. These packages tend to have very large sizes and should definitely be excluded from git.</li><li><strong>vendor</strong> folder stores packages downloaded by Composer. These packages should be excluded and every developer should maintain his own copy of vendor packages. Only the composer.json and composer.lock files should be committed.</li></ul>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus