PHP code example of abovesky / laravel-yar

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

    

abovesky / laravel-yar example snippets


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


namespace App\Services;

use Abovesky\LaravelYar\YarService;

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


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


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

 
use Abovesky/LaravelYar/Yar;

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



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


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


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