{"id":17989512,"url":"https://github.com/evilfreelancer/yaml-php","last_synced_at":"2025-07-07T16:35:58.492Z","repository":{"id":56980188,"uuid":"123430118","full_name":"EvilFreelancer/yaml-php","owner":"EvilFreelancer","description":"Small PHP library for importing and exporting with validation of YAML configuration files.","archived":false,"fork":false,"pushed_at":"2018-03-07T13:00:00.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-19T22:04:54.221Z","etag":null,"topics":["configuration","export","import","library","php","yaml"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/evilfreelancer/yaml-php","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/EvilFreelancer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-01T12:09:15.000Z","updated_at":"2020-10-29T12:37:18.000Z","dependencies_parsed_at":"2022-08-21T08:40:42.257Z","dependency_job_id":null,"html_url":"https://github.com/EvilFreelancer/yaml-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/EvilFreelancer/yaml-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fyaml-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fyaml-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fyaml-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fyaml-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvilFreelancer","download_url":"https://codeload.github.com/EvilFreelancer/yaml-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fyaml-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260838605,"owners_count":23070607,"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":["configuration","export","import","library","php","yaml"],"created_at":"2024-10-29T19:14:51.342Z","updated_at":"2025-06-19T22:06:40.075Z","avatar_url":"https://github.com/EvilFreelancer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YAML PHP Import/Export with validation\n\nSmall PHP library for importing and exporting with validation of YAML configuration files.\n\n    composer require evilfreelancer/yaml-php\n\nFor correct work you need install YAML extension of PHP interpreter.\n\n## Available methods\n\n* `read` - Read YAML from file or URL (autodetect)\n* `add` - Add without replace array of parameters\n* `set` - Add with replace array of parameters\n* `validate` - Check array of parameters in memory by validation template\n* `get` - Return array of prepared parameters\n* `save` - Export parameters in YAML format to file on filesystem\n* `show` - Return YAML in plain text format\n\n## How to use\n\nMore examples [here](extra).\n\n### Basic example of usage\n\n```php\n\u003c?php\nrequire_once __DIR__ . '/../vendor/autoload.php';\nuse \\EvilFreelancer\\Yaml\\Yaml;\n\n// Object for work with YAML\n$yaml = new Yaml();\n\n// Simple array from which need build YAML\n$array = [\n    'string' =\u003e 'zzz',\n    'integer' =\u003e 42,\n    'bool' =\u003e true,\n];\n\n// Generate YAML and print to stdOut\n$yaml_text = $yaml-\u003eset($array)-\u003eshow();\necho $yaml_text;\n```\n\nOutput is:\n\n```yaml\n---\nstring: zzz\ninteger: 42\nbool: true\n...\n```\n\n### Read YAML from file\n\n```php\n$yaml_array = $yaml-\u003eread('example.yaml')-\u003eget();\nprint_r($yaml_array);\n```\n\nOutput is:\n\n```text\nArray\n(\n    [string] =\u003e zzz\n    [integer] =\u003e 42\n    [bool] =\u003e 1\n)\n```\n\n### How to append array\n\n```php\n$array = [\n    'string' =\u003e 'zzz',\n    'integer' =\u003e 42,\n    'bool' =\u003e true,\n];\n\n$append = [\n    'array_simple' =\u003e [\n        'item1',\n        'item2',\n        'item3'\n    ],\n    'array_md' =\u003e [\n        'string1' =\u003e 'text',\n        'integer' =\u003e 42,\n        'bool' =\u003e true\n    ]\n];\n\n// Set array, then append additional array and show to stdOut\necho $yaml\n    -\u003eset($array)\n    -\u003eadd($append)\n    -\u003eshow();\n```\n\nOutput is:\n\n```yaml\n---\nstring: zzz\ninteger: 42\nbool: true\narray_simple:\n- item1\n- item2\n- item3\narray_md:\n  string1: text\n  integer: 42\n  bool: true\n...\n```\n\n## How to use validation\n\n```php\n// Schema by which we need make validation\n$schema = [\n    'string' =\u003e Types::STRING,\n    'integer' =\u003e Types::INT,\n    'bool' =\u003e Types::BOOL,\n    'array_simple' =\u003e Types::ARRAY,\n    'array_md' =\u003e [\n        'string1' =\u003e Types::STRING,\n        'integer' =\u003e Types::INT,\n        'bool' =\u003e Types::BOOL\n    ]\n];\n\n// Array from which we need make YAML\n$array = [\n    'string' =\u003e 'zzz',\n    'integer' =\u003e 42,\n    'bool' =\u003e true,\n    'array_simple' =\u003e [\n        'item1',\n        'item2',\n        'item3'\n    ],\n    'array_md' =\u003e [\n        'string1' =\u003e 'text',\n        'integer' =\u003e 42,\n        'bool' =\u003e true\n    ]\n];\n\n// Set array and execute validation procedure\necho $yaml\n    -\u003eset($array)\n    -\u003evalidate($schema)\n    -\u003eshow();\n```\n\nIn result you should saw YAML, if something wrong will be error with detailed \"Stack Trace\".\n\n# Links\n\n* [Official PHP documentation about Yaml](http://php.net/manual/ru/book.yaml.php)\n* [Symfony YAML](https://github.com/symfony/yaml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilfreelancer%2Fyaml-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilfreelancer%2Fyaml-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilfreelancer%2Fyaml-php/lists"}