Download the PHP package yoya/php-svg without Composer
On this page you can find all versions of the php package yoya/php-svg. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package php-svg
Short Description Read, edit, write, and render SVG files with PHP (yoya's customize)
License MIT
Homepage http://pwiki.awm.jp/~yoya/?php-svg
Informations about the package php-svg
php-svg (yoya's customize)
This is a vector graphics library for PHP, which surely is a broad specification. That is due to the fact that the goal of this project is to offer features in three different, big areas:
- Generating SVG images from PHP code and outputting them, either into XML strings or into files.
- Loading and parsing XML strings into document trees that can be easily modified and then also turned back into strings.
- Transforming parsed or generated document trees into raster graphics, like PNG.
Contributing
These tasks will take a lot of time and effort, so you are welcome to contribute
if this is a project you are interested in.
In case you decide to contribute, please honor these things:
- External libraries shall not be used.
- Please set your editor to use 4 spaces for indentation. In general, it would be good to follow the existing code style for consistency.
- Source files must end with a newline character.
- By contributing code, you agree to license that code under the MIT license to this project.
Installation
Composer (recommended)
This package is available through Composer/Packagist:
Manual
Download this repo, or the latest release, and put it somewhere in your project. Then do:
The rest works exactly the same as with Composer, just without things like nice version management.
Getting Started
Creating an image
The following code generates an SVG with a blue square, sets the Content-Type header and echoes it:
Rasterizing
To convert an instance of SVGImage to a PHP/GD image resource, or in other words
convert it to a raster image, you simply call toRasterImage($width, $height)
on it. Example:
Loading an SVG
You can load SVG images both from strings and from files. This example loads one from a string, moves the contained rectangle and echoes the new SVG:
For loading from a file instead, you would call SVGImage::fromFile($file)
.
That function supports local file paths as well as URLs.