PHP code example of bear / ssr-module

1. Go to this page and download the library: Download bear/ssr-module 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/ */

    

bear / ssr-module example snippets


$buildDir = dirname(__DIR__, 2) . '/var/www/build';
$this->install(new SsrModule($buildDir, 'index_ssr');

/**
 * @Ssr(app="index_ssr")
 */
public function onGet()
{ 
    $this->body = [
        'name' => 'World'
    ];

    return $this;
}

/**
 * @Ssr(
 *   app="index_ssr",
 *   state={"name", "age"},
 *   meta={"title"}
 * )
 */
public function onGet()
{ 
    $this->body = [
        'name' => 'World',
        'age' => 4.6E8;
        'title' => 'Age of the World'
    ];

    return $this;
}