Download the PHP package zergius-eggstream/amp-converter without Composer

On this page you can find all versions of the php package zergius-eggstream/amp-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package amp-converter

php-amp-converter

Latest Stable Version License PHP Version Require

Convert rendered HTML pages into AMP-valid HTML — pure PHP, no Node runtime.

PHP port of the Node-based convert-rendered-to-amp.js shipped with the amp-seo-sites toolset. Designed for build-time conversion of pre-rendered HTML into AMP HTML that passes the official amphtml-validator, with no Node runtime in the conversion path.

Status

Port complete, ready for review. All 13 algorithm stages implemented and exercised end-to-end on a real-world ~119 KB rendered page (covering amp-img, amp-youtube, amp-iframe, amp-bind burger, amp-accordion FAQ, inlined external CSS, JSON-LD); PHP output sits within 0.1 % of the Node reference (113.6 KB vs 113.7 KB, structurally identical AMP). 258 phpunit tests / 513 assertions; PHPStan level 8 clean. CI runs on PHP 8.4. Stage map: doc/port-status.md.

Requirements

Installation

Once the maintainer of the consuming projects forks/republishes the package under their preferred vendor, that require line points at the new name (the namespace stays AmpConverter\ so call sites don't change).

Usage

Arguments:

Name Required Default Meaning
$renderedHtml yes the rendered HTML to convert
$siteRoot yes absolute path to the site directory (root of on-disk assets)
$canonicalUrl no null absolute URL of the non-AMP (canonical) version of the page. When provided, AMP page emits <link rel="canonical" href="$canonicalUrl"> and replaces any existing canonical link. When null, falls back to a relative self-reference href="./" so the package stays drop-in for hosts that don't compute absolute URLs at build time.
$assetsBaseDir no 'public' subdirectory under $siteRoot where assets live. The default matches the common public/-as-document-root convention; pass an empty string for a flat layout, or a custom folder for non-standard layouts.

The package is intentionally agnostic about where the host gets canonicalUrl from (TSV, per-site config, request data, hard-coded mapping, …) — that's a host concern. The package just emits what it was given.

ConversionResult exposes:

Symfony integration

The package is framework-agnostic. A typical Symfony host wires it through a thin one-line autowired service:

If a future iteration ships a Symfony Bundle for zero-config auto-wiring (Bridge/Symfony/AmpConverterBundle), it will be additive — the framework-agnostic core won't change.

Architecture

The converter is an ordered pipeline of transformers. Each transformer implements Transformer::apply(string $html, Context $ctx): string and owns one feature area; Context carries cross-transformer state (siteRoot, used components, warnings, detected FAQ classes, font @imports collected from CSS, …).

Replace the default pipeline by constructing AmpConverter directly:

Error handling

Strict but graceful: when the converter cannot transform a fragment (unparseable <img> tag, malformed CSS block, missing image dimensions), it removes the fragment and records a warning rather than throwing. The whole page still converts. Build pipelines decide what to do with warnings (log / fail / ignore). Exceptions are reserved for unrecoverable programmer errors (e.g. invalid pipeline configuration).

Testing

Layout:

CI is GitHub Actions over PHP 8.4 with the libxml, mbstring, simplexml, gd extensions; no Node required.

License

MIT.


All versions of amp-converter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-libxml Version *
ext-mbstring Version *
ext-simplexml Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zergius-eggstream/amp-converter contains the following files

Loading the files please wait ...