PHP code example of it-healer / laravel-monero

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

    

it-healer / laravel-monero example snippets


'providers' => ServiceProvider::defaultProviders()->merge([
    ...,
    \ItHealer\LaravelMonero\MoneroServiceProvider::class,
])->toArray(),

'aliases' => Facade::defaultAliases()->merge([
    ...,
    'Monero' => \ItHealer\LaravelMonero\Facades\Monero::class,
])->toArray(),

use ItHealer\LaravelMonero\Facades\Monero;

$node = MoneroNode::find(1);

// Check status (without saving to DB)
$result = Monero::checkNodeStatus($node, 'api');

if ($result['status']) {
    echo "Process is running";
} else {
    echo "Process is down: " . $result['details']['message'];
}

$node = Monero::updateNodeStatus($node, 'api');

if ($node->worked) {
    echo "Process is operational";
    // Details: $node->worked_data
}

$stats = Monero::checkAllNodesStatus('api');

echo "Total: {$stats['total']}, Working: {$stats['working']}, Failed: {$stats['failed']}";

Route::get('/api/monero/health', function () {
    $stats = Monero::checkAllNodesStatus('api');
    return response()->json($stats, $stats['failed'] === 0 ? 200 : 503);
});

$node = MoneroNode::find(1);

if ($node->worked) {
    echo "Last check: {$node->worked_data['last_check']}";
} else {
    echo "Error: {$node->worked_data['message']}";
}
bash
php artisan monero:install
bash
php artisan monero:wallet-rpc
bash
php artisan migrate
bash
php artisan monero:node-sync [NODE ID]
bash
php artisan monero:wallet-sync [WALLET ID]