{"id":36978947,"url":"https://github.com/atomicptr/berry","last_synced_at":"2026-01-13T22:48:30.605Z","repository":{"id":330884038,"uuid":"1123676084","full_name":"atomicptr/berry","owner":"atomicptr","description":"Berry is a zero-dependency, type-safe toolkit for building HTML structures using pure PHP.","archived":false,"fork":false,"pushed_at":"2026-01-11T17:31:30.000Z","size":166,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-11T20:24:46.862Z","etag":null,"topics":["berry","berry-html","php","template-engine"],"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/atomicptr.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"atomicptr","buy_me_a_coffee":"atomicptr"}},"created_at":"2025-12-27T11:32:25.000Z","updated_at":"2026-01-11T17:31:34.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/atomicptr/berry","commit_stats":null,"previous_names":["atomicptr/berry"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/atomicptr/berry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fberry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fberry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fberry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fberry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicptr","download_url":"https://codeload.github.com/atomicptr/berry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fberry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["berry","berry-html","php","template-engine"],"created_at":"2026-01-13T22:48:30.547Z","updated_at":"2026-01-13T22:48:30.595Z","avatar_url":"https://github.com/atomicptr.png","language":"PHP","funding_links":["https://github.com/sponsors/atomicptr","https://buymeacoffee.com/atomicptr"],"categories":[],"sub_categories":[],"readme":"# Berry\n\nBerry is a zero-dependency, type-safe toolkit for building HTML structures using pure PHP.\n\n## Features\n\n- **Pure PHP eDSL**: Define HTML structures using a fluent API, no new template syntax to learn just pure PHP\n- **Type Safety**: Designed with PHPStan in mind, benefit from static analysis to catch bugs before they hit production\n- **Built-in inspector**: Berry includes a visual debugging tool that renders a tree of your components and stack traces directly in the browser\n- **Extensible**: Extend Berry with custom attributes using the integrated extension method functionality\n\n## Usage\n\nInstall via composer\n\n```bash\n$ composer req berry/html\n```\n\n```php\n\u003c?php declare(strict_types=1);\n\n// renders a counter button and a debug representation of itself\n// clicking on the button will send a POST request to the current script\nfunction counterButton(int $value): Element\n{\n    $nextValue = $value + 1;\n\n    /** @var string $current */\n    $current = $_SERVER['PHP_SELF'] ?? '/';\n\n    return div()\n        -\u003eattr('hx-target', 'this')\n        -\u003echild(\n            button()\n                -\u003eid('counter-button')\n                -\u003eattr('hx-post', \"$current?counter=$nextValue\")\n                -\u003eattr('hx-swap', 'outerHTML')\n                -\u003etext(\"+ $value\")\n        )\n        -\u003echild(hr())\n        -\u003edump(true);\n}\n\n// our website layout to wrap around the content\n// includes picocss and htmx\nfunction layout(Element $content): Element\n{\n    return html()\n        -\u003echild(head()\n            -\u003echild(title()-\u003etext('Hello, Berry!'))\n            -\u003echild(link()\n                -\u003erel(Rel::Stylesheet)\n                -\u003ehref('https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css')))\n        -\u003echild(body()\n            -\u003echild(header())\n            -\u003echild(div()\n                -\u003eclass('container')\n                -\u003echild($content))\n            -\u003echild(script()-\u003esrc('https://cdnjs.cloudflare.com/ajax/libs/htmx/2.0.7/htmx.min.js')));\n}\n\n// if we get a POST render only the counter button and stop\nif ($_SERVER['REQUEST_METHOD'] === 'POST') {\n    $value = $_GET['counter'] ?? '1';\n    assert(is_string($value));\n\n    $value = intval($value);\n\n    echo counterButton($value)-\u003etoString();\n    die();\n}\n\n// and lastly render the normal page template\necho layout(\n    main()\n        -\u003eclass('container')\n        -\u003echild(h1()-\u003etext('Hello, Berry!'))\n        -\u003echild(p()-\u003etext('This is an example page rendering HTML using Berry'))\n        -\u003echild(counterButton(1))\n)-\u003etoString();\n```\n\n![Example Screenshot](./.github/example_screenshot.png)\n\n## Ecosystem\n\nSome other related packages:\n\n- [berry/symfony](https://github.com/atomicptr/berry-symfony) - Symfony integration\n- [berry/htmx](https://github.com/atomicptr/berry-symfony) - HTMX integration\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Fberry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicptr%2Fberry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Fberry/lists"}