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?

4

1 回答 1

2

如果你想在插件中使用 laravel 包,你必须在 plugin.php 中注册服务提供者和别名

注册插件服务提供者 在你的 Plugin.php 的 boot() 方法中,添加

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

这是您自动注册第三方 ServiceProvider 的方式。

在任何 ServiceProvider 行下的 Plugin.php 的 boot() 方法中注册任何别名 ,如果您需要添加别名,可以使用

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

检查此链接https://github.com/Shahiem/CKeditor-plugin/blob/master/Plugin.php#L53

于 2014-10-04T18:39:46.020 回答