diff --git a/README.md b/README.md index 2fa0ea3..e5f68fb 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,47 @@ to work with PHP7 in accordance with the PSR standards. You can use this library with pre-6.43 and post-6.43 versions of RouterOS firmware, it will be detected automatically on connection stage. +## Laravel framework support + +RouterOS API client is optimized for usage as normal Laravel package, all functional is available via `\RouterOS` facade, +for access to client object you need instead: + +```php +$config = new \RouterOS\Config(['api_key' => getenv('API_KEY')]); +$client = new \RouterOS\Client($config); +``` + +Call facade and pass array of parameters to `getClient` method: + +```php +$client = \RouterOS::getClient([ + 'user' => 'admin', + 'pass' => 'admin', + 'port' => 8728, +]); +``` + +### Laravel installation + +Install the package via Composer: + + composer require evilfreelancer/routeros-api-php + +By default the package will automatically register its service provider, but +if you are a happy owner of Laravel version less than 5.3, then in a project, which is using your package +(after composer require is done, of course), add into`providers` block of your `config/app.php`: + +```php +'providers' => [ + // ... + RouterOS\Laravel\ClientServiceProvider::class, +], +``` + +Optionally, publish the configuration file if you want to change any defaults: + + php artisan vendor:publish --provider="RouterOS\\Laravel\\ClientServiceProvider" + ## How to use Basic example, analogue via command line is `/ip hotspot ip-binding print`: diff --git a/src/Laravel/ClientServiceProvide.php b/src/Laravel/ClientServiceProvider.php similarity index 92% rename from src/Laravel/ClientServiceProvide.php rename to src/Laravel/ClientServiceProvider.php index c087064..9ce33ab 100644 --- a/src/Laravel/ClientServiceProvide.php +++ b/src/Laravel/ClientServiceProvider.php @@ -4,7 +4,7 @@ namespace RouterOS\Laravel; use Illuminate\Support\ServiceProvider as BaseServiceProvider; -class ClientServiceProvide extends BaseServiceProvider +class ClientServiceProvider extends BaseServiceProvider { /** * Bootstrap any application services.