Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env #20057

Closed
arcanedev-maroc opened this issue Sep 25, 2016 · 14 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@arcanedev-maroc
Copy link

The trick is by using the export-ignore: https://git-scm.com/docs/gitattributes#__code_export_ignore_code

This is useful when we want to upload the app into the shared host with FTP.

For example: https://github.com/ARCANEDEV/LogViewer/blob/master/.gitattributes

@linaori
Copy link
Contributor

linaori commented Sep 26, 2016

And don't forget all Tests directories 👍

@mvrhov
Copy link

mvrhov commented Sep 26, 2016

Please look at previous suggestions, this is a NO.

@linaori
Copy link
Contributor

linaori commented Sep 26, 2016

@mvrhov code that you use in production shouldn't have testing code or files that are not used in production. Even when developing you don't want all the files that come along with a framework but are not used by you (like test files). It greatly increases the amount of files which your IDE will index (especially with a FW as big as Symfony) and those files serve 0 purpose.

@mvrhov
Copy link

mvrhov commented Sep 26, 2016

No I want the tests. And I'm installing everything with preferred-install:dist For deploy I have a script which removes everything for me.

P.S. As said in another thread with the same debate:
We don't trust "composer". We commit all dependencies. It happened before the composer that the vendor code was nowhere to be found and the JavaScript example from a few months ago shows exactly what kinds of problems you can have if you don't have everything stored.

@linaori
Copy link
Contributor

linaori commented Sep 26, 2016

If you want the tests, clone the repository

@javiereguiluz javiereguiluz added the RFC RFC = Request For Comments (proposals about features that you want to be discussed) label Sep 26, 2016
@jakzal
Copy link
Contributor

jakzal commented Sep 26, 2016

re #17995 #11810 #5674

@linaori
Copy link
Contributor

linaori commented Sep 26, 2016

It seems to be a recurring subject and the only reason people want to have it, is something that can be achieved by additional means. I would like to quote Seldaek: #20032 (comment)

as you are trying to run phpunit as far as I understand, and not develop it.

We're trying to run Symfony in our own packages, not develop it. That means we don't need all the extra code neither in our development nor production servers.

When searching for classes, you always get polluted results;

People might end up hinting against those classes which is extremely unhelpful for newer developers. Next to this, your IDE autocompletion is polluted with stuff you don't care about (yes, even SessionTest will come up when looking at Session). In case you DO need the tests for what reason ever, you can always simply fork/clone the repository.

@arcanedev-maroc
Copy link
Author

Thanks @jakzal @iltar for including these references.

I know it's a big issue, because we need to split the ecosystem of our applications into separate environments (dev/testing/production) and the only way to "clean the mess" is by doing it manually for each project (and if we use a script to clean the packages, we need to maintain it).

Now Composer is a main tool for every PHP Developer, the --prefer-dist and --prefer-source doesn't make a big difference at this point in time because we end up with all the files used for development (docs, tests, examples, etc) for each installed package.

Who wants the tests/docs in their production environments ?

I love the Laravel framework approach for grouping all the tests into a single folder.

PS: @jakzal I love your talks/videos 👍.

@linaori
Copy link
Contributor

linaori commented Sep 26, 2016

@arcanedev-maroc the strategy that I follow is quite simple:

  "autoload": {
    "psr-4": {"Iltar\\HttpBundle\\": "src/"}
  },
  "autoload-dev": {
    "psr-4": {"Iltar\\HttpBundle\\": "test/"}
  }

I agree with (don't ever dare to quote me) Laravel on this matter, yet have to say that this is (nearly) impossible for Symfony due to the Subtree split.

Who wants the tests/docs in their production environments ?

I don't need them in dev either, I have a browser for this, they are just polluting my search results.

@nicolas-grekas
Copy link
Member

Then help fix editorconfig/editorconfig#228, this is the real issue...

@linaori
Copy link
Contributor

linaori commented Sep 26, 2016

It should still work if you have only poor tooling available (Say Eclipse PDT). I shouldn't have to rely on editors ignore stuff that shouldn't be there in the first place if you ask me and feels like a work-around for something. If I'm using command-line searching, the editor config won't really be of much service to me either afaik. With ~180 packages installed locally, I don't always use an IDE to open/edit/find stuff.

@jakzal
Copy link
Contributor

jakzal commented Sep 27, 2016

Another use case for making vendor dir lighter is to make docker images smaller. In the age of microservices this is becoming more and more important. Removing tests from the Symfony Demo cuts 13M. I know this could be done while building an image, but perhaps the end users should not have to think which part of Symfony is actual production code.

@arcanedev-maroc
Copy link
Author

arcanedev-maroc commented Sep 29, 2016

And there is more: #6047 #6374 #6605 #16174

@nicolas-grekas
Copy link
Member

Closing as already confirmed several times.
Note that with Flex, we're going to not use symfony/symfony directly that often anymore - that may help.

fabpot added a commit that referenced this issue Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (#29277)
Added .gitattributes files to root and all components (#26472)
Exclude non-essential files from Composer package (#25414)
[HttpFoundation] optimize files for distribution (#24427)
Add .gitattributes files (#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (#20057)
Add lightweight and root only .gitattributes (#18004)
Add .gitattributes to exclude tests from ZIPs (#17995)
[RFC] Move tests out of the source and source out of the tests (#17749)
Removal of development & testing files using .gitattributes (#16174)
Please add .gitattributes files and fix line endings (#13521)
making use of .gitattributes (#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24 Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/mailer that referenced this issue Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/web-profiler-bundle that referenced this issue Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this issue Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/cache that referenced this issue Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/yaml that referenced this issue Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/mailer that referenced this issue Sep 28, 2021
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

6 participants