ngsoft / emby-client-php
A php port of Emby.SDK.
Requires
- php: >=8.1
- ext-mbstring: *
- ngsoft/tools: ^3.1|^4
- psr/cache: ^2.0|^3.0
- psr/http-client: ^1.0
- psr/log: ^1|^2|^3
- tuupola/http-factory: ^1.4
Requires (Dev)
- brick/varexporter: ^0.4.0
- friendsofphp/php-cs-fixer: ^3.34
- guzzlehttp/guzzle: ^7.8
- symfony/cache: ^6.3
- symfony/var-dumper: ^6.3
Suggests
- guzzlehttp/guzzle: Guzzle is a PHP HTTP client library
- symfony/cache: Provides extended PSR-6, PSR-16 (and tags) implementations
README
This is a Php port of Emby.SDK for Emby Media Server With this you can connect to your Emby mediaserver and manage it.
How to install
You can install this package using composer inside your project
composer require ngsoft/emby-client-php
This library requires use of a PSR-18 Http client and was developed using Guzzle
If you wish to use guzzle:
composer require guzzlehttp/guzzle
This library also supports any PSR-6 caching (to keep your EmbyConnect connection token).
You can install a Cache library using:
composer require symfony/cache
How to use
You can initialize the library like this:
<?php use EmbyClient\Connection; use EmbyClient\EmbyConnect; use EmbyClient\Cache; use EmbyClient\HttpClient; // if you are using a custom cache library you can add that line // if you installed symfony/cache you don't need that line Cache::setCachePool($myCacheItemPoolInstance); // if you are using a custom Http Client you can add that line // with guzzle it is automatic HttpClient::setHttpClient($myHttpClientInstance); // To make a connection using emby connect: $connection = EmbyConnect::connect('usernameOrEmail', 'password', 'serverName'); // or to make a connection to a local or remote server using its ip or address using an api key // you can generate an api key for your server in the web interface of your emby server: // settings -> Advanced -> Api Keys -> New Api Key $connection = Connection::getConnection('ipAddressOrHostname', 'api_key'); // or with custom port $connection = Connection::getConnection('ipAddressOrHostname:port', 'api_key'); // you can also connect to a server using its http(s) address and port $connection = Connection::getConnection('https://example.com:8096', 'api_key'); // you can also test if a connection is authenticated if($connection->testConnection()) { // you can also make a connection active globally // the first to connect is automatically registered $connection->makeActive(); }
To make an Api call you can use emby api client:
use EmbyClient\ApiClient; $devices = ApiClient::getDevices();
You can also use the services directly:
use EmbyClient\Model\Services\DeviceService; $service = new DeviceService($connection) $devices = $service->getDevices();
Informations
All models inside 'lib/' and the ApiClient
are generated using src/generator.php
using emby schema
in resources/openapi_v3.json
.
PHP-CS-Fixer has also been used to make it PSR-12 compliant. phan has also been used to check for errors