PHP code example of bromine-mai / cor-yar

1. Go to this page and download the library: Download bromine-mai/cor-yar 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/ */

    

bromine-mai / cor-yar example snippets




 
//使用use导入新类方式替换客户端
use \BromineMai\CorYar\Client\Client as Yar_Client;
$client = new Yar_Client("http://host/api/");
$result = $client->api("parameter);


use \BromineMai\CorYar\Server\SwooleServer as Yar_Server;
$http = new Server("127.0.0.1", 9501);
$http->on('request', function ($request, $response) {
    $server=new Yar_Server(new XXXApi());
	$server->setIoHandler($request,$response);//设置IO句柄
	$server->handle(); 
});
$http->start();

        $server->setInputHandle(function()use($xxFrameworkRequest){
            return $xxFrameworkRequest->getRawContent();
        });
        $server->setOutputHandle(function($result){
            echo $result;
        });