Coder Social home page Coder Social logo

api-php-lib's Introduction

PHP library for Plesk XML-RPC API

Test Status Scrutinizer Code Quality codecov

PHP object-oriented library for Plesk XML-RPC API.

Install Via Composer

Composer is a preferable way to install the library:

composer require plesk/api-php-lib

Usage Examples

Here is an example on how to use the library and create a customer with desired properties:

$client = new \PleskX\Api\Client($host);
$client->setCredentials($login, $password);

$client->customer()->create([
    'cname' => 'Plesk',
    'pname' => 'John Smith',
    'login' => 'john',
    'passwd' => 'secret',
    'email' => '[email protected]',
]);

It is possible to use a secret key instead of password for authentication.

$client = new \PleskX\Api\Client($host);
$client->setSecretKey($secretKey)

In case of Plesk extension creation one can use an internal mechanism to access XML-RPC API. It does not require to pass authentication because the extension works in the context of Plesk.

$client = new \PleskX\Api\InternalClient();
$protocols = $client->server()->getProtos();

For additional examples see tests/ directory.

How to Run Unit Tests

One the possible ways to become familiar with the library is to check the unit tests.

To run the unit tests use the following command:

REMOTE_HOST=your-plesk-host.dom REMOTE_PASSWORD=password composer test

To use custom port one can provide a URL (e.g. for Docker container):

REMOTE_URL=https://your-plesk-host.dom:port REMOTE_PASSWORD=password composer test

One more way to run tests is to use Docker:

docker-compose run tests

Continuous Testing

During active development it could be more convenient to run tests in continuous manner. Here is the way how to achieve it:

REMOTE_URL=https://your-plesk-host.dom:port REMOTE_PASSWORD=password composer test:watch

api-php-lib's People

Contributors

sibprogrammer avatar dependabot[bot] avatar xgin avatar mrsombre avatar rybalov avatar vbaranovskiy-plesk avatar simonsolutions avatar abashurov avatar laurisb avatar transkontrol avatar vlikhtanskiy avatar sergeimilke avatar ayvazyan10 avatar vizovitin avatar jb-boin avatar ghermans avatar baldhead avatar kojhon avatar davidhdj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.