PHP code example of williamson / tplinksmartplug
1. Go to this page and download the library: Download williamson/tplinksmartplug 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/ */
williamson / tplinksmartplug example snippets
'providers' => [
//...
Williamson\TPLinkSmartplug\Laravel\TPLinkServiceProvider::class,
]
'aliases' => [
//...
"TPLink" => Williamson\TPLinkSmartplug\Laravel\Facades\TPLinkFacade::class
]
//TPLink.php
return [
'lamp' => [
'ip' => '192.168.1.100', //Or hostname eg: home.example.com
'port' => '9999',
],
];
//Non laravel
$tpManager = new TPLinkManager($configArray);
$tpDevice = $tpManager->device('lamp')
//Laravel
//with facade
TPLink::device('lamp')
//without facade
$tpDevice = app('tplink')->device('lamp');
$tpDevice = app(TPLinkManager::class)->device('lamp');
//Non laravel
$tpDevice->sendCommand(TPLinkCommand::systemInfo());
//Laravel
//with facade
TPLink::device('lamp')->sendCommand(TPLinkCommand::systemInfo());
//without facade
$tpDevice->sendCommand(TPLinkCommand::systemInfo());
//Non laravel
$tpDevice->sendCommand(TPLinkCommand::setLED(false));
//Laravel
//with facade
TPLink::device('lamp')->sendCommand(TPLinkCommand::setLED(false));
//without facade
$tpDevice->sendCommand(TPLinkCommand::setLED(false));
//Non laravel
$tpDevice->togglePower();
//Laravel
//with facade
TPLink::device('lamp')->togglePower();
//without facade
$tpDevice->togglePower();
$ php artisan vendor:publish --provider='Williamson\TPLinkSmartplug\Laravel\TPLinkServiceProvider'