PHP code example of rxthunder / skeleton

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

    

rxthunder / skeleton example snippets


// src/Handler/PromptHello.php
namespace App\Handler;

use Rx\Observable;
use RxThunder\Core\Model\DataModel;

class PromptHello
{
    public function __invoke(DataModel $data_model)
    {
        return Observable::of($data_model)
            ->do(function() {
                echo "hello there". PHP_EOL;
            });
    }
}

// src/Route/Test.php
namespace App\Route;

use App\Handler\PromptHello;
use Rx\Observable;
use RxThunder\Core\Model\DataModel;
use RxThunder\Core\Router\Route;

class Test extends Route
{
    public const PATH = '/test';

    private $prompt;

    public function __construct(
        PromptHello $prompt
    ) {
        $this->prompt = $prompt;
    }

    public function __invoke(DataModel $data_model): Observable
    {
        return Observable::of($data_model)
            ->do(function () {
                echo "i'm in /test".PHP_EOL;
            })
            ->flatMap($this->prompt)
            ->do(function () {
                echo "passed in /test".PHP_EOL;
            });
    }
}