PHP code example of becklyn / javascript-context

1. Go to this page and download the library: Download becklyn/javascript-context library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

becklyn / javascript-context example snippets


use Becklyn\JavaScriptContext\Context\JavaScriptContext;


function doSomething (JavaScriptContext $context)
{
    $context
        ->set("some-data", 123)
        ->set("locale", "de");
}

use Becklyn\JavaScriptContext\Context\JavaScriptContext;
use Becklyn\JavaScriptContext\Provider\ContextProviderInterface;

class MyProvider implements ContextProviderInterface
{
    public function provideJavaScriptContext (JavaScriptContext $context, ?string $domain) : void
    {
        $context->set("some", "value");
    }
}