omines / directadmin
PHP client library to manage DirectAdmin control panel servers.
Installs: 10 456
Dependents: 0
Suggesters: 0
Security: 0
Stars: 98
Watchers: 13
Forks: 47
Open Issues: 13
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ^6.1|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^5.7 || ^7.3
This package is auto-updated.
Last update: 2023-03-18 18:04:09 UTC
README
This package is no longer supported by the original authors as we no longer use DirectAdmin. The library still worked fine when we left it, use at your own risk. If you want to take over just push your fork to Packagist, it's MIT all the way.
This is a PHP client library to manage DirectAdmin control panel servers. We simply decided to develop this as we needed automation of our own DirectAdmin servers, and the existing implementations were unsupported and incomplete.
API documentation for this project is automatically generated on each push.
Installation
The recommended way to install this library is through Composer:
composer require omines/directadmin
If you're not familiar with composer
follow the installation instructions for
Linux/Unix/Mac or
Windows, and then read the
basic usage introduction.
Dependencies
The library uses Guzzle 6 as its HTTP communication layer. PHP versions supported are 5.6, 7.0, 7.1 and hhvm.
Basic usage
To set up the connection use one of the base functions:
use Omines\DirectAdmin\DirectAdmin; $adminContext = DirectAdmin::connectAdmin('http://hostname:2222', 'admin', 'pass'); $resellerContext = DirectAdmin::connectReseller('http://hostname:2222', 'reseller', 'pass'); $userContext = DirectAdmin::connectUser('http://hostname:2222', 'user', 'pass');
These functions return an
AdminContext
,
ResellerContext
, and
UserContext
respectively exposing the functionality available at the given level. All three extend eachother as DirectAdmin uses a
strict is-a model. To act on behalf of a user you can use impersonation calls:
$resellerContext = $adminContext->impersonateReseller($resellerName); $userContext = $resellerContext->impersonateUser($userName);
Both are essentially the same but mapped to the correct return type. Impersonation is also done implicitly when managing a user's domains:
$domain = $adminContext->getUser('user')->getDomain('example.tld');
This returns, if the domain exists, a Domain
instance in the context of its owning user, allowing you to manage its email accounts et al transparently.
Contributions
As the DirectAdmin API keeps expanding pull requests are welcomed, as are requests for specific functionality. Pull requests should in general include proper unit tests for the implemented or corrected functions.
For more information about unit testing see the README.md
in the tests folder.
Legal
This software was developed for internal use at Omines Full Service Internetbureau
in Eindhoven, the Netherlands. It is shared with the general public under the permissive MIT license, without
any guarantee of fitness for any particular purpose. Refer to the included LICENSE
file for more details.
The project is not in any way affiliated with JBMC Software or its employees.