sandwave-io/freenas

A PHP SDK for the FreeNAS RESTful API (v2)

1.0.0 2020-07-21 08:58 UTC

This package is auto-updated.

Last update: 2024-11-13 13:49:24 UTC


README

FreeNAS RESTful API (v2) - PHP SDK

Codecov GitHub Workflow Status Packagist PHP Version Support Packagist PHP Version Support Packagist Downloads

This package is built upon the v2.0 of the FreeNAS API.

How to use

composer require sandwave-io/freenas-php
$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
);

How to contribute

Feel free to create a PR if you have any ideas for improvements. Or create an issue.

  • When adding code, make sure to add tests for it (phpunit).
  • Make sure the code adheres to our coding standards (use php-cs-fixer to check/fix).
  • Also make sure PHPStan does not find any bugs.
vendor/bin/php-cs-fixer fix

vendor/bin/phpstan analyze

vendor/bin/phpunit --coverage-text

These tools will also run in GitHub actions on PR's and pushes on master.