PHP code example of reprover / laravel-yar

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

    

reprover / laravel-yar example snippets


protected $except = [
    '/yar/*',
];


namespace App\Services;

use Reprover\LaravelYar\YarService;

class TestService extends YarService
{
    function test_method($parameters)
    {
        return ['parameter' => $parameters];
    }
}


    return [
        'Example' => [
            'path' => 'http://resource.test/yar/', 'services' => [
            'ExampleService' => 'Example',
            'Example2Service' => 'Example2',
        ]
    ],
];


return [
    'get_example' => [
        'module' => 'Example',
        'service' => 'ExampleService',
        'method' => 'getExample',
        'connect_timeout' => 1000,
        'read_timeout' => 5000,
    ]
];

 
use Reprover/LaravelYar/Yar;

$ret = Yar::test_get([123]);
var_dump($ret);



$yarClient = new \Reprover\LaravelYar\Yar('test_get');
$ret = $yarClient->call([123]);


\Reprover\LaravelYar\Yar::asyncCall("test_get",[123],function($ret, $callbackinfo){
    var_dump($ret);
});
\Reprover\LaravelYar\Yar::asyncCall("test_get",[456],function($ret, $callbackinfo){
    var_dump($ret);
});
\Reprover\LaravelYar\Yar::loop();


$yarClient = new \Reprover\LaravelYar\Yar('test_get', true);
$yarClient->setCallback(function($ret, $callbackinfo){
                            var_dump($ret);
                        });
$yarClient->call([789]);
$yarClient::loop();
bash
php artisan vendor:publish --tag="laravel-yar"