PHP client for interacting with SRS (Simple Realtime Server) API.
- π Full SRS API support
- π§ Convenient object-oriented interface
- π Typed data and IDE autocompletion
- π Detailed documentation and examples
- π‘οΈ Error handling and exceptions
- π SSL/TLS support
- βοΈ Flexible configuration
composer require sangezar/srs-php-clientuse SrsClient\Client;
use SrsClient\Config;
use SrsClient\Exception\SrsApiException;
try {
// Create client
$config = new Config('http://your-srs-server:1985');
$client = new Client($config);
// Get list of streams
$streams = $client->getStreams();
foreach ($streams as $stream) {
echo "Stream: " . $stream->getName() . "\n";
echo "Clients: " . $stream->getClients() . "\n";
echo "Bitrate: " . $stream->getBitrateKbps() . " Kbps\n";
}
} catch (SrsApiException $e) {
echo "Error: " . $e->getMessage() . "\n";
}Detailed documentation is available in multiple languages in the docs directory:
- PHP 7.4 or higher
- Composer
- PHP Extensions:
- JSON
- cURL
composer testThis project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have suggestions for improvements, please:
- Check existing issues
- Create a new issue with a detailed description
- Submit a pull request with fixes or improvements
All notable changes are documented in the CHANGELOG.md file.
use SrsClient\Client;
use SrsClient\Config;
// Create configuration with credentials
$config = new Config('http://your-srs-server:1985', [
'credentials' => [
'username' => 'admin',
'password' => 'password'
],
'timeout' => 5,
'verify' => true,
'debug' => false
]);
// Initialize client
$client = new Client($config);
// Get SRS version
$version = $client->getVersions();
echo "Version: " . $version->getVersion() . "\n";
echo "Server ID: " . $version->getServerId() . "\n";
echo "Service ID: " . $version->getServiceId() . "\n";
// Check version
if ($version->isNewerThan('5.0.0')) {
echo "Running on newer version than 5.0.0\n";
}
// Working with streams
$streams = $client->getStreams();
$streamInfo = $client->getStream('stream-id');
$client->deleteStream('stream-id');
// Working with clients
$clients = $client->getClients(20); // get 20 clients
$clientInfo = $client->getClient('client-id');
$client->deleteClient('client-id');Configuration supports the following options:
credentials- Authentication credentials:username- Usernamepassword- Password
timeout- Request timeout in seconds (default: 30)verify- SSL certificate verification (true/false or path to CA bundle)proxy- Proxy settingsdebug- Debug mode (true/false)headers- Additional HTTP headers
getVersions()- Get SRS version- Returns
Versionobject with methods:getVersion()- Full version (e.g., "5.0.213")getServerId()- Unique server IDgetServiceId()- Unique service IDgetPid()- Process IDgetMajor()- Major versiongetMinor()- Minor versiongetRevision()- RevisionisVersion(string $version)- Check specific versionisNewerThan(string $version)- Check if version is newerisOlderThan(string $version)- Check if version is older
- Returns
getSummaries()- Get general information (pid, argv, pwd, cpu, mem)getRusages()- Get resource usage statisticsgetSelfProcStats()- Get SRS process statisticsgetSystemProcStats()- Get system process statisticsgetMeminfos()- Get system memory informationgetPerformance()- Get system performance statistics
getAuthors()- Get information about authors, license, and contributorsgetFeatures()- Get list of supported featuresgetRequests()- Get current request informationgetRawConfig()- Get RAW SRS configuration
getVhosts()- Get list of all virtual hostsgetVhost(string $vhost)- Get information about specific virtual host
getStreams()- Get list of all streamsgetStream(string $streamId)- Get information about specific streamdeleteStream(string $streamId)- Delete stream
getClients(int $count = 10)- Get list of clients (default 10)getClient(string $clientId)- Get information about specific clientdeleteClient(string $clientId)- Delete client
getClusters()- Cluster managementgetTcmalloc(string $page = 'summary')- Get tcmalloc information
use SrsClient\Exception\SrsApiException;
try {
$streams = $client->getStreams();
} catch (SrsApiException $e) {
echo "Error: " . $e->getMessage();
}