PHP code example of caiyun / micro

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

    

caiyun / micro example snippets


'static' => [
    'driver' => 'static',
    'endpoints' => [
        'caiyun-ai-agent' => [env('AGENT_BASE_URL', 'http://127.0.0.1:8080')],
    ],
],

use Caiyun\Micro\Facades\Micro;

$response = Micro::for('agent')->post('/v1/chat', [
    'message' => 'hello',
]);

$instance = Micro::select('caiyun-ai-agent');
$instances = Micro::getInstances('caiyun-ai-agent');

Micro::registerSelf();
Micro::heartbeatSelf();
Micro::deregisterSelf();

Schedule::command('micro:heartbeat')->everyFiveSeconds();

use Caiyun\Micro\Facades\Micro;

Micro::extend('consul', function ($app, array $config) {
    return new App\Micro\ConsulDriver($config);
});
bash
php artisan vendor:publish --provider="Caiyun\Micro\MicroServiceProvider" --tag=micro-config
bash
php artisan micro:register
php artisan micro:heartbeat
php artisan micro:deregister