Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Symfony's 'bin' directory be ignored by git?

Running composer install in a Symfony Standard Edition application with a requirement for Doctrine will add a folder called 'bin'. The folder is configured in composer.json:

"config": {
    "bin-dir": "bin"
}

The .gitignore file that comes with the Symfony Standard Edition includes the directory (causing git to ignore the directory and all it's contents). It seems like the 'bin' folder only contains links to files inside the 'vendor' folder. This leads me to think that it's a good idea to ignore the folder and let Composer handle it.

However, the example .gitignores from GitHub and in Symfony's docs doesn't include 'bin'. In fact, I can't really find much about this directory in the official Symfony docs at all, including whether or not it's recommended to keep it out of version control.

Is it indeed recommended to let git ignore this directory and its contents, and is Symfony's documentation simply not up-to-date?

like image 452
Nic Wortel Avatar asked May 02 '14 22:05

Nic Wortel


People also ask

What files should be ignored in Git?

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are: dependency caches, such as the contents of /node_modules or /packages. compiled code, such as .o , .

Where should be the Git ignore file?

gitignore is located in the root directory of your repo. / will ignore directories with the name.

Do I need a Git ignore?

Advantages of Git ignore gitignore file beyond ensuring specific files are not tracked by Git: It helps you keep your code repository clean by ignoring unwanted files. It keeps your repository size under control, which is especially helpful if you are working on a big project.

Does Git ignore the .Git folder?

It looks like git automatically ignores . git folders in subfolders of root repository. Hmm. When I commit and push as normal, the sub-project shows up in the repo as a reference, while other packages (from packagist) show up as files.


2 Answers

Symfony 3

In the Symfony 3 Standard Edition, the purpose of the bin directory has been slightly changed. Binaries from Composer packages (such as phpunit) are no longer installed in the bin directory, but in vendor/bin. Instead, the bin directory contains the console and symfony_requirements executables (and whatever executable files you add yourself).

Because these files should be committed to your Git repository, you should no longer have the bin directory in your .gitignore file.

like image 106
Nic Wortel Avatar answered Oct 11 '22 00:10

Nic Wortel


EDIT: This is answer is only applicable to Symfony 2. For Symfony 3 and later see Nic Wortels answer below.

Is it indeed recommended to let git ignore this directory and it's contents, and is Symfony's documentation simply not up-to-date?

This is indeed the case. The bin directory is the same as the vendor directory, it depends on your requirements. It should be ignored. Except if you are going to put custom files in it (e.g. you move app/console to bin/symfony), then it should be ignored except from those custom files.

The Symfony2.gitignore file from GitHub had it's last update 2 years ago. In those 2 years, a lot of things happend (like using Composer with Symfony2). I wouldn't recommend using it as an example.

The docs were indeed not up-to-date, if you hit the "edit" button in the docs you can update it yourself. I'll be very happy if you do that! :)

like image 24
Wouter J Avatar answered Oct 11 '22 00:10

Wouter J