{"id":25851451,"url":"https://github.com/evilcorptech/fluidxml","last_synced_at":"2025-03-17T19:11:56.313Z","repository":{"id":43169713,"uuid":"46118287","full_name":"EvilcorpTech/fluidxml","owner":"EvilcorpTech","description":"FluidXML, the PHP library for manipulating XML with a concise and fluent API.","archived":false,"fork":false,"pushed_at":"2023-11-08T14:02:53.000Z","size":346,"stargazers_count":456,"open_issues_count":10,"forks_count":43,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-03-17T19:11:50.293Z","etag":null,"topics":["php","xml"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EvilcorpTech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/.common.sh","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-13T11:31:21.000Z","updated_at":"2025-03-16T18:58:37.000Z","dependencies_parsed_at":"2025-01-04T05:14:37.366Z","dependency_job_id":null,"html_url":"https://github.com/EvilcorpTech/fluidxml","commit_stats":{"total_commits":141,"total_committers":6,"mean_commits":23.5,"dds":0.2056737588652482,"last_synced_commit":"3f671b178e0f46c8dd9f2ac8bb747f203822d975"},"previous_names":["evilcorptech/fluidxml","servo-php/fluidxml"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilcorpTech%2Ffluidxml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilcorpTech%2Ffluidxml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilcorpTech%2Ffluidxml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilcorpTech%2Ffluidxml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvilcorpTech","download_url":"https://codeload.github.com/EvilcorpTech/fluidxml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244094274,"owners_count":20397020,"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":["php","xml"],"created_at":"2025-03-01T13:07:43.732Z","updated_at":"2025-03-17T19:11:56.288Z","avatar_url":"https://github.com/EvilcorpTech.png","language":"PHP","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=UUBXYHQRVJE28","https://www.paypal.me/danieleorlando","https://ko-fi.com/2216WXOPLSZER'"],"categories":[],"sub_categories":[],"readme":"[apis]:             https://github.com/servo-php/fluidxml/wiki/APIs\n[gettingstarted]:   https://github.com/servo-php/fluidxml/wiki/Getting-Started\n[examples]:         https://github.com/servo-php/fluidxml/blob/master/doc/Examples/\n[specs]:            https://github.com/servo-php/fluidxml/blob/master/specs/FluidXml.php\n[wiki]:             https://github.com/servo-php/fluidxml/wiki\n[bsd]:              https://opensource.org/licenses/BSD-2-Clause\n[license]:          https://github.com/servo-php/fluidxml/blob/master/LICENSE.txt\n[changelog]:        https://github.com/servo-php/fluidxml/blob/master/CHANGELOG.txt\n[codecoverage]:     https://bytebucket.org/daniele_orlando/bithosting/raw/master/FluidXML_code_coverage.png\n[donate-button]:    https://bytebucket.org/daniele_orlando/bithosting/raw/master/Donate_button.png\n[donate-link]:      https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=UUBXYHQRVJE28\n[donate-link-alt]:  https://www.paypal.me/danieleorlando\n[ninja]:            http://1.viki.io/d/1863c/8b75dc48c9.gif\n[thankyou]:         https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Heart_corazón.svg/2000px-Heart_corazón.svg.png\n\n[packagist]:        https://packagist.org/packages/servo/fluidxml\n[travis]:           https://travis-ci.org/servo-php/fluidxml\n[scrutinizer]:      https://scrutinizer-ci.com/g/servo-php/fluidxml/?branch=master\n[coveralls]:        https://coveralls.io/github/servo-php/fluidxml?branch=master\n[codeclimate]:      https://codeclimate.com/github/servo-php/fluidxml\n[codeship]:         https://codeship.com/projects/129206\n[circle]:           https://circleci.com/gh/servo-php/fluidxml\n\n[packagist-license-badge]:        https://poser.pugx.org/servo/fluidxml/license\n[packagist-release-badge]:        https://poser.pugx.org/servo/fluidxml/v/stable\n[packagist-downloads-badge]:      https://poser.pugx.org/servo/fluidxml/downloads\n[packagist-license-badge-alt]:    https://img.shields.io/packagist/l/servo/fluidxml.svg?style=flat-square\n[packagist-release-badge-alt]:    https://img.shields.io/packagist/v/servo/fluidxml.svg?style=flat-square\n[packagist-downloads-badge-alt]:  https://img.shields.io/packagist/dt/servo/fluidxml.svg?style=flat-square\n[travis-build-badge]:             https://travis-ci.org/servo-php/fluidxml.svg?branch=master\n[scrutinizer-coverage-badge]:     https://scrutinizer-ci.com/g/servo-php/fluidxml/badges/coverage.png?b=master\n[scrutinizer-quality-badge]:      https://scrutinizer-ci.com/g/servo-php/fluidxml/badges/quality-score.png?b=master\n[coveralls-coverage-badge]:       https://coveralls.io/repos/github/servo-php/fluidxml/badge.svg?branch=master\n[codeclimate-quality-badge]:      https://codeclimate.com/github/servo-php/fluidxml/badges/gpa.svg\n[codeship-build-badge]:           https://codeship.com/projects/8f977260-a359-0133-4946-1ac8bff03ae9/status?branch=master\n[circle-build-badge]:             https://circleci.com/gh/servo-php/fluidxml.svg?style=svg\n\n\n[![Travis Build][travis-build-badge]][travis]\n[![Coveralls Coverage][coveralls-coverage-badge]][coveralls]\n[![Scrutinizer Quality][scrutinizer-quality-badge]][scrutinizer]\n[![Code Climate Quality][codeclimate-quality-badge]][codeclimate]\n\n[![Packagist License][packagist-license-badge]][packagist]\n[![Packagist Last Release][packagist-release-badge]][packagist]\n[![Packagist Total Downloads][packagist-downloads-badge]][packagist]\n\n\n## Changelog\n\n**2.0.0** (2023-11-06):\n\n_PHP 8.1 is the new minimum required version._\n\n**...**\n\n[The full changes list.][changelog]\n\n\u003cbr/\u003e\n\n\u003ca href='https://ko-fi.com/2216WXOPLSZER' target='_blank'\u003e\n  \u003cimg height='32' src='https://az743702.vo.msecnd.net/cdn/kofi5.png?v=a' border='0' alt='Buy Me a Coffee at ko-fi.com'/\u003e\n\u003c/a\u003e\n\n\n# FluidXML\n\u003cimg src=\"https://bytebucket.org/daniele_orlando/bithosting/raw/master/Servo_logo.png\" height=\"64px\" alt=\"Servo-PHP Logo\"/\u003e\n\u003cspan\u003e      \u003c/span\u003e\n\u003cimg src=\"https://bytebucket.org/daniele_orlando/bithosting/raw/master/Fluidxml_logo.png\" height=\"64px\" alt=\"FluidXML Logo\"/\u003e\n\nFluidXML is a PHP library designed to manipulate XML documents with a **concise** and **fluent** API.\u003cbr/\u003e\nIt leverages the fluent programming pattern to be **fun and effective**.\n\n```php\n$book = fluidxml();\n\n$book-\u003eadd('title', 'The Theory Of Everything')\n     -\u003eadd('author', 'S. Hawking')\n     -\u003eadd('chapters', true)\n         -\u003eadd('chapter', 'Ideas About The Universe', ['id' =\u003e 1])\n         -\u003eadd('chapter', 'The Expanding Universe',   ['id' =\u003e 2]);\n```\n\nOr, if you prefer, there is an **extended syntax**.\n\n```php\n$book = new FluidXml();\n\n$book-\u003eaddChild('title', 'The Theory Of Everything')\n     -\u003eaddChild('author', 'S. Hawking')\n     -\u003eaddChild('chapters', true)\n         -\u003eaddChild('chapter', 'Ideas About The Universe', ['id' =\u003e 1])\n         -\u003eaddChild('chapter', 'The Expanding Universe',   ['id' =\u003e 2]);\n```\n\nWith FluidXML the DOM manipulation becomes **fast**, **clear** and **expressive**.\n\n**PHP Arrays** are first class citizens.\n\n```php\n$book-\u003eadd([ 'title'  =\u003e 'The Theory Of Everything',\n             'author' =\u003e 'S. Hawking',\n             'chapters' =\u003e [\n                    [ 'chapter' =\u003e [\n                            '@id' =\u003e '1',\n                            '@'   =\u003e 'Ideas About The Universe' ] ],\n                    [ 'chapter' =\u003e [\n                            '@id' =\u003e '2',\n                            '@'   =\u003e 'The Expanding Universe' ] ],\n           ]]);\n```\n\n```php\necho $book;\n```\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cdoc\u003e\n  \u003ctitle\u003eThe Theory Of Everything\u003c/title\u003e\n  \u003cauthor\u003eS. Hawking\u003c/author\u003e\n  \u003cchapters\u003e\n    \u003cchapter id=\"1\"\u003eIdeas About The Universe\u003c/chapter\u003e\n    \u003cchapter id=\"2\"\u003eThe Expanding Universe\u003c/chapter\u003e\n  \u003c/chapters\u003e\n\u003c/doc\u003e\n```\n\n**XPath** is king.\n\n```php\n$book-\u003equery('//title', '//author', '//chapter')\n        -\u003eattr('lang', 'en');\n```\n\nAnd **CSS Selectors** rock.\n\n```php\n$book-\u003equery('#id', '.class1.class2', 'div p \u003e span')\n        -\u003eattr('lang', 'en');\n\n// Many other selectors are available.\n```\n\n**XML/CSS Namespaces** are fully covered.\n\n```php\n$book-\u003enamespace('xhtml', 'http://www.w3.org/1999/xhtml')\n     -\u003eadd('xhtml:h1')\n     -\u003equery('//xhtml:h1')  // XPath namespace.\n     -\u003equery('xhtml|h1');   // CSS namespace.\n```\n\nAnd sometimes **XML Fragments** are the fastest way.\n\n```php\n$book-\u003eadd(\u003c\u003c\u003cXML\n    \u003ccover class=\"front\"\u003e\n        \u003cimg src=\"http://goo.gl/kO3Iov\"/\u003e\n    \u003c/cover\u003e\n    \u003ccover class=\"back\"\u003e\n        \u003cimg src=\"http://goo.gl/kO3Iov\"/\u003e\n    \u003c/cover\u003e\nXML\n);\n```\n\nEverything is fluent, even **iterations**.\n\n```php\n$book-\u003equery('//chapter')-\u003eeach(function ($i) {\n    $this-\u003eattr('id', $i);\n});\n```\n\n```php\n$book-\u003equery('//chapters')\n        -\u003etimes(3)\n            -\u003eadd('chapter')\n        -\u003etimes(4, function ($i) {\n            $this-\u003eadd('chapter');\n            $this-\u003eadd('illustration');\n        });\n```\n\nYou can **map** nodes easily too.\n\n```php\n$chaptersIds = $book-\u003equery('//chapter')-\u003emap(function ($i, $it) {\n    return $it-\u003egetAttribute('id');\n});\n```\n\n```php\n$book-\u003equery('//chapters')\n        -\u003etimes(3)\n            -\u003eadd('chapter')\n        -\u003etimes(4, function ($i) {\n            $this-\u003eadd('chapter');\n            $this-\u003eadd('illustration');\n        });\n```\n\nWhether some queries are too complex to express with XPath/CSS,\u003cbr/\u003e\n**filtering** is your friend.\n\n```php\n$book-\u003equery('//chapters')\n        -\u003efilter(function ($i, $node) {\n            return $i % 2 === 0;\n        })\n        -\u003eattr('even');\n```\n\nInteroperability with existing **DOMDocument** and **SimpleXML** is simply magic.\u003cbr/\u003e\nImport them or inject them in any point of the FluidXML flow just like that.\n\n```php\nfluidxml($domdocument)\n    -\u003equery('/html/body')\n         -\u003eadd($simplexml);\n\n// Yes, we merged a DOMDocument with a SimpleXMLElement\n// and everything is still fluid.\n```\n\nDon't be shy and tell it: **« IT'S AWESOME! »** ^\\_^\n\nMany other [APIs][apis] are available:\n- `__invoke()`\n- `append()`/`appendSibling()`\n- `prepend()`/`prependSibling()`\n- `addText()`\n- `text()`/`setText()`\n- `addCdata()`\n- `cdata()`/`setCdata()`\n- `addComment()`\n- `comment()`/`setComment()`\n- `remove()`\n- `size()`/`length()`\n- `load()`\n- `save()`\n- `dom()`\n- `xml()`\n- `html()`\n- `__toString()`\n- `array()`\n- ...\n\n\n## Still doubts?\nFluidXML is **fun** to use, **concise** and **effective**.\n\nIf it's not enough, it has a comprehensive test suite with a **100% code coverage**.\n\nBut you'll have the best answer trying it yourself.\n\n![100% Code Coverage][codecoverage]\n\n\n## Requirements\n* **FluidXML v2** (latest) requires **PHP \u003e= 8.1**\n* FluidXML v1 (legacy) requires **PHP \u003e=5.6 \u003c8**\n\n\n## Installation\n* **Cloning the repository**:\n\n```sh\ngit clone https://github.com/servo-php/fluidxml.git\n```\n\n* **Using Composer**:\n\n```sh\ncomposer require servo/fluidxml\n```\n\n\n## Getting Started\n* **Cloning the repository**:\n\n```php\nrequire_once 'FluidXml.php';\n```\n\n* **Using Composer**:\n\n```php\nrequire_once 'vendor/autoload.php';\n```\n\n`use` classes and functions as you need.\n```php\nuse function \\FluidXml\\fluidxml;\nuse function \\FluidXml\\fluidns;\nuse function \\FluidXml\\fluidify;\n```\n```php\nuse \\FluidXml\\FluidXml;\nuse \\FluidXml\\FluidNamespace;\n```\nSee the [documentation](#documentation) to get started and become a [ninja][ninja].\n\n\n## Documentation\n_10 minutes reading_\u003cbr/\u003e\nFollow the [Getting Started tutorial][gettingstarted] to become a [ninja][ninja] in no time.\n\nMany other examples are available:\n- inside the [`doc/Examples/`][examples] folder\n- inside the [`specs/FluidXml.php`][specs] file (as test cases)\n\nAll them cover from the simplest case to the most complex scenario.\n\nTake a look at the [APIs][apis] to discover all the available manipulation operations,\u003cbr/\u003e\nand go to the [Wiki Page][wiki] for more reading.\n\n\n## Donation\nIf you think this code is **awesome** or if you want to demonstrate\u003cbr/\u003e\nyour immense gratitude **[♥][thankyou]**, _buy me a coffe_.\n\n\u003ca href='https://ko-fi.com/2216WXOPLSZER' target='_blank'\u003e\n    \u003cimg height='32' src='https://az743702.vo.msecnd.net/cdn/kofi5.png?v=a' border='0' alt='Buy Me a Coffee at ko-fi.com'/\u003e\n\u003c/a\u003e\n\n[//]: # ([![Donate][donate-button]][donate-link]\u003cbr/\u003e)\n[//]: # (**1$ or more**\u003cspan style=\"color: gray;\"\u003e, due to the PayPal fees.\u003c/span\u003e)\n\n\u003ca-off href='https://pledgie.com/campaigns/30607'\u003e\n    \u003cimg-off alt='Click here to lend your support to: FluidXML and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/30607.png?skin_name=chrome' border='0'/\u003e\n\u003c/a-off\u003e\n\n\n## Roadmap\n* [ ] Extending the documentation\n* [ ] Expanding the APIs\n\n## Author\nDaniele Orlando  [\u0026lt;fluidxml@danieleorlando.io\u0026gt;](mailto:fluidxml@danieleorlando.io)\n\n\n## License\nFluidXML is licensed under the [BSD 2-Clause License][bsd].\n\nSee [`doc/LICENSE.txt`][license] for the details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilcorptech%2Ffluidxml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilcorptech%2Ffluidxml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilcorptech%2Ffluidxml/lists"}