{"id":25016397,"url":"https://github.com/lib16/svg-builder-php","last_synced_at":"2026-05-16T08:06:07.724Z","repository":{"id":57014574,"uuid":"80362548","full_name":"lib16/svg-builder-php","owner":"lib16","description":"lib16 SVG Builder is a PHP 7 library for creating SVG documents.","archived":false,"fork":false,"pushed_at":"2020-06-26T20:09:14.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-15T15:20:35.445Z","etag":null,"topics":["charts","composer","php","php-library","php7","svg","svg-builder","svg-writer"],"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/lib16.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":"2017-01-29T18:10:42.000Z","updated_at":"2025-01-03T15:18:53.000Z","dependencies_parsed_at":"2022-08-21T13:40:57.005Z","dependency_job_id":null,"html_url":"https://github.com/lib16/svg-builder-php","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lib16/svg-builder-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lib16%2Fsvg-builder-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lib16%2Fsvg-builder-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lib16%2Fsvg-builder-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lib16%2Fsvg-builder-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lib16","download_url":"https://codeload.github.com/lib16/svg-builder-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lib16%2Fsvg-builder-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273220600,"owners_count":25066423,"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-09-02T02:00:09.530Z","response_time":77,"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":["charts","composer","php","php-library","php7","svg","svg-builder","svg-writer"],"created_at":"2025-02-05T09:29:24.946Z","updated_at":"2026-05-16T08:06:07.670Z","avatar_url":"https://github.com/lib16.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lib16 SVG Builder for PHP 7\nA library for creating SVG documents written in PHP 7.\n\n[![Build Status](https://travis-ci.org/lib16/svg-builder-php.svg?branch=master)](https://travis-ci.org/lib16/svg-builder-php)\n\n## Installation with Composer\nThis package is available on [packagist](https://packagist.org/packages/lib16/svg), so you can use [Composer](https://getcomposer.org) to install it.\nRun the following command in your shell:\n\n```\ncomposer require lib16/svg\n```\n\n## Basic Usage\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php';\n\nuse Lib16\\SVG\\Svg;\nuse Lib16\\Graphics\\Geometry\\Point;\n\n$dbRows = [\n    ['month' =\u003e '2015-01', 'clicks' =\u003e '501'],\n    ['month' =\u003e '2015-02', 'clicks' =\u003e '560'],\n    ['month' =\u003e '2015-03', 'clicks' =\u003e '543'],\n    ['month' =\u003e '2015-04', 'clicks' =\u003e '607'],\n    ['month' =\u003e '2015-05', 'clicks' =\u003e '646'],\n    ['month' =\u003e '2015-06', 'clicks' =\u003e '645']\n];\n\n$svg = Svg::createSvg(400, 400);\n$svg-\u003edefs()-\u003estyle('.bgr {\n    fill: #593;\n    fill-opacity: 0.25;\n}\n.graph {\n    fill: none;\n    stroke-width: 3px;\n    stroke: #593;\n}\n.solid {\n    fill: #593;\n    fill-opacity: 0.5;\n}\n.labels, .title {\n    font-family: open sans, tahoma, verdana, sans-serif;\n    fill: 333;\n    stroke: none;\n}\n.labels {\n    font-size: 16px;\n}\n.title {\n    font-size: 24px;\n    text-anchor: middle;\n}');\n$group = $svg-\u003eg();\n$group-\u003erect(new Point(0, 0), 400, 400)-\u003esetClass('bgr');\n$group-\u003etext('Clicks 1/2015', new Point(200, 45))-\u003esetClass('title');\n$solid = $group-\u003epolygon()-\u003esetClass('solid');\n$solid-\u003esetPoints(new Point(350, 330), new Point(50, 330));\n$graph = $group-\u003epolyline()-\u003esetClass('graph');\n$labels1 = $group-\u003etext()-\u003esetClass('labels');\n$labels2 = $group-\u003etext()-\u003esetClass('labels');\nforeach ($dbRows as $i =\u003e $row) {\n    $x = 50 + $i * 60;\n    $y = (1000 - $row['clicks']) / 2;\n    $solid-\u003esetPoints(new Point($x, $y));\n    $graph-\u003esetPoints(new Point($x, $y));\n    $labels1-\u003etspan($row['clicks'], new Point($x - 10, $y - 15));\n    $labels2-\u003etspan(\n        strftime('%b', (new DateTime($row['month']))-\u003egetTimestamp()),\n        new Point($x - 10, 350)\n    );\n}\nprint $svg-\u003eheaderfields('stats');\nprint $svg-\u003egetMarkup();\n```\n\nThe generated markup:\n\n```svg\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" ?\u003e\n\u003csvg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"400\" height=\"400\"\u003e\n    \u003cdefs\u003e\n        \u003cstyle\u003e\n        \u003c![CDATA[\n            .bgr {\n                fill: #593;\n                fill-opacity: 0.25;\n            }\n            .graph {\n                fill: none;\n                stroke-width: 3px;\n                stroke: #593;\n            }\n            .solid {\n                fill: #593;\n                fill-opacity: 0.5;\n            }\n            .labels, .title {\n                font-family: open sans, tahoma, verdana, sans-serif;\n                fill: 333;\n                stroke: none;\n            }\n            .labels {\n                font-size: 16px;\n            }\n            .title {\n                font-size: 24px;\n                text-anchor: middle;\n            }\n        ]]\u003e\n        \u003c/style\u003e\n    \u003c/defs\u003e\n    \u003cg\u003e\n        \u003crect x=\"0\" y=\"0\" width=\"400\" height=\"400\" class=\"bgr\"/\u003e\n        \u003ctext x=\"200\" y=\"45\" class=\"title\"\u003eClicks 1/2015\u003c/text\u003e\n        \u003cpolygon class=\"solid\" points=\"350,330 50,330 50,249.5 110,220 170,228.5 230,196.5 290,177 350,177.5\"/\u003e\n        \u003cpolyline class=\"graph\" points=\"50,249.5 110,220 170,228.5 230,196.5 290,177 350,177.5\"/\u003e\n        \u003ctext class=\"labels\"\u003e\n            \u003ctspan x=\"40\" y=\"234.5\"\u003e501\u003c/tspan\u003e\n            \u003ctspan x=\"100\" y=\"205\"\u003e560\u003c/tspan\u003e\n            \u003ctspan x=\"160\" y=\"213.5\"\u003e543\u003c/tspan\u003e\n            \u003ctspan x=\"220\" y=\"181.5\"\u003e607\u003c/tspan\u003e\n            \u003ctspan x=\"280\" y=\"162\"\u003e646\u003c/tspan\u003e\n            \u003ctspan x=\"340\" y=\"162.5\"\u003e645\u003c/tspan\u003e\n        \u003c/text\u003e\n        \u003ctext class=\"labels\"\u003e\n            \u003ctspan x=\"40\" y=\"350\"\u003eJan\u003c/tspan\u003e\n            \u003ctspan x=\"100\" y=\"350\"\u003eFeb\u003c/tspan\u003e\n            \u003ctspan x=\"160\" y=\"350\"\u003eMar\u003c/tspan\u003e\n            \u003ctspan x=\"220\" y=\"350\"\u003eApr\u003c/tspan\u003e\n            \u003ctspan x=\"280\" y=\"350\"\u003eMay\u003c/tspan\u003e\n            \u003ctspan x=\"340\" y=\"350\"\u003eJun\u003c/tspan\u003e\n        \u003c/text\u003e\n    \u003c/g\u003e\n\u003c/svg\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flib16%2Fsvg-builder-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flib16%2Fsvg-builder-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flib16%2Fsvg-builder-php/lists"}