Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoriohc committed Feb 5, 2016
0 parents commit 0d97045
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
.DS_Store
/.idea/
/vendor/
composer.phar
composer.lock
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Colin Viebrock

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

67 changes: 67 additions & 0 deletions README.md
@@ -0,0 +1,67 @@
# Laravel 5 Plesk RPC API wrapper

A simple Laravel 5 package that wraps [Plesk](https://plesk.com) RPC API.

## Requirements

* PHP 5.4 or greater

## Installation

You can install the package using the [Composer](https://getcomposer.org/) package manager running this command in your project root:

```sh
composer require gregoriohc/laravel-plesk
```

## Laravel

The package includes a service providers and a facade for easy integration and a nice syntax for Laravel.

Firstly, add the `Gregoriohc\LaravelPlesk\PleskServiceProvider` provider to the providers array in `config/app.php`

```php
'providers' => [
...
Gregoriohc\LaravelPlesk\PleskServiceProvider::class,
],
```

and then add the facade to your `aliases` array

```php
'aliases' => [
...
'Plesk' => Gregoriohc\LaravelPlesk\Facades\Wrapper::class,
],
```

### Configuration

Publish the configuration file with:

```sh
php artisan vendor:publish --provider="Gregoriohc\LaravelPlesk\PleskServiceProvider"
```

Head into the file and configure the keys and defaults you'd like the package to use.

## Usage

#### Creating an user

```php
Plesk::customer()->create([
'pname' => 'John Smith',
'login' => 'john-unit-test',
'passwd' => 'simple-password',
]);
```

#### More examples

For more examples of usage, please see the original PHP Plesk RPC API package tests: https://github.com/plesk/api-php-lib/tree/master/tests

## Contributing

If you're having problems, spot a bug, or have a feature suggestion, please log and issue on Github. If you'd like to have a crack yourself, fork the package and make a pull request.
29 changes: 29 additions & 0 deletions composer.json
@@ -0,0 +1,29 @@
{
"name": "gregoriohc/laravel-plesk",
"description": "A Laravel wrapper and facade package for the Plesk RPC API",
"keywords": ["laravel", "package", "facade", "plesk", "api"],
"homepage": "https://github.com/gregoriohc/laravel-plesk",
"license": "MIT",
"authors": [
{
"name": "Gregorio Hernández Caso",
"email": "gregoriohc@gmail.com"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/config": "~5",
"illuminate/support": "~5",
"plesk/api-php-lib": "@dev"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"autoload": {
"psr-4": {
"Gregoriohc\\LaravelPlesk\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
38 changes: 38 additions & 0 deletions config/plesk.php
@@ -0,0 +1,38 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Plesk Host
|--------------------------------------------------------------------------
|
| Your Plesk host name
|
*/

'host' => env('PLESK_HOST', ''),

/*
|--------------------------------------------------------------------------
| Plesk Login
|--------------------------------------------------------------------------
|
| Your Plesk login
|
*/

'login' => env('PLESK_LOGIN', ''),

/*
|--------------------------------------------------------------------------
| Plesk Host
|--------------------------------------------------------------------------
|
| Your Plesk passworkd
|
*/

'password' => env('PLESK_PASSWORD', ''),

];
16 changes: 16 additions & 0 deletions src/Facades/Wrapper.php
@@ -0,0 +1,16 @@
<?php

namespace Gregoriohc\LaravelPlesk\Facades;

use Illuminate\Support\Facades\Facade;

class Wrapper extends Facade {

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'plesk'; }

}
56 changes: 56 additions & 0 deletions src/PleskServiceProvider.php
@@ -0,0 +1,56 @@
<?php

namespace Gregoriohc\LaravelPlesk;

use Illuminate\Support\ServiceProvider as LaravelServiceProvider;

class PleskServiceProvider extends LaravelServiceProvider {

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot() {

$this->handleConfigs();
}

/**
* Register the service provider.
*
* @return void
*/
public function register() {

$this->app['plesk'] = $this->app->share(function($app) {
return new Wrapper($app['config']);
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides() {

return [];
}

private function handleConfigs() {

$configPath = __DIR__ . '/../config/plesk.php';

$this->publishes([$configPath => config_path('plesk.php')]);

$this->mergeConfigFrom($configPath, 'plesk');
}
}
51 changes: 51 additions & 0 deletions src/Wrapper.php
@@ -0,0 +1,51 @@
<?php

namespace Gregoriohc\LaravelPlesk;

use Illuminate\Config\Repository;
use PleskX\Api\Client;

class Wrapper
{
/**
* The config instance
*
* @var Repository
*/
public $config;

/**
* The Plesk api client instance
*
* @var \PleskX\Api\Client
*/
public $client;

/**
* Client constructor
*
* @param Repository $config
*/
public function __construct(Repository $config)
{
// Get the config data
$this->config = $config;

// Make the client instance
$this->client = new Client($this->config->get('plesk.host'));
$this->client->setCredentials($this->config->get('plesk.login'), $this->config->get('plesk.password'));
}

/**
* Handle dynamic calls to the client
*
* @param $name
* @param $arguments
*
* @return mixed
*/
public function __call($name, $arguments)
{
return call_user_func_array([$this->client, $name], $arguments);
}
}

0 comments on commit 0d97045

Please sign in to comment.