hiddeco / laravel-transip
Laravel TransIP is a bridge for the TransIP SOAP client and Laravel 5.
Installs: 4 408
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 0
Forks: 12
Open Issues: 2
pkg:composer/hiddeco/laravel-transip
Requires
- graham-campbell/manager: ~3.0|~4.0
- hiddeco/transip: ~5.7
- illuminate/contracts: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0
- illuminate/support: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0
- laravel/helpers: ^1.0
Requires (Dev)
- graham-campbell/testbench: ~3.0|~4.0|~5.0
- mockery/mockery: ^1.0
- phpunit/phpunit: 4.*|^6.5|^7.0|^8.0
README
Laravel TransIP provides a bridge between the TransIP package and Laravel 5.*.
Installation
To use this package without running into trouble you will need PHP 5.5+ or HHVM 3.6+, and Composer.
-
Get the latest version of Laravel TransIP, add the following line to your composer.json file
"hiddeco/laravel-transip": "~5.3" -
Run
composer updateorcomposer install -
Register the Laravel TransIP service provider in
config/app.phpby adding'TransIP\Laravel\TransIPServiceProvider::class'to the providers key -
Add the
TransIPfacade to the aliases key:'TransIP' => TransIP\Laravel\Facades\TransIP::class
Configuration
To manage your TransIP connections run the php artisan vendor:publish command, this will create the config/transip.php
file where you can modify and manage your client connections.
The following configuration options are available:
Default Connection Name
The TransIP connection name set here (default) is the default connection used for all API requests. However, you may
use as many connections as you need using the manager class. The default setting is 'main'.
TransIP Connections
This is the place to configure your TransIP connections (connections). A default configuration with possible
options (except your API credentials) is already present and there is no limit to the amount of connections.
Each connection has 2 required fields (username and private_key) and 2 optional fields (mode and endpoint).
It is worth mentioning the mode field only accepts readonly and readwrite as values.
Usage
TransIP Manager
The TransIPManager is where the magic happens. Bounded to the ioc container as transip and accessible by using the
Facade\TransIP facade. It uses parts of the Laravel Manager
package to manage the TransIP client connections. For more information about the Manager you should check out the respective
docs.
It is worth noting the connection returned will always be an instance of \HiddeCo\TransIP\Client. You
can find more information about this instance and its methods in the TransIP docs.
TransIP Facade
The TransIP facade will pass static method calls to the transip object in the ioc container, which as stated
before is the TransIPManager class.
Examples
The usage of this package is fairly simple. Add your TransIP API credentials to the main connection and the package
will work without any further settings.
Using the Facade
use TransIP\Laravel\Facades\TransIP; $domainNames = TransIP::domain()->getDomainNames(); // and you're done
Using the TransIP Manager
The TransIPManager returns an instance of \HiddeCo\TransIP\Client and will behave like it. If
you want to call a specific connection, you can use the connection method:
use TransIP\Laravel\Facades\TransIP; $domainNames = TransIP::connection('alternative')->domain()->getDomainNames();
Changing the default connection and further explanations:
use TransIP\Laravel\Facades\TransIP; TransIP::connection('main')->domain()->getDomainNames(); TransIP::domain()->getDomainNames(); TransIP::connection()->domain()->getDomainNames(); // are all the same because TransIP::getDefaultConnection(); // returns 'main' as set in the configuration file TransIP::setDefaultConnection('alternative'); // the 'alternative' connection is now the default connection
Dependency Injection
Prefer the use of a dependency injection over facades? You can easily inject the manager:
use TransIP\Laravel\TransIPManager; class Foo { protected $transIP; public function __construct(TransIPManager $transIP) { $this->transIP; } public function bar() { $this->transIP->domain()->getDomainNames(); } }
License
Laravel TransIP is licensed under The MIT License (MIT).