webproject-xyz / ikea-tradfri-php-api
PHP library to control ikea tradfri hub
Package info
github.com/WebProject-xyz/ikea-tradfri-php
pkg:composer/webproject-xyz/ikea-tradfri-php-api
4.5.0
2026-06-22 20:44 UTC
Requires
- php: ~8.5.0
- ext-filter: *
- ext-json: *
- ext-mbstring: *
- doctrine/collections: ^3.1.0
- psr/log: ^3.0.2
- symfony/polyfill-mbstring: ^1.38.2
- symfony/process: ^8.1.0
- symfony/property-access: ^8.1.0
- symfony/property-info: ^8.1.0
- symfony/serializer: ^8.1.0
- symfony/service-contracts: ^3.7.0
- symfony/validator: ^8.1.0
- webmozart/assert: ^2.4.1
Requires (Dev)
- codeception/codeception: ^5.3.5
- codeception/mockery-module: ^0.5.0
- codeception/module-asserts: ^3.3.0
- ergebnis/license: ^2.7.0
- ergebnis/php-cs-fixer-config: ^6.62.2
- friendsofphp/php-cs-fixer: ^3.95.10
- mockery/mockery: ^1.6.12
- phpro/grumphp: ^2.21.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpdoc-parser: ^2.3.2
- phpstan/phpstan: ^2.2.2
- phpstan/phpstan-doctrine: ^2.0.27
- phpstan/phpstan-mockery: ^2.0.0
- rector/rector: ^2.5.2
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^8.1.0
- webproject-xyz/codeception-module-ai-reporter: ^1.2.1
- wmde/psr-log-test-doubles: ^3.4.0
This package is auto-updated.
Last update: 2026-06-22 20:45:53 UTC
README
A powerful PHP library to control IKEA Tradfri smart lights via the Gateway.
🚀 Quick Start
1. Requirements
- PHP 8.4+
coap-client(available via Docker)
2. Generate Security Key
Use the Docker Coap-Client to get your credentials:
docker run --rm webproject/coap-client -m post -u "Client_identity" -k "<GATEWAY_SECRET>" -e '{"9090":"php-api-user"}' "coaps://<GATEWAY_IP>:5684/15011/9063"
💻 Usage
Initialize API
use IKEA\Tradfri\Dto\CoapGatewayAuthConfigDto; use IKEA\Tradfri\Factory\GatewayServiceFactory; $api = (new GatewayServiceFactory( new CoapGatewayAuthConfigDto( username: 'php-api-user', apiKey: 'GENERATED_API_KEY', gatewayIp: '192.168.1.10', gatewaySecret: 'GATEWAY_SECRET' ) ))();
Control Devices
// Switch on all lights and dim to 80% foreach ($api->getLights() as $light) { $light->switchOn()->dim(80); } // Switch off a specific group $api->getGroups()->first()?->switchOff();
📖 Documentation
🤝 Contributing
Feel free to submit Pull Requests.
📄 License
MIT License.