Skip to content

Commit 72836f7

Browse files
Add usage examples.
1 parent 904c18f commit 72836f7

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,38 @@ PHP object-oriented library for Plesk XML-RPC API.
1010

1111
`composer require plesk/api-php-lib:@dev`
1212

13+
## Usage Examples
14+
15+
Here is an example on how to use the library and create a customer with desired properties:
16+
```php
17+
$client = new \PleskX\Api\Client($host);
18+
$client->setCredentials($login, $password);
19+
20+
$client->customer()->create([
21+
'cname' => 'Plesk',
22+
'pname' => 'John Smith',
23+
'login' => 'john',
24+
'passwd' => 'secret',
25+
'email' => '[email protected]',
26+
]);
27+
```
28+
29+
It is possible to use a secret key instead of password for authentication.
30+
31+
```php
32+
$client = new \PleskX\Api\Client($host);
33+
$client->setSecretKey($secretKey)
34+
```
35+
36+
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.
37+
38+
```php
39+
$client = new \PleskX\Api\InternalClient();
40+
$protocols = $client->server()->getProtos();
41+
```
42+
43+
For additional examples see tests/ directory.
44+
1345
## How to Run Unit Tests
1446

1547
One the possible ways to become familiar with the library is to check the unit tests.
@@ -27,4 +59,3 @@ To use custom port one can provide a URL (e.g. for Docker container):
2759
* Install Node.js
2860
* Install dependencies via `npm install` command
2961
* Run `REMOTE_HOST=your-plesk-host.dom REMOTE_PASSWORD=password grunt watch:test`
30-

0 commit comments

Comments
 (0)