2017 © Pedro Peláez
 

library nextcloud

library for nextcloud user management

image

masterzero/nextcloud

library for nextcloud user management

  • Saturday, June 23, 2018
  • by MasterZero
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel Nextcloud API User Management

manage your nextcloud users via laravel, (*1)

Setup:

  1. Use following command in your terminal to install this library. (Currently the library is in development mode):, (*2)

    composer require masterzero/nextcloud dev-master, (*3)

  2. Update the poviders in config/app.php, (*4)

    'providers' => [
        // ...
        MasterZero\Nextcloud\ApiServiceProvider::class,
    ]
  3. Update the aliases in config/app.php, (*5)

    'aliases' => [
        // ...
        'NextcloudApi' => MasterZero\Nextcloud\Facade\Api::class,
    ]
  4. Create config/nextcloud.php with content:, (*6)


return [ 'login'=> env('NEXTCLOUD_LOGIN', 'admin'), 'password'=> env('NEXTCLOUD_PASSWORD', '12345678'), 'baseUrl'=> env('NEXTCLOUD_BASEURL', 'http://localhost'), ];
  1. Add these params to .env (optional):
NEXTCLOUD_LOGIN=admin
NEXTCLOUD_PASSWORD=12345678
NEXTCLOUD_BASEURL=http://localhost

Usage:

create user:

// reqeust to API
$data = NextcloudApi::createUser($username, $password);

// do something with it
if ($data['success']) {

    // do something ...

} else {

    // do something else ...

    echo $data['message'];

}

user list:

// reqeust to API
$data =  NextcloudApi::getUserList();

// do something with it
if ($data['success']) {

    foreach ($data['users'] as $userid) {
        // do something with $userid
    }

} else {

    // do something else ...

}

edit user param:

// reqeust to API
$data = NextcloudApi::editUser('rabbit','quota', '200 MB');

if ($data['success']) {

    // do something ...

} else {

    // do something else ...

}

enable/disable user:

// reqeust to API
$data = NextcloudApi::enableUser('bird');
//$data = NextcloudApi::disableUser('turtle');

if ($data['success']) {

    // do something ...

} else {

    // do something else ...

}

exceptions


use MasterZero\Nextcloud\Exceptions\XMLParseException; use MasterZero\Nextcloud\Exceptions\CurlException; // ... try { // reqeust to API NextcloudApi::editUser('rabbit','quota', '200 MB'); } catch (XMLParseException $e) { // bad nextcloud answer } catch (CurlException $e) { // bad connection } catch (\Exception $e) { // bad something else }

multi-server usage


use MasterZero\Nextcloud\Api; // ... $api = new Api([ 'baseUrl' => 'http://develop.localhost:3500', 'login' => 'admin', 'password' => '12345678', 'sslVerify' => false, // use default value // 'apiPath' => 'custom/path/to/api.php', // 'userPath' => '', // 'enablePath' => '', // 'disablePath' => '', ]); $api->createUser( 'dummy', 'qwerty');

The Versions

23/06 2018

dev-master

9999999-dev

library for nextcloud user management

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Avatar MasterZero

laravel nextcloud