PHP code example of sandwave-io / freenas
1. Go to this page and download the library: Download sandwave-io/freenas 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/ */
sandwave-io / freenas example snippets
$freenas = new \SandwaveIo\FreeNAS\RestClient(
'https://my-freenas-install.io/api/v2.0/', // base url
'root', // user
'SuperSecretPassword123' // password
);
// This example shows how to create a dataset, and a user that has access rights to that dataset.
$dataset = $freenas->createDataset(
'store01', // pool
'my-dataset', // dataset
20 * 1024**3 // size in bytes
);
$user = $freenas->createUser(
1001, // uid
'my-user', // username
$dataset->getMountPoint(), // homedir
'SuperSecretUserPassword123' // password
);