带有依赖包的Laravel包

时间:2018-01-02 16:28:21

标签: laravel package

我正在开发laravel包。这是我的composer.json文件。在我的本地包中,我正在添加 opentok / opentok 依赖包。因此在运行composer之后,在我的本地包中创建了vendor文件夹。我在config / app.php文件中包含了我的服务提供程序。但我无法在本地包中使用依赖包类。这是我的本地包composer.json文件。

 {
    "name": "cast/talk",
    "description": "video caht",
    "require": {
        "opentok/opentok": "2.5.x"
    }
}

我的serviceprovider

<?php

namespace cast\Talk;

use Illuminate\Support\ServiceProvider;

class TalkServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
        include __DIR__.'/routes.php';
        $this->app->make('cast\Talk\TalkController');
    }
}

我的包裹控制器

<?php

namespace cast\Talk;
use App\Http\Controllers\Controller;
use OpenTok\OpenTok;
use OpenTok\MediaMode;
use OpenTok\Session as OpentokSession;
use OpenTok\Role;

class TalkController extends Controller
{

    public function index()
    {

        $opentok = new OpenTok('xxxxxxx', 'xxxxxxxxxxxxxxxxx');

        $sessionOptions = array(
            'mediaMode' => MediaMode::ROUTED
        );
        $session = $opentok->createSession($sessionOptions);

        echo $sessionId = $session->getSessionId();die;
    }

}

routes.php文件

<?php

Route::get('members', 
  'cast\talk\TalkController@index');

当我访问会员页面时,我正在获得Class&#39; OpenTok \ OpenTok&#39;找不到

那么如何在laravel包中使用依赖包呢?

0 个答案:

没有答案