{"id":34364752,"url":"https://github.com/shadz3rg/php-stamp","last_synced_at":"2025-12-18T06:59:54.819Z","repository":{"id":21843186,"uuid":"25166353","full_name":"shadz3rg/php-stamp","owner":"shadz3rg","description":"The XSL-way templating library for Word DOCX documents.","archived":false,"fork":false,"pushed_at":"2023-11-18T09:57:38.000Z","size":213,"stargazers_count":166,"open_issues_count":5,"forks_count":34,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-10-21T23:10:21.669Z","etag":null,"topics":["doc","document","docx","dom","microsoft","office","php","template","word","xml","xsl"],"latest_commit_sha":null,"homepage":"","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/shadz3rg.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-13T16:11:06.000Z","updated_at":"2025-09-15T13:27:48.000Z","dependencies_parsed_at":"2023-01-13T21:42:22.131Z","dependency_job_id":"84f2dee2-1e56-485c-8742-99c11aa2c729","html_url":"https://github.com/shadz3rg/php-stamp","commit_stats":null,"previous_names":["shadz3rg/php-stamp"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/shadz3rg/php-stamp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadz3rg%2Fphp-stamp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadz3rg%2Fphp-stamp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadz3rg%2Fphp-stamp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadz3rg%2Fphp-stamp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shadz3rg","download_url":"https://codeload.github.com/shadz3rg/php-stamp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadz3rg%2Fphp-stamp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27792980,"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","status":"online","status_checked_at":"2025-12-18T02:00:09.725Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["doc","document","docx","dom","microsoft","office","php","template","word","xml","xsl"],"created_at":"2025-12-18T06:59:54.269Z","updated_at":"2025-12-18T06:59:54.812Z","avatar_url":"https://github.com/shadz3rg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHPStamp\n=========\n\nPHPStamp is a simple templating engine for [XML-based Microsoft Word documents](https://learn.microsoft.com/en-us/office/open-xml/word/structure-of-a-wordprocessingml-document?tabs=cs).  \nLibrary aims to provide native XML-way of templating for DOCX documents as an alternative to treating its content as a plain text for regex replacing, which has a lot of downsides.  \nInstead it tries to clean messy WYSIWYG-generated code and create reusable XSL stylesheet from document.  \n\nSome additional information:  \n(EN) https://redd.it/30conp  \n(RU) https://habr.com/ru/articles/244421/  \n \nFeatures\n----\n  - Caching XSL template to filesystem for fast document render.\n  - Track document mode - generate and cache new template if original document was updated.\n  - Configurable brackets for placeholder tags.\n  - Basic extension system, which helps to generate content blocks such as Cells or ListItems.\n\nKnown issues\n----\nValues inserted into placeholder tags may be highlighted as incorrect by spellcheck, since library removes language attribute and MS Word tries to check it with system language.\n\nRequirements\n----\nLibrary requires PHP 7.4+ with DOM, XSL, Zip extensions.\n\nInstallation\n----\nInstall with Composer:\n\n`composer require shadz3rg/php-stamp`\n\nUsage\n----\n\n##### Template:  \n\n![alt tag](https://habrastorage.org/files/0bf/dbf/f89/0bfdbff896ba45e1ac966c54abd050aa.png)\n\n```php\n\u003c?php\n    require 'vendor/autoload.php';\n    \n    use PHPStamp\\Templator;\n    use PHPStamp\\Document\\WordDocument;\n    \n    $cachePath = 'path/to/writable/directory/';\n    $templator = new Templator($cachePath);\n    \n    // Enable debug mode to re-generate template with every render call.\n    // $templator-\u003edebug = true;\n    \n    // Enable track mode to generate template with every original document change.\n    // $templator-\u003etrackDocument = true;\n    \n    $documentPath = 'path/to/document.docx';\n    $document = new WordDocument($documentPath);\n    \n    $values = [\n        'library' =\u003e 'PHPStamp 0.1',\n        'simpleValue' =\u003e 'I am simple value',\n        'nested' =\u003e [\n            'firstValue' =\u003e 'First child value',\n            'secondValue' =\u003e 'Second child value'\n        ],\n        'header' =\u003e 'test of a table row',\n        'students' =\u003e [\n            ['id' =\u003e 1, 'name' =\u003e 'Student 1', 'mark' =\u003e '10'],\n            ['id' =\u003e 2, 'name' =\u003e 'Student 2', 'mark' =\u003e '4'],\n            ['id' =\u003e 3, 'name' =\u003e 'Student 3', 'mark' =\u003e '7']\n        ],\n        'maxMark' =\u003e 10,\n        'todo' =\u003e [\n            'TODO 1',\n            'TODO 2',\n            'TODO 3'\n        ]\n    ];\n    $result = $templator-\u003erender($document, $values);\n    \n    // Now you can get template result.\n    // 1. HTTP Download\n    $result-\u003edownload();\n    \n    // Or\n    // 2. Save to file\n    // $saved = $result-\u003esave(__DIR__ . '/static', 'Test_Result1.docx');\n    // if ($saved === true) {\n    //     echo 'Saved!';\n    // }\n    \n    // Or\n    // 3. Buffer output\n    // echo $result-\u003eoutput();\n```\n\n##### Result:  \n\n![alt tag](https://habrastorage.org/files/290/6aa/6e6/2906aa6e6cba4fa08655b1f58463a4d8.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadz3rg%2Fphp-stamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshadz3rg%2Fphp-stamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadz3rg%2Fphp-stamp/lists"}