proficlos/vestacp-api

v1.0.0 2019-11-07 21:21 UTC

This package is auto-updated.

Last update: 2024-09-08 09:58:45 UTC


README

GitHub version Build Status codecov

VestaCP PHP API

使用方法

  1. 安装

    $ composer require proficlos/vestacp-api
  2. 创建客户端

    a) 简单方式

    use ProfiCloS\VestaCP\Client;
    
    // easy way to create Client
    $client = Client::simpleFactory('https://someHost', 'someUser', 'somePass');

    b) 由于某些原因(更多主机等)您可能需要单独创建对象

    use ProfiCloS\VestaCP\Client;
    use ProfiCloS\VestaCP\Authorization\Credentials;
    use ProfiCloS\VestaCP\Authorization\Host;
    
    $credentials = new Credentials('someUser', 'somePassword');
    $host = new Host('https://someHost', $credentials);
    $client = new Client($host);
  3. 用法

    // verify login
    $client->testAuthorization(); // bool

    您可以发送预定义的其中一个命令(或者您也可以编写自己的命令 - 必须实现 \ProfiCloS\VestaCP\Command\ICommand

    $command = new SomeCommand(); 
    $response = $client->send( $command );
    
    echo $response->getResponseText();

    或者使用预定义的模块

    a) 用户模块

    $userModule = $client->getModuleUser();
    
    $userModule->list(); // returns all users with data
    $userModule->detail('admin'); // returns selected user with data
    $userModule->changePassword('admin', 'otherPa$$word');
    $userModule->add('other_user', 'pa$$word', 'some@email.com');
    $userModule->delete('other_user');
    // ... etc

    b) 网站模块

    $webModule = $client->getModuleWeb('admin'); // web module needs user
    
    $webModule->listDomains();
    $webModule->addDomain('domain.com');
    $webModule->addDomainLetsEncrypt('domain.com', 'www.domain.com'); // needs longer timeout
    $webModule->deleteDomainLetsEncrypt('domain.com');
    $webModule->addDomainFtp('domain.com', 'test', 'pa$$word');
    $webModule->changeDomainFtpPassword('domain.com', 'admin_test', 'otherPa$$word');
    $webModule->changeDomainFtpPath('domain.com', 'admin_test', 'path/other');
    $webModule->deleteDomainFtp('domain.com', 'admin_test');
    $webModule->deleteDomain('domain.com');
    // ... etc

    c) 邮件模块

    $mailModule = $client->getModuleMail('admin'); // mail module needs user
    
    $mailModule->listDomains(); // returns mail domains from selected user
    $mailModule->addDomain('domain.com'); // add domain
    $mailModule->listAccounts('domain.com'); // returns accounts from selected user and domain
    $mailModule->listDomainDkim('domain.com'); 
    $mailModule->listDomainDkimDns('domain.com');
    $mailModule->addAccount('domain.com', 'info', 'pa$$word'); // add info@domain.com account
    $mailModule->changeAccountPassword('domain.com', 'info', 'otherPa$$word'); // change info@domain.com password
    $mailModule->deleteAccount('domain.com', 'info');
    $mailModule->deleteDomain('domain.com');
    // ... etc

    d) 数据库模块

    // modules
    $dbModule = $client->getModuleDb(); 
    
    // todo
    // ... etc

    e) 计划任务模块

    $cronModule = $client->getModuleCron(); 
    
    // todo
    // ... etc

    f) 备份模块

    $backupModule = $client->getModuleBackup(); 
    
    // todo
    // ... etc

买我们一杯咖啡 <3

Buy me a Coffee

捐赠我们 <3

ETH: 0x7D771A56735500f76af15F589155BDC91613D4aB
UBIQ: 0xAC08C7B9F06EFb42a603d7222c359e0fF54e0a13