Download the PHP package atelier/svg without Composer
On this page you can find all versions of the php package atelier/svg. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package svg
Short Description PHP library for SVG manipulation, optimization, and morphing: parsing, building, styling, transforms, validation, and sanitization
License MIT
Homepage https://github.com/ateliersvg/svg
Informations about the package svg
Atelier SVG
Parse, build, query, optimize, sanitize and morph SVG, in pure PHP.
An SVG document as typed PHP objects rather than a string you edit with regular expressions. Load a file, query it with CSS selectors, change it, and write it back. Or build one from nothing.
Every element is a class, every attribute is validated, and nothing depends on an extension or an external binary. Backed by an extensive test suite and PHPStan at its highest level.
Query · Sanitize · Morph · Documentation
Installation
Requires PHP 8.3 or later. No extensions, no image library, no external binary.
Quick start
Loading from markup instead of a path is Svg::fromString($markup), and toString() returns
the document without writing a file. See Quick start.
Parse, build and export
Svg is the fluent facade. It loads an existing document, creates an empty one, and hands back
markup, a pretty-printed string, a file, or a data URI.
Parsing has profiles: the default accepts what a browser accepts, the strict one refuses what is merely loadable. See Document.
Query and edit
The whole tree is objects, and CSS selectors find your way through it.
Collections are typed and chainable rather than plain arrays. See Collections.
Every element, typed
Shapes, text, gradients, filters, clipping and masking, structure, animation: each SVG element is a class with its own attributes rather than a generic node. See Elements.
Paths
The d attribute becomes a list of typed segments, which is what makes measuring and rewriting
a curve possible at all.
Building, analysis, geometry, simplification, and baking transforms into coordinates all live in Paths.
Styling and transforms
Inline styles, presentation attributes, transform matrices, and the bounding boxes that layout depends on. See Styling.
Sanitize untrusted input
Accepting an SVG upload means accepting arbitrary markup. One call strips what makes it
dangerous: <script>, on* handlers, javascript: URLs, <foreignObject>, and external
references.
Profiles range from permissive to strict, and validation is separate for when you need to know what is wrong rather than remove it. See Sanitization.
Optimize
Fifty passes, grouped into cleanup, conversion, removal, and restructuring. Four presets choose
for you, and optimizeWith() takes a pipeline you assembled yourself.
optimizeSafe() preserves ids and metadata, optimizeAggressive() goes for the smallest file.
Writing your own pass is a documented interface, not a fork. See
Optimization.
Accessibility
A generated SVG is invisible to a screen reader until it is told what it shows.
Titles, descriptions, ARIA roles and labels, focus order, and an audit that reports what is missing. See Accessibility.
Morph and animate
Interpolate between two shapes, whatever their segment counts, and export the result as SMIL, CSS keyframes, JavaScript, or a sprite sheet.
See Morphing.
Documentation
- Installation: requirements and setup.
- Quick start: load, create, and manipulate a document.
- Document: parse, create, validate, sanitize, export.
- Elements: every element as a typed object.
- Paths: build, measure, simplify, transform.
- Styling: styles, transforms, layout boxes.
- Optimization: the passes, the presets, writing your own.
- Morphing: interpolation and animation export.
- Guides: sanitizing uploads, icon sprites, charts, batch processing.
The full documentation is published at ateliersvg.com/svg.
Contributing
Contributions are welcome. Visit the project on GitHub to report a bug, suggest a feature, or open a pull request.
Before submitting code, run:
Changes to public behaviour need a test and a documentation update.
Support
Bug reports, security disclosures, and contribution guidelines are collected at ateliersvg.com/support.
Sharing the package or starring it on GitHub helps more than you would think.
License
Atelier SVG is released under the MIT License.
All versions of svg with dependencies
ext-dom Version *
ext-xml Version *