2

I'm working on a plugin for OctoberCMS and will use Omnipay. I've done a research and found some packages that integrates the Omnipay library with Laravel as ignited/omnipay and barryvdh/laravel-omnipay. I've tried both of them by following this steps (all on the plugin directory):

  • Create a composer.json file and add this:

    {
        "name": "BalanceRecharge Plugin",
        "email": "webmaster@root.com",
        "require": {
            #in this case I'm using barryvdh/laravel-omnipay
            "barryvdh/laravel-omnipay": "0.1.*", 
            "omnipay/omnipay": "*"
        }
    }
    
  • Run composer update for update library and dependencies, all good

  • Add 'Barryvdh\Omnipay\ServiceProvider' to the providers:

    'providers' => array_merge(include(base_path().'/modules/system/providers.php'), array(
    
        // 'Illuminate\Html\HtmlServiceProvider', // Example
    
        'System\ServiceProvider',
        'Barryvdh\Omnipay\ServiceProvider',
    )),
    
  • Then try to run the command php artisan config:publish barryvdh/laravel-omnipay but get the error below:

PHP Fatal error: Class 'Barryvdh\Omnipay\ServiceProvider' not found in /var/www/html/alomicuba/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157 PHP Stack trace: PHP 1. {main}() /var/www/html/alomicuba/artisan:0 PHP 2. require_once() /var/www/html/alomicuba/artisan:30 PHP 3. require() /var/www/html/alomicuba/bootstrap/start.php:57 PHP 4. Illuminate\Foundation\ProviderRepository->load() /var/www/html/alomicuba/vendor/laravel/framework/src/Illuminate/Foundation/start.php:210 PHP 5. Illuminate\Foundation\ProviderRepository->compileManifest() /var/www/html/alomicuba/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:57 PHP 6. Illuminate\Foundation\ProviderRepository->createProvider() /var/www/html/alomicuba/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:121

What I'm doing wrong? What is the right way to register the Provider?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363

1 Answers1

2

if you want to use laravel packages in plugin you have to register service provider and alias in plugin.php

Register the plugins Service Provider In your Plugin.php's boot() method, add

\App::register('\Third\Party\ServiceProvider');.

This is how you register a third party ServiceProvider automatically.

Register any Alias's In your Plugin.php's boot() method under any ServiceProvider lines, if you then need to add an Alias it can be done with

$alias = \Illuminate\Foundation\AliasLoader::getInstance()->alias('YourAlias', 'Third\Party\Facade');

check this link https://github.com/Shahiem/CKeditor-plugin/blob/master/Plugin.php#L53

Bhavin Solanki
  • 1,364
  • 11
  • 27
Anand Patel
  • 3,885
  • 3
  • 17
  • 23