environment for use with youtube, has validators, helpers, apis, widgets...

Installs: 553

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0


v1.1.1 2021-05-24 18:48 UTC

This package is auto-updated.

Last update: 2024-03-25 00:59:15 UTC


Latest Stable Version Total Downloads License Codacy Badge Build Test


The preferred way to install this extension is through composer.

Either run

$ composer require dynamikaweb/yii2-youtube "*"

or add

"dynamikaweb/yii2-youtube": "*"

to the require section of your composer.json file.


Add it to your components

add to your components

'components' => [
    'youtube' => [
        'class' => \sr1871\youtubeApi\components\YoutubeApi::className(),
        'api_config' => [
            'clientId' => 'your Oauth Client Id, you can get it from google console',
            'clientSecret' => 'your Oauth Client Secret, you can get it from google console',
            'scopes' => ['scopes that you going to use', 'as array'],
        'channel' = 'youtube channel, which will be consulted'

generate your access token

An advantage of this component is that you only have to generate your access token once.

Create an action in any controller

public function actionYoutubeValidation() {
        return $this->redirect(Yii::$app->youtube->validationGet(Yii::$app->urlManager->createAbsoluteUrl('/site/youtube-validation')));

    } else {
        Yii::$app->session->setFlash('success', 'The access token was generated');
        return $this->redirect('index');

To validate access to the action by passing the validate parameter come true. This will access google to do the validation and it will return to the same action by passing the parameter code with the Access Token.




Yii::$app->youtube->setParts(['snippet', 'recordingDetails', 'id'])->listVideos(['id' => 'someId'])

You can pass in setParts(), the parts that you want, if you don't want the default parts. For more information of every method and how do it, read the PhpDOC of component's methods