Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
/ SpfPhp Public archive

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

License

Notifications You must be signed in to change notification settings

Rehike/SpfPhp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated

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();

Acknowledgements

SpfPhp makes use of the following open-source software:

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages