{"id":13828421,"url":"https://github.com/antonioribeiro/yaml","last_synced_at":"2025-04-04T22:07:38.063Z","repository":{"id":27132713,"uuid":"112624437","full_name":"antonioribeiro/yaml","owner":"antonioribeiro","description":"A Laravel YAML parser and config loader","archived":false,"fork":false,"pushed_at":"2022-06-13T21:28:08.000Z","size":283,"stargazers_count":114,"open_issues_count":2,"forks_count":35,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-15T13:26:12.477Z","etag":null,"topics":["config","laravel","parser","php","yaml"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonioribeiro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-30T14:59:31.000Z","updated_at":"2024-05-10T08:12:20.000Z","dependencies_parsed_at":"2022-09-16T10:41:52.807Z","dependency_job_id":null,"html_url":"https://github.com/antonioribeiro/yaml","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fyaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fyaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fyaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fyaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonioribeiro","download_url":"https://codeload.github.com/antonioribeiro/yaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"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":["config","laravel","parser","php","yaml"],"created_at":"2024-08-04T09:02:45.974Z","updated_at":"2025-04-04T22:07:38.030Z","avatar_url":"https://github.com/antonioribeiro.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# YAML\n### A Laravel YAML parser and config loader\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://buddy.works/data/blog/_thumbnails/yaml-cover.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/pragmarx/yaml\"\u003e\u003cimg alt=\"Latest Stable Version\" src=\"https://img.shields.io/packagist/v/pragmarx/yaml.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"/antonioribeiro/yaml/blob/master/LICENSE.md\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-yaml.com/g/antonioribeiro/yaml/?branch=master\"\u003e\u003cimg alt=\"Code Quality\" src=\"https://img.shields.io/scrutinizer/g/antonioribeiro/yaml.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-yaml.com/g/antonioribeiro/yaml/?branch=master\"\u003e\u003cimg alt=\"Build\" src=\"https://img.shields.io/scrutinizer/build/g/antonioribeiro/yaml.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://scrutinizer-yaml.com/g/antonioribeiro/yaml/?branch=master\"\u003e\u003cimg alt=\"Coverage\" src=\"https://img.shields.io/scrutinizer/coverage/g/antonioribeiro/yaml.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://styleci.io/repos/112624437\"\u003e\u003cimg alt=\"StyleCI\" src=\"https://styleci.io/repos/112624437/shield\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://insight.sensiolabs.com/projects/7ede7c95-b31b-4ea1-9694-51b5f1d9bdb8\"\u003e\u003cimg alt=\"SensioLabsInsight\" src=\"https://img.shields.io/sensiolabs/i/7ede7c95-b31b-4ea1-9694-51b5f1d9bdb8.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Rationale\n\nConfig files getting bigger, harder to maintain and look at, every day. Why not just use YAML to load them?\n\n#### Which one is cleaner?\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/yaml-php.png\"\u003e\n\u003c/p\u003e\n\n## Key features\n\n### Load one file to Laravel config \n\n``` php\nYaml::loadToConfig(config_path('myapp.yml'), 'my-app-conf');\n```\n\n## Or a whole directory, recursively, so all those files would be loaded with a single command\n\n``` php\nYaml::loadToConfig(config_path('myapp'), 'my-app-conf');\n```\n\nTo load a directory with all your config files:\n\n``` text\n.\n└── myapp\n    ├── multiple\n    │   ├── alter.yml\n    │   ├── app.yml\n    │   └── second-level\n    │       └── third-level\n    │           ├── alter.yml\n    │           └── app.yml\n    ├── single\n        └── single-app.yml\n```\n\nThen you would just have to use it like you usually do in Laravel\n\n``` php\nconfig('my-app-conf.multiple.second-level.third-level.alter.person.name')\n```\n\n### Execute functions, like in the usual Laravel PHP array config.\n\n``` php\nrepository: \"{{ env('APP_NAME') }}\"\npath: \"{{ storage_path('app') }}\"\n```\n\n### Config values can reference config keys, you just have to quote it this way:\n\n``` yaml\n{{'format.version'}}\n```\n\n### You can add comments to your YAML files, something JSON wouldn't let you do\n\n``` yaml\nbuild:\n  mode: git-local  #### other modes: git-remote or number\n```\n\n## Parser and dumper methods\n\nIn case you need to deal with YAML directly, you can use these public methods:\n\n``` php\nYaml::parse($input, $flags) // Parses YAML into a PHP value.\n\nYaml::parseFile($filename, $flags) // Parses a YAML file into a PHP value.\n\nYaml::dump($input, $inline, $indent, $flags) // Dumps a PHP value to a YAML string.\n```\n\nWhich are simple bridges to [Symfony's YAML](https://symfony.com/doc/current/components/yaml.html).\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require pragmarx/yaml\n```\n\n## Using\n\nPublish your package as you would usually do:\n\n``` php\n$this-\u003epublishes([\n    __DIR__.'/../config/version.yml' =\u003e $this-\u003egetConfigFile(),\n]);\n```\n\nLoad the configuration in your `boot()` method:\n\n``` php\n$this-\u003eapp\n     -\u003emake('pragmarx.yaml')\n     -\u003eloadToConfig($this-\u003egetConfigFile(), 'my-package');\n```\n\nOr use the Facade:\n\n``` php\nYaml::loadToConfig(config_path('myapp.yml'), 'my-package');\n```\n\nAnd it's merged to your Laravel config:\n\n``` php\nconfig('my-package.name');\n```\n\n## Utilize PECL YAML\n\nTo utilize the PECL YAML, you should [install the PECL YAML extension](https://www.php.net/manual/en/yaml.installation.php) and register the binding in the `register()` method of your service provider:\n\n```php\n$this-\u003eapp-\u003ebind(\\PragmaRX\\Yaml\\Package\\Support\\Parser::class, \\PragmaRX\\Yaml\\Package\\Support\\PeclParser::class);\n```\n\n## Example\n\nThis is a YAML file from another package using this package:\n\n``` yaml\ncurrent:\n  major: 1\n  minor: 0\n  patch: 0\n  format: \"{$major}.{$minor}.{$patch}\"\ncache:\n  enabled: true\n  key: pragmarx-version\nbuild:\n  mode: git-local # git-remote or number\n  number: 701031\n  git-local: \"git rev-parse --verify HEAD\"\n  git-remote: \"git ls-remote {$repository} refs/heads/master\"\n  repository: \"{{ env('APP_GIT_REPOSITORY') }}\"\n  length: 6\nformat:\n  version: \"{$major}.{$minor}.{$patch} (build {$build})\"\n  full: \"version {{'format.version'}}\"\n  compact: \"v{$major}.{$minor}.{$patch}-{$build}\"\n  ## add as many formats as you need\n```\n\n## Minimum requirements\n\n- Laravel 5.5\n- PHP 7.0\n\n## Author\n\n[Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)\n\n## License\n\nThis package is licensed under the MIT License - see the `LICENSE` file for details\n\n## Contributing\n\nPull requests and issues are welcome.\n\n\n\u003c!--[![Downloads](https://img.shields.io/packagist/dt/pragmarx/yaml.svg?style=flat-square)](https://packagist.org/packages/pragmarx/yaml)--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fyaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonioribeiro%2Fyaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fyaml/lists"}