PHP code example of bpx-chain / bpx-beacon-php

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

    

bpx-chain / bpx-beacon-php example snippets



try {
    $beacon = new BPX\Beacon('localhost', 8201, 'C:\private_beacon.crt', 'C:\private_beacon.key');
    $farmer = new BPX\Farmer('localhost', 8204, 'C:\private_farmer.crt', 'C:\private_farmer.key');
    $harvester = new BPX\Harvester('localhost', 8205, 'C:\private_harvester.crt', 'C:\private_harvester.key');
    $crawler = new BPX\Crawler('localhost', 8206, 'C:\private_crawler.crt', 'C:\private_crawler.key');
        
    var_dump(
        $beacon -> getBlockchainState()
    );
    
    var_dump(
        $farmer -> getRewardTargets(true)
    );
		
    $harvester -> refreshPlots();
    
    var_dump(
        $crawler -> getPeerCounts()
    );
}
    
catch(BPX\Exceptions\ConnException $e) {
    echo "Connection error: " . $e->getMessage();
}
    
catch(BPX\Exceptions\BPXException $e) {
    echo "BPX error: " . $e->getMessage();
}