Official PHP library.
The PHP library is responsible for processing snippets that meet the established conditions.
The snippets must be inside the HTML
<pre><code>...</code></pre> (code) or
<pre><samp>...</samp></pre> (output) tags.
Also, as in the rest of the libraries, the HTML
<samp> tags must include the
language-NAME class, as indicated on the getting-started/quickstart#snippet-preparation page.
This library accepts any HTML structure, such as an article, and returns the same article with the processed snippets, keeping the rest intact.
The library is available at Packagist, so you can use Composer to install it.
photon-php makes use of the PSR-4 autoloading specification.
After requiring the
autoload.php file in your application, import the
Photon class and create a new instance of such class.
Then, provide the API key to the
setup method using an array and call the
highlight method providing the snippet to process as the first argument.
The API key can also be provided through the
$options array to the
Photon throws a
Photonsh\PhotonPhp\Exception\ClientException exception when there is a problem highlighting the snippet.
Method that accepts as single argument an array with configuration parameters. These parameters affect all calls to the
apiKey: The API key to use for all calls to the
highlight(string $snippet, array $options)
Method that accepts as the first argument a snippet or an HTML fragment/document with snippets inside it, nested at any level.
As a second argument,
highlight accepts an array with configuration parameters. These parameters only affect this call to the
apiKey: The API key to use in this specific call.
If you do not provide an API key to the
setup method, you must provide it to the