rehike/spfphp

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP library for generating SPF.js-compatible page fragments.

1.0.5 2022-07-17 09:57 UTC

This package is auto-updated.

Last update: 2023-11-30 23:50:04 UTC


README

SpfPhp was mostly a Rehike-specific hack that should have been worked around a long time ago. For more efficient performance, this project will be deprecated and Rehike will move away from it in the future.

If you are a third-party user of the SpfPhp library, then feel free to make a fork and continue maintaining it.

SpfPhp

A PHP library that parses and transforms HTML into the JSON required by YouTube's SPF.js.

Installation

The recommended installation method is via Composer:

composer require rehike/spfphp

After installation, use the library like such:

require "vendor/autoload.php"; // Include Composer packages

use SpfPhp\SpfPhp;

Get started

SpfPhp is designed with the most portability in mind. With that, it does not require the use of or integrate with any particular templating engine.

To use this with any templating engine, or just PHP alone, simply wrap all output with these following functions:

<?php
SpfPhp::beginCapture();

?>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <div id="content" x-spfphp-capture>Hello world!</div>
    </body>
</html>
<?php

// Then tell SpfPhp we need it
SpfPhp::autoRender();

Click here for further documentation

See an example project

Acknowledgements

SpfPhp makes use of the following open-source software: