{"id":20529355,"url":"https://github.com/eliashaeussler/gitattributes","last_synced_at":"2025-04-14T05:06:52.694Z","repository":{"id":260092118,"uuid":"880157880","full_name":"eliashaeussler/gitattributes","owner":"eliashaeussler","description":"🍄 PHP library for object-oriented .gitattributes file handling","archived":false,"fork":false,"pushed_at":"2024-11-08T16:36:03.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-08T17:31:29.001Z","etag":null,"topics":["composer-package","gitattributes"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eliashaeussler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["eliashaeussler"],"custom":["https://paypal.me/eliashaeussler"]}},"created_at":"2024-10-29T08:18:36.000Z","updated_at":"2024-11-08T16:31:51.000Z","dependencies_parsed_at":"2024-10-29T13:54:28.959Z","dependency_job_id":null,"html_url":"https://github.com/eliashaeussler/gitattributes","commit_stats":null,"previous_names":["eliashaeussler/gitattributes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fgitattributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fgitattributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fgitattributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fgitattributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliashaeussler","download_url":"https://codeload.github.com/eliashaeussler/gitattributes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224859697,"owners_count":17381676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","gitattributes"],"created_at":"2024-11-15T23:31:18.521Z","updated_at":"2024-11-15T23:32:32.955Z","avatar_url":"https://github.com/eliashaeussler.png","language":"PHP","readme":"\u003cdiv align=\"center\"\u003e\n\n# Object-oriented `.gitattributes` file handling\n\n[![Coverage](https://img.shields.io/coverallsCoverage/github/eliashaeussler/gitattributes?logo=coveralls)](https://coveralls.io/github/eliashaeussler/gitattributes)\n[![Maintainability](https://img.shields.io/codeclimate/maintainability/eliashaeussler/gitattributes?logo=codeclimate)](https://codeclimate.com/github/eliashaeussler/gitattributes/maintainability)\n[![CGL](https://img.shields.io/github/actions/workflow/status/eliashaeussler/gitattributes/cgl.yaml?label=cgl\u0026logo=github)](https://github.com/eliashaeussler/gitattributes/actions/workflows/cgl.yaml)\n[![Tests](https://img.shields.io/github/actions/workflow/status/eliashaeussler/gitattributes/tests.yaml?label=tests\u0026logo=github)](https://github.com/eliashaeussler/gitattributes/actions/workflows/tests.yaml)\n[![Supported PHP Versions](https://img.shields.io/packagist/dependency-v/eliashaeussler/gitattributes/php?logo=php)](https://packagist.org/packages/eliashaeussler/gitattributes)\n\n\u003c/div\u003e\n\nA PHP library to parse and dump `.gitattributes` file in an object-oriented way. The library\nprovides a `GitattributesDumper` and `GitattributesParser` to either read or write contents\nto or from `.gitattributes` files. All attributes as of Git v2.46.0 according to the\n[official documentation](https://git-scm.com/docs/gitattributes) are supported.\n\n## 🔥 Installation\n\n[![Packagist](https://img.shields.io/packagist/v/eliashaeussler/gitattributes?label=version\u0026logo=packagist)](https://packagist.org/packages/eliashaeussler/gitattributes)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/eliashaeussler/gitattributes?color=brightgreen)](https://packagist.org/packages/eliashaeussler/gitattributes)\n\n```bash\ncomposer require eliashaeussler/gitattributes\n```\n\n## ⚡ Usage\n\n### Parse rules from `.gitattributes` file\n\nThe main parsing functionality is provided by the [`GitattributesParser`](src/GitattributesParser.php).\nIt can be used as follows:\n\n```php\nuse EliasHaeussler\\Gitattributes;\n\n$parser = new Gitattributes\\GitattributesParser(__DIR__);\n$ruleset = $parser-\u003eparse('.gitattributes');\n```\n\nThe returned ruleset contains the original filename as well as all parsed rules as instances of\n[`Rule\\Rule`](src/Rule/Rule.php). A rule contains the file pattern and a list of attributes:\n\n```php\nforeach ($ruleset-\u003erules() as $rule) {\n    echo $rule-\u003epattern()-\u003etoString().' ';\n\n    foreach ($rule-\u003eattributes() as $attribute) {\n        echo $attribute-\u003etoString().' ';\n    }\n\n    echo PHP_EOL;\n}\n```\n\n\u003e [!IMPORTANT]\n\u003e Only attribute names listed in the [official documentation](https://git-scm.com/docs/gitattributes)\n\u003e are supported by the library. Using other than the supported attributes will raise an exception.\n\u003e See [`Rule\\Attribute\\AttributeName`](src/Rule/Attribute/AttributeName.php) for an overview.\n\n### Dump `.gitattributes` file from rules\n\nIt is also possible to create a new `.gitattributes` file by dumping a list of prepared rules.\nThis functionality is provided by the [`GitattributesDumper`](src/GitattributesDumper.php):\n\n```php\nuse EliasHaeussler\\Gitattributes;\n\n$rules = [\n    // You can create rules in an object-oriented way\n    new Gitattributes\\Rule\\Rule(\n        new Gitattributes\\Rule\\Pattern\\FilePattern('/tests'),\n        [\n            Gitattributes\\Rule\\Attribute\\Attribute::set(Gitattributes\\Rule\\Attribute\\AttributeName::ExportIgnore),\n        ],\n    ),\n    // ... or using a string input\n    Gitattributes\\Rule\\Rule::fromString('/phpunit.xml export-ignore'),\n];\n\n$dumper = new Gitattributes\\GitattributesDumper(__DIR__);\n$result = $dumper-\u003edump('.gitattributes', $rules);\n```\n\n\u003e [!NOTE]\n\u003e A file must not exist when dumping file contents. Otherwise, an exception is thrown.\n\n## 🧑‍💻 Contributing\n\nPlease have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\n## ⭐ License\n\nThis project is licensed under [GNU General Public License 3.0 (or later)](LICENSE).\n","funding_links":["https://github.com/sponsors/eliashaeussler","https://paypal.me/eliashaeussler"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliashaeussler%2Fgitattributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliashaeussler%2Fgitattributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliashaeussler%2Fgitattributes/lists"}