1. Go to this page and download the library: Download hollodotme/fast-cgi-proxy 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/ */
hollodotme / fast-cgi-proxy example snippets
declare(strict_types=1);
namespace YourVendor\YourProject;
use hollodotme\FastCGI\Proxy;
use hollodotme\FastCGI\Collections\Random;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;
use hollodotme\FastCGI\SocketConnections\UnixDomainSocket;
$random = Random::fromConnections(
new NetworkSocket( '127.0.0.1', 9000 ),
new NetworkSocket( '10.100.10.42', 9000 ),
new UnixDomainSocket( '/var/run/php7.3-fpm.sock' )
);
$proxy = new Proxy( $random );
declare(strict_types=1);
namespace YourVendor\YourProject;
use hollodotme\FastCGI\Proxy;
use hollodotme\FastCGI\Collections\RoundRobin;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;
use hollodotme\FastCGI\SocketConnections\UnixDomainSocket;
$roundRobin = RoundRobin::fromConnections(
new NetworkSocket( '127.0.0.1', 9000 ),
new NetworkSocket( '10.100.10.42', 9000 ),
new UnixDomainSocket( '/var/run/php7.3-fpm.sock' )
);
$proxy = new Proxy( $roundRobin );
declare(strict_types=1);
namespace YourVendor\YourProject;
use hollodotme\FastCGI\ClusterProxy;
use hollodotme\FastCGI\Collections\Cluster;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;
use hollodotme\FastCGI\SocketConnections\UnixDomainSocket;
$cluster = Cluster::fromConnections(
new NetworkSocket( '127.0.0.1', 9000 ),
new NetworkSocket( '10.100.10.42', 9000 ),
new UnixDomainSocket( '/var/run/php7.3-fpm.sock' )
);
$clusterProxy = new ClusterProxy( $cluster );
declare(strict_types=1);
namespace hollodotme\FastCGI\Interfaces;
interface ProvidesServerStatus
{
/**
* Returns the original response object for the status request provided by hollodotme/fast-cgi-client
* @see https://github.com/hollodotme/fast-cgi-client/blob/2.x-stable/src/Responses/Response.php
*
* @return ProvidesResponseData
*/
public function getResponse() : ProvidesResponseData;
/**
* Returns the connection object used for the status request
* in order to identify the server that produced the status response
*
* @return ConfiguresSocketConnection
*/
public function getConnection() : ConfiguresSocketConnection;
/**
* Returns any data structure representing the status information of the server
* @return mixed
*/
public function getStatus();
/**
* Returns a list of any data structure representing current processes running on the server
* @return array
*/
public function getProcesses() : array;
}
declare(strict_types=1);
namespace hollodotme\FastCGI\Examples;
use hollodotme\FastCGI\ClusterProxy;
use hollodotme\FastCGI\Collections\Cluster;
use hollodotme\FastCGI\Responses\PhpFpmStatusResponse;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;
If you do not want the list processes, use the following line to get the status only
# $statusResponses = $clusterProxy->getStatus( '/status' );
/** @var PhpFpmStatusResponse $statusResponse */
foreach ( $statusResponses as $statusResponse )
{
$connection = $statusResponse->getConnection();
$status = $statusResponse->getStatus();
$processes = $statusResponse->getProcesses();
$response = $statusResponse->getResponse();
echo '[ SERVER: ', $connection->getSocketAddress(), " ]\n";
echo '- Pool name: ', $status->getPoolName(), "\n";
echo '- Process manager: ', $status->getProcessManager(), "\n";
echo '- Started at: ', $status->getStartTime()->format( 'c' ), "\n";
echo '- Seconds since start: ', $status->getStartSince(), "\n";
echo '- Number of accepted connections: ', $status->getAcceptedConnections(), "\n";
echo '- Current listen queue: ', $status->getListenQueue(), "\n";
echo '- Listen queue maximum: ', $status->getMaxListenQueue(), "\n";
echo '- Listen queue length: ', $status->getListenQueueLength(), "\n";
echo '- Number of idle processes: ', $status->getIdleProcesses(), "\n";
echo '- Number of active processes: ', $status->getActiveProcesses(), "\n";
echo '- Number of total processes: ', $status->getTotalProcesses(), "\n";
echo '- Number of active processes maximum: ', $status->getMaxActiveProcesses(), "\n";
echo '- Times max children reached: ', $status->getMaxChildrenReached(), "\n";
echo '- Number of slow requests: ', $status->getSlowRequests(), "\n";
echo "\nPrinting processes:\n\n";
foreach ( $processes as $index => $process )
{
echo '- [ PROCESS #', ($index + 1), " ]\n";
echo ' * PID: ', $process->getPid(), "\n";
echo ' * State: ', $process->getState(), "\n";
echo ' * Started at: ', $process->getStartTime()->format( 'c' ), "\n";
echo ' * Seconds since start: ', $process->getStartSince(), "\n";
echo ' * Number of requests processed: ', $process->getRequests(), "\n";
echo ' * Last request duration: ', $process->getRequestDuration(), "\n";
echo ' * Last request method: ', $process->getRequestMethod(), "\n";
echo ' * Last request URI: ', $process->getRequestUri(), "\n";
echo ' * Last content length: ', $process->getContentLength(), "\n";
echo ' * Last user: ', $process->getUser(), "\n";
echo ' * Last script: ', $process->getScript(), "\n";
echo ' * CPU usage of last request: ', $process->getLastRequestCpu(), "\n";
echo ' * Memory usage of last request: ', $process->getLastRequestMemory(), "\n";
echo "\n\n---\n\n";
}
echo 'Processing duration: ', $response->getDuration(), " seconds\n\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.