├── src ├── ClientInterface.php ├── Api │ ├── ApiInterface.php │ ├── ServicePlansAddons.php │ ├── Ip.php │ ├── Dns.php │ ├── Sessions.php │ ├── Nodejs.php │ ├── Extensions.php │ ├── Subdomains.php │ ├── Locales.php │ ├── SitesAliases.php │ ├── SecretKeys.php │ ├── AbstractApi.php │ ├── ServicePlans.php │ ├── Certificates.php │ ├── ResellersPlans.php │ ├── Databases.php │ ├── Php.php │ ├── LogRotations.php │ ├── Customers.php │ ├── Plesk.php │ ├── Sites.php │ ├── Ftp.php │ ├── DatabasesServers.php │ ├── Aps.php │ ├── Git.php │ ├── Mail.php │ ├── Resellers.php │ └── Subscriptions.php ├── helpers.php ├── Facade.php ├── HttpClient │ ├── HttpClientInterface.php │ └── HttpClient.php ├── ServiceProvider.php ├── Plesk.php └── Client.php ├── .github ├── dependabot.yml └── workflows │ └── run-tests.yml ├── config └── plesk-xml.php ├── CHANGELOG.md ├── LICENSE.md ├── composer.json ├── CONTRIBUTING.md └── README.md /src/ClientInterface.php: -------------------------------------------------------------------------------- 1 | env('PLESK_SERVER', 'default'), 6 | 7 | 'servers' => [ 8 | 9 | 'default' => [ 10 | 'host' => env('PLESK_DEFAULT_HOST'), 11 | 'username' => env('PLESK_DEFAULT_USERNAME'), 12 | 'password' => env('PLESK_DEFAULT_PASSWORD'), 13 | 'key' => env('PLESK_DEFAULT_KEY'), 14 | ], 15 | 16 | ], 17 | 18 | ]; 19 | -------------------------------------------------------------------------------- /src/Api/ServicePlansAddons.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'service-plan-addon' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function get($params) 22 | { 23 | return $this->post([ 24 | 'service-plan-addon' => ['get' => ['filter' => $params]] 25 | ]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-plesk-xml` will be documented in this file 4 | 5 | ## 0.9.0 - 2020-12-06 6 | 7 | - Adding support for PHP 8.0, ditched PHP 7.2 and PHP 7.3 8 | 9 | ## 0.8.0 - 2020-09-18 10 | 11 | - Adding support for Laravel 8 12 | 13 | ## 0.7.0 - 2020-02-24 14 | 15 | - Adding support for Laravel 7 16 | - Dropping support for Laravel 5.8 17 | 18 | ## 0.6.0 - 2019-12-02 19 | 20 | - Added support for PHP 7.4 21 | 22 | ## 0.5.2 - 2019-09-11 23 | 24 | - Fixed 'Call to a member function request() on null' 25 | 26 | ## 0.5.1 - 2019-09-09 27 | 28 | - Added support for custom port via configuration-file 29 | 30 | ## 0.5.0 - 2019-09-04 31 | 32 | - Added support for Laravel 6 33 | -------------------------------------------------------------------------------- /src/Api/Ip.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'ip' => ['get' => []] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'ip' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'ip' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/HttpClient/HttpClientInterface.php: -------------------------------------------------------------------------------- 1 | post([ 14 | 'dns' => ['get_rec' => ['filter' => $params]] 15 | ]); 16 | } 17 | 18 | /** 19 | * @param $params 20 | * @return mixed 21 | */ 22 | public function create($params) 23 | { 24 | return $this->post([ 25 | 'dns' => ['add_rec' => $params] 26 | ]); 27 | } 28 | 29 | /** 30 | * @param $params 31 | * @return mixed 32 | */ 33 | public function delete($params) 34 | { 35 | return $this->post([ 36 | 'dns' => ['del_rec' => ['filter' => $params]] 37 | ]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Api/Sessions.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'session' => ['get' => []] 14 | ]); 15 | } 16 | 17 | /** 18 | * @return mixed 19 | */ 20 | public function create($params) 21 | { 22 | return $this->post([ 23 | 'server' => ['create_session' => ['login' => $params, 'data' => ['user_ip' => base64_encode(request()->ip()), 'source_server' => '']]] 24 | ]); 25 | } 26 | 27 | /** 28 | * @param $params 29 | * @return mixed 30 | */ 31 | public function terminate($params) 32 | { 33 | return $this->post([ 34 | 'session' => ['terminate' => $params] 35 | ]); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Api/Nodejs.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'extension' => ['call' => ['nodejs' => ['versions' => []]]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function disable($params) 22 | { 23 | return $this->post([ 24 | 'extension' => ['call' => ['nodejs' => ['disable' => $params]]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function enable($params) 33 | { 34 | return $this->post([ 35 | 'extension' => ['call' => ['nodejs' => ['enable' => $params]]] 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Api/Extensions.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'extension' => ['get' => []] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function get($params) 22 | { 23 | return $this->post([ 24 | 'extension' => ['call' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function install($params) 33 | { 34 | return $this->post([ 35 | 'extension' => ['install' => $params] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function uninstall($params) 44 | { 45 | return $this->post([ 46 | 'extension' => ['uninstall' => $params] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Api/Subdomains.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'subdomain' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'subdomain' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'subdomain' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'subdomain' => ['get' => ['filter' => $params]] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Api/Locales.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'locale' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function disable($params) 22 | { 23 | return $this->post([ 24 | 'locale' => ['disable' => ['filter' => $params]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function enable($params) 33 | { 34 | return $this->post([ 35 | 'locale' => ['enable' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'locale' => ['get' => ['filter' => $params]] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Api/SitesAliases.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'site-alias' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'site-alias' => ['create' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'site-alias' => ['delete' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'site-alias' => ['get' => ['filter' => $params]] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Api/SecretKeys.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'secret_key' => ['get_info' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'secret_key' => ['create' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'secret_key' => ['delete' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'secret_key' => ['get_info' => ['filter' => $params]] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Api/AbstractApi.php: -------------------------------------------------------------------------------- 1 | client = $client; 22 | } 23 | 24 | /** 25 | * @param $parameters 26 | * @return mixed 27 | * @throws \GuzzleHttp\Exception\GuzzleException 28 | */ 29 | protected function post($parameters) 30 | { 31 | $parameters = ArrayToXml::convert($parameters, [ 32 | 'rootElementName' => 'packet', 33 | '_attributes' => [ 34 | 'version' => $this->client->getHttpClient()->getOptions()['version'], 35 | ], 36 | ]); 37 | 38 | $response = $this->client->getHttpClient()->post( 39 | $parameters 40 | ); 41 | 42 | return $response; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Api/ServicePlans.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'service-plan' => ['get' => ['filter' => [], 'owner-all' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'service-plan' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'service-plan' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'service-plan' => ['get' => ['filter' => $params, 'owner-all' => []]] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Api/Certificates.php: -------------------------------------------------------------------------------- 1 | post([ 14 | 'certificate' => ['remove' => ['filter' => $params]] 15 | ]); 16 | } 17 | 18 | /** 19 | * @param $params 20 | * @return mixed 21 | */ 22 | public function domain($params) 23 | { 24 | return $this->post([ 25 | 'certificate' => ['get-pool' => ['filter' => $params]] 26 | ]); 27 | } 28 | 29 | /** 30 | * @param $params 31 | * @return mixed 32 | */ 33 | public function generate($params) 34 | { 35 | return $this->post([ 36 | 'certificate' => ['generate' => $params] 37 | ]); 38 | } 39 | 40 | /** 41 | * @param $params 42 | * @return mixed 43 | */ 44 | public function install($params) 45 | { 46 | return $this->post([ 47 | 'certificate' => ['install' => $params] 48 | ]); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ServiceProvider.php: -------------------------------------------------------------------------------- 1 | publishes([ 15 | __DIR__ . '/../config/plesk-xml.php' => config_path('plesk-xml.php') 16 | ], 'config'); 17 | } 18 | 19 | /** 20 | * Get the services provided by the provider. 21 | * 22 | * @return array 23 | */ 24 | public function provides() 25 | { 26 | return ['nickurt\Plesk\PleskXml', 'PleskXml']; 27 | } 28 | 29 | /** 30 | * Register the service provider. 31 | * 32 | * @return void 33 | */ 34 | public function register() 35 | { 36 | $this->app->singleton('nickurt\PleskXml\Plesk', function ($app) { 37 | $plesk = new Plesk($app); 38 | $plesk->server($plesk->getDefaultServer()); 39 | 40 | return $plesk; 41 | }); 42 | 43 | $this->app->alias('nickurt\PleskXml\Plesk', 'PleskXml'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) nickurt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Api/ResellersPlans.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'reseller-plan' => ['get' => ['filter' => ['all' => []], 'limits' => [], 'permissions' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'reseller-plan' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'reseller-plan' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'reseller-plan' => ['get' => ['filter' => $params, 'limits' => [], 'permissions' => []]] 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nickurt/laravel-plesk-xml", 3 | "description": "Plesk Onyx 17.8 Xml for Laravel 6.x/7.x/8.x", 4 | "keywords": ["plesk", "plesk onyx", "plesk onyx 17.8", "laravel"], 5 | "license": "MIT", 6 | "require": { 7 | "php": "^8.0|^7.4", 8 | "laravel/framework": "^6.0|^7.0|^8.0", 9 | "guzzlehttp/guzzle": "^6.3.1|^7.0.1", 10 | "spatie/array-to-xml": "^3.1" 11 | }, 12 | "require-dev": { 13 | "orchestra/testbench": "^4.0|^5.0|^6.0" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "nickurt\\PleskXml\\": "src/" 18 | }, 19 | "files": [ 20 | "src/helpers.php" 21 | ] 22 | }, 23 | "autoload-dev": { 24 | "psr-4": { 25 | "nickurt\\PleskXml\\tests\\": "tests" 26 | } 27 | }, 28 | "scripts": { 29 | "test": "vendor/bin/phpunit", 30 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 31 | }, 32 | "minimum-stability": "dev", 33 | "prefer-stable": true, 34 | "extra": { 35 | "laravel": { 36 | "providers": [ 37 | "nickurt\\PleskXml\\ServiceProvider" 38 | ], 39 | "aliases": { 40 | "PleskXml": "nickurt\\PleskXml\\Facade" 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Api/Databases.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'database' => ['get-db' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'database' => ['add-db' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'database' => ['del-db' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'database' => ['get-db' => ['filter' => $params]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param array $params 52 | * @return mixed 53 | */ 54 | public function users($params = []) 55 | { 56 | return $this->post([ 57 | 'database' => ['get-db-users' => ['filter' => $params]] 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Api/Php.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'php-handler' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function disable($params) 22 | { 23 | return $this->post([ 24 | 'php-handler' => ['disable' => ['filter' => $params]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function enable($params) 33 | { 34 | return $this->post([ 35 | 'php-handler' => ['enable' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'php-handler' => ['get' => ['filter' => $params]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function usage($params) 55 | { 56 | return $this->post([ 57 | 'php-handler' => ['get-usage' => ['filter' => $params]] 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Api/LogRotations.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'log-rotation' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function disable($params) 22 | { 23 | return $this->post([ 24 | 'log-rotation' => ['disable' => ['filter' => $params]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function enable($params) 33 | { 34 | return $this->post([ 35 | 'log-rotation' => ['enable' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'log-rotation' => ['get' => ['filter' => $params]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function status($params) 55 | { 56 | return $this->post([ 57 | 'log-rotation' => ['get-status' => ['filter' => $params]] 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Api/Customers.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'customer' => ['get' => ['filter' => [], 'dataset' => ['gen_info' => [], 'stat' => []]]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'customer' => ['add' => ['gen_info' => $params]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'customer' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'customer' => ['get' => ['filter' => $params, 'dataset' => ['gen_info' => [], 'stat' => []]]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | * @throws \Http\Client\Exception 54 | */ 55 | public function update($params) 56 | { 57 | return $this->post(['customer' => ['set' => [$params]]]); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Api/Plesk.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'server' => ['get_additional_key' => []] 14 | ]); 15 | } 16 | 17 | /** 18 | * @return mixed 19 | */ 20 | public function information() 21 | { 22 | return $this->post([ 23 | 'server' => ['get' => ['admin' => []]] 24 | ]); 25 | } 26 | 27 | /** 28 | * @param $params 29 | * @return mixed 30 | */ 31 | public function install_key($params) 32 | { 33 | return $this->post([ 34 | 'server' => ['lic_install' => $params] 35 | ]); 36 | } 37 | 38 | /** 39 | * @return mixed 40 | */ 41 | public function key() 42 | { 43 | return $this->post([ 44 | 'server' => ['get' => ['key' => []]] 45 | ]); 46 | } 47 | 48 | /** 49 | * @return mixed 50 | */ 51 | public function rollback_key() 52 | { 53 | return $this->post([ 54 | 'server' => ['license-rollback-key' => []] 55 | ]); 56 | } 57 | 58 | /** 59 | * @return mixed 60 | */ 61 | public function services() 62 | { 63 | return $this->post([ 64 | 'server' => ['get' => ['services_state' => []]] 65 | ]); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Api/Sites.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'site' => ['get' => ['filter' => [], 'dataset' => ['gen_info' => [], 'hosting' => [], 'stat' => [], 'prefs' => [], 'disk_usage' => []]]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'site' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'site' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'site' => ['get' => ['filter' => $params, 'dataset' => ['gen_info' => [], 'hosting' => [], 'stat' => [], 'prefs' => [], 'disk_usage' => []]]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function traffic($params) 55 | { 56 | return $this->post([ 57 | 'site' => ['get_traffic' => ['filter' => $params]] 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Api/Ftp.php: -------------------------------------------------------------------------------- 1 | post([ 14 | 'ftp-user' => ['get' => ['filter' => []]] 15 | ]); 16 | } 17 | 18 | /** 19 | * @param $params 20 | * @return mixed 21 | * @throws \Http\Client\Exception 22 | */ 23 | public function create($params) 24 | { 25 | return $this->post([ 26 | 'ftp-user' => ['add' => $params] 27 | ]); 28 | } 29 | 30 | /** 31 | * @param $params 32 | * @return mixed 33 | * @throws \Http\Client\Exception 34 | */ 35 | public function delete($params) 36 | { 37 | return $this->post([ 38 | 'ftp-user' => ['del' => ['filter' => $params]] 39 | ]); 40 | } 41 | 42 | /** 43 | * @param $params 44 | * @return mixed 45 | * @throws \Http\Client\Exception 46 | */ 47 | public function get($params) 48 | { 49 | return $this->post([ 50 | 'ftp-user' => ['get' => ['filter' => $params]] 51 | ]); 52 | } 53 | 54 | /** 55 | * @param $params 56 | * @return mixed 57 | * @throws \Http\Client\Exception 58 | */ 59 | public function update($params) 60 | { 61 | return $this->post([ 62 | 'ftp-user' => ['set' => $params] 63 | ]); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Api/DatabasesServers.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'db_server' => ['get' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'db_server' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'db_server' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'db_server' => ['get' => ['filter' => $params]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @return mixed 52 | */ 53 | public function types() 54 | { 55 | return $this->post([ 56 | 'db_server' => ['get-supported-types' => []] 57 | ]); 58 | } 59 | 60 | /** 61 | * @param $params 62 | * @return mixed 63 | */ 64 | public function local($params) 65 | { 66 | return $this->post([ 67 | 'db_server' => ['get-local' => ['filter' => $params]] 68 | ]); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Api/Aps.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'aps' => ['get-packages-list' => ['filter' => []]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function download($params) 22 | { 23 | return $this->post([ 24 | 'aps' => ['download-package' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function import_config($params) 33 | { 34 | return $this->post([ 35 | 'aps' => ['import-config' => $params] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function import_package($params) 44 | { 45 | return $this->post([ 46 | 'aps' => ['import-package' => $params] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function install($params) 55 | { 56 | return $this->post([ 57 | 'aps' => ['install' => $params] 58 | ]); 59 | } 60 | 61 | /** 62 | * @param $params 63 | * @return mixed 64 | */ 65 | public function task($params) 66 | { 67 | return $this->post([ 68 | 'aps' => ['get-download-status' => ['filter' => $params]] 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Api/Git.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'extension' => ['call' => ['git' => ['get' => []]]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'extension' => ['call' => ['git' => ['create' => $params]]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'extension' => ['call' => ['git' => ['remove' => $params]]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function deploy($params) 44 | { 45 | return $this->post([ 46 | 'extension' => ['call' => ['git' => ['deploy' => $params]]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function fetch($params) 55 | { 56 | return $this->post([ 57 | 'extension' => ['call' => ['git' => ['fetch' => $params]]] 58 | ]); 59 | } 60 | 61 | /** 62 | * @param $params 63 | * @return mixed 64 | */ 65 | public function update($params) 66 | { 67 | return $this->post([ 68 | 'extension' => ['call' => ['git' => ['update' => $params]]] 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Api/Mail.php: -------------------------------------------------------------------------------- 1 | post([ 14 | 'mail' => ['create' => ['filter' => $params]] 15 | ]); 16 | } 17 | 18 | /** 19 | * @param $params 20 | * @return mixed 21 | */ 22 | public function delete($params) 23 | { 24 | return $this->post([ 25 | 'mail' => ['remove' => ['filter' => $params]] 26 | ]); 27 | } 28 | 29 | /** 30 | * @param $params 31 | * @return mixed 32 | */ 33 | public function disable($params) 34 | { 35 | return $this->post([ 36 | 'mail' => ['disable' => $params] 37 | ]); 38 | } 39 | 40 | /** 41 | * @param $params 42 | * @return mixed 43 | */ 44 | public function enable($params) 45 | { 46 | return $this->post([ 47 | 'mail' => ['enable' => $params] 48 | ]); 49 | } 50 | 51 | /** 52 | * @param $params 53 | * @return mixed 54 | */ 55 | public function get($params) 56 | { 57 | return $this->post([ 58 | 'mail' => ['get_info' => ['filter' => $params, 'mailbox' => [], 'mailbox-usage' => [], 'forwarding' => [], 'aliases' => [], 'autoresponder' => []]] 59 | ]); 60 | } 61 | 62 | /** 63 | * @param $params 64 | * @return mixed 65 | */ 66 | public function prefs($params) 67 | { 68 | return $this->post([ 69 | 'mail' => ['get_prefs' => ['filter' => $params]] 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: '0 0 * * *' 8 | 9 | jobs: 10 | php-tests: 11 | runs-on: ${{ matrix.os }} 12 | 13 | strategy: 14 | matrix: 15 | php: [8.0, 7.4] 16 | laravel: [8.*, 7.*, 6.*] 17 | dependency-version: [prefer-lowest, prefer-stable] 18 | os: [ubuntu-latest] 19 | include: 20 | - laravel: 8.* 21 | testbench: 6.* 22 | - laravel: 7.* 23 | testbench: 5.* 24 | - laravel: 6.* 25 | testbench: 4.* 26 | 27 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} 28 | 29 | steps: 30 | - name: Checkout code 31 | uses: actions/checkout@v2 32 | 33 | - name: Setup PHP 34 | uses: shivammathur/setup-php@v2 35 | with: 36 | php-version: ${{ matrix.php }} 37 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 38 | coverage: none 39 | 40 | - name: Install dependencies 41 | run: | 42 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update 43 | composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest 44 | 45 | - name: Execute tests 46 | run: vendor/bin/phpunit 47 | -------------------------------------------------------------------------------- /src/Api/Resellers.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'reseller' => ['get' => ['filter' => [], 'dataset' => ['gen-info' => [], 'stat' => [], 'permissions' => [], 'limits' => [], 'ippool' => []]]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'reseller' => ['add' => ['gen-info' => $params]] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'reseller' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function domains($params) 44 | { 45 | return $this->post([ 46 | 'reseller' => ['get-domain-list' => ['filter' => $params]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function get($params) 55 | { 56 | return $this->post([ 57 | 'reseller' => ['get' => ['filter' => $params, 'dataset' => ['gen-info' => [], 'stat' => [], 'permissions' => [], 'limits' => [], 'ippool' => []]]] 58 | ]); 59 | } 60 | 61 | /** 62 | * @param $params 63 | * @return mixed 64 | */ 65 | public function limits($params) 66 | { 67 | return $this->post([ 68 | 'reseller' => ['get-limit-descriptor' => ['filter' => $params]] 69 | ]); 70 | } 71 | 72 | /** 73 | * @param $params 74 | * @return mixed 75 | */ 76 | public function permissions($params) 77 | { 78 | return $this->post([ 79 | 'reseller' => ['get-permission-descriptor' => ['filter' => $params]] 80 | ]); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/HttpClient/HttpClient.php: -------------------------------------------------------------------------------- 1 | client)) { 22 | $this->client = new \GuzzleHttp\Client(); 23 | 24 | return $this->client; 25 | } 26 | 27 | return $this->client; 28 | } 29 | 30 | /** 31 | * @param array $body 32 | * @return mixed 33 | * @throws \GuzzleHttp\Exception\GuzzleException 34 | */ 35 | public function post($body = []) 36 | { 37 | return $this->request($body, 'POST'); 38 | } 39 | 40 | /** 41 | * @param $body 42 | * @param $method 43 | * @return mixed 44 | * @throws \GuzzleHttp\Exception\GuzzleException 45 | */ 46 | public function request($body, $method) 47 | { 48 | $response = $this->getClient()->request( 49 | $method, 50 | sprintf('https://%s:%s%s', $this->getOptions()['host'], $this->getOptions()['port'], '/enterprise/control/agent.php'), 51 | [ 52 | 'headers' => $this->getHeaders(), 53 | 'body' => $body 54 | ] 55 | ); 56 | 57 | return json_decode(json_encode(simplexml_load_string($response->getBody()))); 58 | } 59 | 60 | /** 61 | * @return array 62 | */ 63 | public function getOptions() 64 | { 65 | return $this->options; 66 | } 67 | 68 | /** 69 | * @param array $options 70 | */ 71 | public function setOptions(array $options) 72 | { 73 | $this->options = array_merge($this->options, $options); 74 | } 75 | 76 | /** 77 | * @return array 78 | */ 79 | public function getHeaders() 80 | { 81 | return $this->headers; 82 | } 83 | 84 | /** 85 | * @param array $headers 86 | */ 87 | public function setHeaders(array $headers) 88 | { 89 | $this->headers = array_merge($this->headers, $headers); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/Plesk.php: -------------------------------------------------------------------------------- 1 | app = $app; 24 | } 25 | 26 | /** 27 | * @param $method 28 | * @param $args 29 | * @return mixed 30 | */ 31 | public function __call($method, $args) 32 | { 33 | return call_user_func_array([$this->client, $method], $args); 34 | } 35 | 36 | /** 37 | * @param string|null $name 38 | * @return \nickurt\PleskXml\Client 39 | */ 40 | public function server($name = null) 41 | { 42 | $name = $name ?: $this->getDefaultServer(); 43 | 44 | return $this->servers[$name] = $this->get($name); 45 | } 46 | 47 | /** 48 | * @return string 49 | */ 50 | public function getDefaultServer() 51 | { 52 | return $this->app['config']['plesk-xml.default']; 53 | } 54 | 55 | /** 56 | * @param string $name 57 | * @return \nickurt\PleskXml\Client 58 | */ 59 | protected function get($name) 60 | { 61 | return $this->servers[$name] ?? $this->resolve($name); 62 | } 63 | 64 | /** 65 | * @param string $name 66 | * @return \nickurt\PleskXml\Client 67 | */ 68 | protected function resolve($name) 69 | { 70 | $config = $this->getConfig($name); 71 | 72 | $this->client = new \nickurt\PleskXml\Client(); 73 | $this->client->setHost($config['host']); 74 | $this->client->setPort($config['port'] ?? 8443); 75 | 76 | if (isset($config['key']) && strlen($config['key']) > 0) { 77 | $this->client->setSecretKey($config['key']); 78 | } else { 79 | $this->client->setCredentials( 80 | $config['username'], 81 | $config['password'] 82 | ); 83 | } 84 | 85 | return $this->client; 86 | } 87 | 88 | /** 89 | * @param string $name 90 | * @return array 91 | */ 92 | protected function getConfig($name) 93 | { 94 | return $this->app['config']["plesk-xml.servers.{$name}"]; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/Api/Subscriptions.php: -------------------------------------------------------------------------------- 1 | post([ 13 | 'webspace' => ['get' => ['filter' => [], 'dataset' => ['gen_info' => [], 'hosting' => [], 'subscriptions' => []]]] 14 | ]); 15 | } 16 | 17 | /** 18 | * @param $params 19 | * @return mixed 20 | */ 21 | public function create($params) 22 | { 23 | return $this->post([ 24 | 'webspace' => ['add' => $params] 25 | ]); 26 | } 27 | 28 | /** 29 | * @param $params 30 | * @return mixed 31 | */ 32 | public function delete($params) 33 | { 34 | return $this->post([ 35 | 'webspace' => ['del' => ['filter' => $params]] 36 | ]); 37 | } 38 | 39 | /** 40 | * @param $params 41 | * @return mixed 42 | */ 43 | public function get($params) 44 | { 45 | return $this->post([ 46 | 'webspace' => ['get' => ['filter' => $params, 'dataset' => ['aps-filter' => [], 'disk_usage' => [], 'gen_info' => [], 'hosting' => [], 'limits' => [], 'mail' => [], 'packages' => [], 'performance' => [], 'permissions' => [], 'php-settings' => [], 'plan-items' => [], 'prefs' => [], 'resource-usage' => [], 'stat' => [], 'subscriptions' => []]]] 47 | ]); 48 | } 49 | 50 | /** 51 | * @param $params 52 | * @return mixed 53 | */ 54 | public function hosting($params) 55 | { 56 | return $this->post([ 57 | 'webspace' => ['get-physical-hosting-descriptor' => ['filter' => $params]] 58 | ]); 59 | } 60 | 61 | /** 62 | * @param $params 63 | * @return mixed 64 | */ 65 | public function limits($params) 66 | { 67 | return $this->post([ 68 | 'webspace' => ['get-limit-descriptor' => ['filter' => $params]] 69 | ]); 70 | } 71 | 72 | /** 73 | * @param $params 74 | * @return mixed 75 | */ 76 | public function permissions($params) 77 | { 78 | return $this->post([ 79 | 'webspace' => ['get-permission-descriptor' => ['filter' => $params]] 80 | ]); 81 | } 82 | 83 | /** 84 | * @param $params 85 | * @return mixed 86 | */ 87 | public function traffic($params) 88 | { 89 | return $this->post([ 90 | 'webspace' => ['get_traffic' => ['filter' => $params]] 91 | ]); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /src/Client.php: -------------------------------------------------------------------------------- 1 | 'Aps', 15 | 'certificates' => 'Certificates', 16 | 'customers' => 'Customers', 17 | 'databases' => 'Databases', 18 | 'databasesservers' => 'DatabasesServers', 19 | 'dns' => 'Dns', 20 | 'extensions' => 'Extensions', 21 | 'ftp' => 'Ftp', 22 | 'git' => 'Git', 23 | 'ip' => 'Ip', 24 | 'locales' => 'Locales', 25 | 'logrotations' => 'LogRotations', 26 | 'mail' => 'Mail', 27 | 'nodejs' => 'Nodejs', 28 | 'php' => 'Php', 29 | 'plesk' => 'Plesk', 30 | 'resellers' => 'Resellers', 31 | 'resellersplans' => 'ResellersPlans', 32 | 'secretkeys' => 'SecretKeys', 33 | 'serviceplans' => 'ServicePlans', 34 | 'serviceplansaddons' => 'ServicePlansAddons', 35 | 'sessions' => 'Sessions', 36 | 'sites' => 'Sites', 37 | 'sitesaliases' => 'SitesAliases', 38 | 'subdomains' => 'Subdomains', 39 | 'subscriptions' => 'Subscriptions', 40 | ]; 41 | 42 | /** @var array */ 43 | private $options = [ 44 | 'port' => '8443', 45 | 'version' => '1.6.9.1', 46 | ]; 47 | 48 | /** 49 | * @param $method 50 | * @param $args 51 | * @return Api\Aps|Api\Certificates 52 | */ 53 | public function __call($method, $args) 54 | { 55 | try { 56 | return $this->api($method); 57 | } catch (InvalidArgumentException $e) { 58 | throw new \BadMethodCallException(sprintf('Undefined method called:"%s"', $method)); 59 | } 60 | } 61 | 62 | /** 63 | * @param $name 64 | * @return Api\Aps|Api\Certificates|Api\Customers|Api\Databases|Api\DatabasesServers|Api\Dns|Api\Extensions 65 | */ 66 | public function api($name) 67 | { 68 | if (!isset($this->classes[$name])) { 69 | throw new \InvalidArgumentException(sprintf('Undefined method called:"%s"', $name)); 70 | } 71 | 72 | $class = '\\nickurt\PleskXml\\Api\\' . $this->classes[$name]; 73 | 74 | return new $class($this); 75 | } 76 | 77 | /** 78 | * @param string $username 79 | * @param string $password 80 | */ 81 | public function setCredentials($username, $password) 82 | { 83 | $this->getHttpClient()->setHeaders([ 84 | 'HTTP_AUTH_LOGIN' => $username, 85 | 'HTTP_AUTH_PASSWD' => $password, 86 | ]); 87 | } 88 | 89 | /** 90 | * @return HttpClient 91 | */ 92 | public function getHttpClient() 93 | { 94 | if (!isset($this->client)) { 95 | $this->client = new HttpClient(); 96 | $this->client->setOptions($this->options); 97 | } 98 | 99 | return $this->client; 100 | } 101 | 102 | /** 103 | * @param string $host 104 | */ 105 | public function setHost($host) 106 | { 107 | $this->getHttpClient()->setOptions([ 108 | 'host' => $host 109 | ]); 110 | } 111 | 112 | /** 113 | * @param int $port 114 | */ 115 | public function setPort($port) 116 | { 117 | $this->getHttpClient()->setOptions([ 118 | 'port' => $port 119 | ]); 120 | } 121 | 122 | /** 123 | * @param string $secretKey 124 | */ 125 | public function setSecretKey($secretKey) 126 | { 127 | $this->getHttpClient()->setHeaders([ 128 | 'KEY' => $secretKey 129 | ]); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Laravel Plesk Onyx 17.8 Xml 2 | [![Build Status](https://github.com/nickurt/laravel-plesk-xml/workflows/tests/badge.svg)](https://github.com/nickurt/laravel-plesk-xml/actions) 3 | [![Total Downloads](https://poser.pugx.org/nickurt/laravel-plesk-xml/d/total.svg)](https://packagist.org/packages/nickurt/laravel-plesk) 4 | [![Latest Stable Version](https://poser.pugx.org/nickurt/laravel-plesk-xml/v/stable.svg)](https://packagist.org/packages/nickurt/laravel-plesk) 5 | [![MIT Licensed](https://poser.pugx.org/nickurt/laravel-plesk-xml/license.svg)](LICENSE.md) 6 | 7 | ### Table of contents 8 | - [Installation](#installation) 9 | - [Usage](#usage) 10 | - [Tests](#tests) 11 | ### Installation 12 | Install this package with composer: 13 | ``` 14 | composer require nickurt/laravel-plesk-xml 15 | ``` 16 | Copy the config files for the PleskXml-plugin 17 | ``` 18 | php artisan vendor:publish --provider="nickurt\PleskXml\ServiceProvider" --tag="config" 19 | ``` 20 | Add the Plesk credentials to your .env file 21 | ``` 22 | PLESK_DEFAULT_HOST= 23 | PLESK_DEFAULT_USERNAME= 24 | PLESK_DEFAULT_PASSWORD= 25 | ``` 26 | ### Usage 27 | #### Dependency injection [e.g. by using multiple servers] 28 | ```php 29 | // Route 30 | Route::get('/plesk/{plesk}/customers', ['as' => 'plesk/customers', 'uses' => 'CustomersController@getIndex']); 31 | 32 | Route::bind('plesk', function ($value, $route) { 33 | app('PleskXml')->server($value); 34 | 35 | return app('PleskXml'); 36 | }); 37 | 38 | // CustomersController 39 | public function getIndex(Plesk $plesk) 40 | { 41 | $customers = $plesk->customers()->all(); 42 | 43 | // 44 | } 45 | ``` 46 | #### Aps 47 | ```php 48 | \PleskXml::aps()->all() 49 | \PleskXml::aps()->download(array $params) 50 | \PleskXml::aps()->import_config(array $params) 51 | \PleskXml::aps()->import_package(array $params) 52 | \PleskXml::aps()->install(array $params) 53 | \PleskXml::aps()->task(array $params) 54 | ``` 55 | #### Certificates 56 | ```php 57 | \PleskXml::certificates()->delete(array $params) 58 | \PleskXml::certificates()->domain(array $params) 59 | \PleskXml::certificates()->generate(array $params) 60 | \PleskXml::certificates()->install(array $params) 61 | ``` 62 | #### Customers 63 | ```php 64 | \PleskXml::customers()->all() 65 | \PleskXml::customers()->create(array $params) 66 | \PleskXml::customers()->delete(array $params) 67 | \PleskXml::customers()->get(array $params) 68 | ``` 69 | #### Databases 70 | ```php 71 | \PleskXml::databases()->all() 72 | \PleskXml::databases()->create(array $params) 73 | \PleskXml::databases()->delete(array $params) 74 | \PleskXml::databases()->get(array $params) 75 | \PleskXml::databases()->users(array $params) 76 | ``` 77 | #### Databases Servers 78 | ```php 79 | \PleskXml::databasesservers()->all() 80 | \PleskXml::databasesservers()->create(array $params) 81 | \PleskXml::databasesservers()->delete(array $params) 82 | \PleskXml::databasesservers()->get(array $params) 83 | \PleskXml::databasesservers()->types() 84 | \PleskXml::databasesservers()->local(array $params) 85 | ``` 86 | #### Dns 87 | ```php 88 | \PleskXml::dns()->all(array $params) 89 | \PleskXml::dns()->create(array $params) 90 | \PleskXml::dns()->delete(array $params) 91 | ``` 92 | #### Extensions 93 | ```php 94 | \PleskXml::extensions()->all() 95 | \PleskXml::extensions()->get(array $params) 96 | \PleskXml::extensions()->install(array $params) 97 | \PleskXml::extensions()->uninstall(array $params) 98 | ``` 99 | #### Ftp 100 | ```php 101 | \PleskXml::ftp()->all() 102 | \PleskXml::ftp()->create(array $params) 103 | \PleskXml::ftp()->delete(array $params) 104 | \PleskXml::ftp()->get(array $params) 105 | \PleskXml::ftp()->update(array $params) 106 | ``` 107 | #### Git 108 | ```php 109 | \PleskXml::git()->all() 110 | \PleskXml::git()->create(array $params) 111 | \PleskXml::git()->delete(array $params) 112 | \PleskXml::git()->deploy(array $params) 113 | \PleskXml::git()->fetch(array $params) 114 | \PleskXml::git()->update(array $params) 115 | ``` 116 | #### Ip 117 | ```php 118 | \PleskXml::ip()->all() 119 | \PleskXml::ip()->create(array $params) 120 | \PleskXml::ip()->delete(array $params) 121 | ``` 122 | #### Locales 123 | ```php 124 | \PleskXml::locales()->all() 125 | \PleskXml::locales()->disable(array $params) 126 | \PleskXml::locales()->enable(array $params) 127 | \PleskXml::locales()->get(array $params) 128 | ``` 129 | #### LogRotations 130 | ```php 131 | \PleskXml::logrotations()->all() 132 | \PleskXml::logrotations()->disable(array $params) 133 | \PleskXml::logrotations()->enable(array $params) 134 | \PleskXml::logrotations()->get(array $params) 135 | \PleskXml::logrotations()->status(array $params) 136 | ``` 137 | #### Mail 138 | ```php 139 | \PleskXml::mail()->create(array $params) 140 | \PleskXml::mail()->delete(array $params) 141 | \PleskXml::mail()->disable(array $params) 142 | \PleskXml::mail()->enable(array $params) 143 | \PleskXml::mail()->get(array $params) 144 | \PleskXml::mail()->prefs(array $params) 145 | ``` 146 | #### NodeJS 147 | ```php 148 | \PleskXml::nodejs()->all() 149 | \PleskXml::nodejs()->disable(array $params) 150 | \PleskXml::nodejs()->enable(array $params) 151 | ``` 152 | #### Php 153 | ```php 154 | \PleskXml::php()->all() 155 | \PleskXml::php()->disable(array $params) 156 | \PleskXml::php()->enable(array $params) 157 | \PleskXml::php()->get(array $params) 158 | \PleskXml::php()->usage(array $params) 159 | ``` 160 | #### Plesk 161 | ```php 162 | \PleskXml::plesk()->additional_key() 163 | \PleskXml::plesk()->information() 164 | \PleskXml::plesk()->install_key(array $params) 165 | \PleskXml::plesk()->key() 166 | \PleskXml::plesk()->rollback_key() 167 | \PleskXml::plesk()->services() 168 | ``` 169 | #### Resellers 170 | ```php 171 | \PleskXml::resellers()->all() 172 | \PleskXml::resellers()->create(array $params) 173 | \PleskXml::resellers()->delete(array $params) 174 | \PleskXml::resellers()->domains(array $params) 175 | \PleskXml::resellers()->get(array $params) 176 | \PleskXml::resellers()->limits(array $params) 177 | \PleskXml::resellers()->permissions(array $params) 178 | ``` 179 | #### Resellers Plans 180 | ```php 181 | \PleskXml::resellersplans()->all() 182 | \PleskXml::resellersplans()->create(array $params) 183 | \PleskXml::resellersplans()->delete(array $params) 184 | \PleskXml::resellersplans()->get(array $params) 185 | ``` 186 | #### SecretKeys 187 | ```php 188 | \PleskXml::secretkeys()->all() 189 | \PleskXml::secretkeys()->create(array $params) 190 | \PleskXml::secretkeys()->delete(array $params) 191 | \PleskXml::secretkeys()->get(array $params) 192 | ``` 193 | #### ServicePlans 194 | ```php 195 | \PleskXml::serviceplans()->all() 196 | \PleskXml::serviceplans()->create(array $params) 197 | \PleskXml::serviceplans()->delete(array $params) 198 | \PleskXml::serviceplans()->get(array $params) 199 | ``` 200 | #### ServicePlans Addons 201 | ```php 202 | \PleskXml::serviceplansaddons()->all() 203 | \PleskXml::serviceplansaddons()->get(array $params) 204 | ``` 205 | #### Sessions 206 | ```php 207 | \PleskXml::sessions()->all() 208 | \PleskXml::sessions()->create(array $params) 209 | \PleskXml::sessions()->terminate(array $params) 210 | ``` 211 | #### Sites 212 | ```php 213 | \PleskXml::sites()->all() 214 | \PleskXml::sites()->create(array $params) 215 | \PleskXml::sites()->delete(array $params) 216 | \PleskXml::sites()->get(array $params) 217 | \PleskXml::sites()->traffic(array $params) 218 | ``` 219 | #### SitesAliases 220 | ```php 221 | \PleskXml::sitesaliases()->all() 222 | \PleskXml::sitesaliases()->create(array $params) 223 | \PleskXml::sitesaliases()->delete(array $params) 224 | \PleskXml::sitesaliases()->get(array $params) 225 | ``` 226 | #### Subdomains 227 | ```php 228 | \PleskXml::subdomains()->all() 229 | \PleskXml::subdomains()->create(array $params) 230 | \PleskXml::subdomains()->delete(array $params) 231 | \PleskXml::subdomains()->get(array $params) 232 | ``` 233 | #### Subscriptions 234 | ```php 235 | \PleskXml::subscriptions()->all() 236 | \PleskXml::subscriptions()->create(array $params) 237 | \PleskXml::subscriptions()->delete(array $params) 238 | \PleskXml::subscriptions()->get(array $params) 239 | \PleskXml::subscriptions()->hosting(array $params) 240 | \PleskXml::subscriptions()->limits(array $params) 241 | \PleskXml::subscriptions()->permissions(array $params) 242 | \PleskXml::subscriptions()->traffic(array $params) 243 | ``` 244 | ### Tests 245 | ```sh 246 | phpunit 247 | ``` 248 | - - - 249 | --------------------------------------------------------------------------------