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.
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.
The library uses Guzzle 6 as its HTTP communication layer. PHP versions supported are 5.6, 7.0, 7.1 and hhvm.
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.
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.
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.