PHP code example of darvis / nuki

1. Go to this page and download the library: Download darvis/nuki 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/ */

    

darvis / nuki example snippets


use Darvis\Nuki\Facades\Nuki;

$locks = Nuki::smartlocks()->all();          // Collection<SmartLock>
$lock  = Nuki::smartlocks()->find($id);      // SmartLock

Nuki::smartlocks()->lock($id);
Nuki::smartlocks()->unlock($id);

$entries = Nuki::logs()->forSmartlock($id, ['limit' => 50]);

Nuki::auths()->create($id, [
    'name' => 'Cleaning lady',
    'type' => 13,                            // keypad code
    'code' => 123456,
]);

use Darvis\Nuki\Events\NukiWebhookReceived;

Event::listen(NukiWebhookReceived::class, function (NukiWebhookReceived $event) {
    // $event->type, $event->payload, $event->accountKey
});
bash
composer vendor:publish --tag=nuki-config
php artisan migrate
dotenv
NUKI_AUTH_USERS_ENABLED=true
php artisan nuki:user-create [email protected] --name=Admin --password=secret123