PHP code example of ihsw / toxiproxy-php-client

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

    

ihsw / toxiproxy-php-client example snippets




hsw\Toxiproxy\Toxiproxy;
use Ihsw\Toxiproxy\ToxicTypes;
use Ihsw\Toxiproxy\StreamDirections;

$toxiproxy = new Toxiproxy("http://toxiproxy:8474");
$proxy = $toxiproxy->create("ihsw_example_redis_master", "127.0.0.1:6379");
$toxic = $proxy->create(ToxicTypes::BANDWIDTH, StreamDirections::UPSTREAM, 1.0, [
    "rate" => 1000
]);
printf(
    "Listening on IP %s and port %s on behalf of 6379, with a connection that's limited to 1000KB/s\n",
    $proxy->getListenIp(),
    $proxy->getListenPort()
);

$toxiproxy->delete($proxy);