repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/LoginForm.php | common/models/LoginForm.php | <?php
namespace common\models;
use Yii;
use yii\base\Model;
/**
* Login form
*/
class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
private $_user;
/**
* {@inheritdoc}
*/
public function rules()
{
return [
// username and password are both required
[['username', 'password'], 'required'],
// rememberMe must be a boolean value
['rememberMe', 'boolean'],
// password is validated by validatePassword()
['password', 'validatePassword'],
];
}
/**
* Validates the password.
* This method serves as the inline validation for password.
*
* @param string $attribute the attribute currently being validated
* @param array $params the additional name-value pairs given in the rule
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) {
$this->addError($attribute, 'Incorrect username or password.');
}
}
}
/**
* Logs in a user using the provided username and password.
*
* @return bool whether the user is logged in successfully
*/
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
}
return false;
}
/**
* Finds user by [[username]]
*
* @return User|null
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = User::findByUsername($this->username);
}
return $this->_user;
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/User.php | common/models/User.php | <?php
namespace common\models;
use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;
/**
* User model
*
* @property integer $id
* @property string $username
* @property string $password_hash
* @property string $password_reset_token
* @property string $verification_token
* @property string $email
* @property string $auth_key
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
* @property string $password write-only password
*/
class User extends ActiveRecord implements IdentityInterface
{
const STATUS_DELETED = 0;
const STATUS_INACTIVE = 9;
const STATUS_ACTIVE = 10;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%user}}';
}
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
TimestampBehavior::className(),
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['status', 'default', 'value' => self::STATUS_INACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_INACTIVE, self::STATUS_DELETED]],
];
}
/**
* @return \yii\db\ActiveQuery
* @throws \yii\base\InvalidConfigException
* @author Zura Sekhniashvili <zurasekhniashvili@gmail.com>
*/
public function getSubscribers()
{
return $this->hasMany(User::class, ['id' => 'user_id'])
->viaTable('subscriber', ['channel_id' => 'id']);
}
/**
* {@inheritdoc}
*/
public static function findIdentity($id)
{
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
}
/**
* {@inheritdoc}
*/
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
* Finds user by username
*
* @param string $username
* @return static|null
*/
public static function findByUsername($username)
{
return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
}
/**
* Finds user by password reset token
*
* @param string $token password reset token
* @return static|null
*/
public static function findByPasswordResetToken($token)
{
if (!static::isPasswordResetTokenValid($token)) {
return null;
}
return static::findOne([
'password_reset_token' => $token,
'status' => self::STATUS_ACTIVE,
]);
}
/**
* Finds user by verification email token
*
* @param string $token verify email token
* @return static|null
*/
public static function findByVerificationToken($token) {
return static::findOne([
'verification_token' => $token,
'status' => self::STATUS_INACTIVE
]);
}
/**
* Finds out if password reset token is valid
*
* @param string $token password reset token
* @return bool
*/
public static function isPasswordResetTokenValid($token)
{
if (empty($token)) {
return false;
}
$timestamp = (int) substr($token, strrpos($token, '_') + 1);
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
return $timestamp + $expire >= time();
}
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->getPrimaryKey();
}
/**
* {@inheritdoc}
*/
public function getAuthKey()
{
return $this->auth_key;
}
/**
* {@inheritdoc}
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* Validates password
*
* @param string $password password to validate
* @return bool if password provided is valid for current user
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model
*
* @param string $password
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
/**
* Generates "remember me" authentication key
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
/**
* Generates new password reset token
*/
public function generatePasswordResetToken()
{
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
}
/**
* Generates new token for email verification
*/
public function generateEmailVerificationToken()
{
$this->verification_token = Yii::$app->security->generateRandomString() . '_' . time();
}
/**
* Removes password reset token
*/
public function removePasswordResetToken()
{
$this->password_reset_token = null;
}
public function isSubscribed($userId)
{
return Subscriber::find()->andWhere([
'channel_id' => $this->id,
'user_id' => $userId
])->one();
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/VideoLike.php | common/models/VideoLike.php | <?php
namespace common\models;
use Yii;
/**
* This is the model class for table "{{%video_like}}".
*
* @property int $id
* @property string $video_id
* @property int $user_id
* @property int|null $type
* @property int|null $created_at
*
* @property User $user
* @property Video $video
*/
class VideoLike extends \yii\db\ActiveRecord
{
const TYPE_LIKE = 1;
const TYPE_DISLIKE = 0;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%video_like}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['video_id', 'user_id'], 'required'],
[['user_id', 'type', 'created_at'], 'integer'],
[['video_id'], 'string', 'max' => 16],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
[['video_id'], 'exist', 'skipOnError' => true, 'targetClass' => Video::className(), 'targetAttribute' => ['video_id' => 'video_id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'video_id' => 'Video ID',
'user_id' => 'User ID',
'type' => 'Type',
'created_at' => 'Created At',
];
}
/**
* Gets query for [[User]].
*
* @return \yii\db\ActiveQuery|\common\models\query\UserQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
/**
* Gets query for [[Video]].
*
* @return \yii\db\ActiveQuery|\common\models\query\VideoQuery
*/
public function getVideo()
{
return $this->hasOne(Video::className(), ['video_id' => 'video_id']);
}
/**
* {@inheritdoc}
* @return \common\models\query\VideoLikeQuery the active query used by this AR class.
*/
public static function find()
{
return new \common\models\query\VideoLikeQuery(get_called_class());
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/Subscriber.php | common/models/Subscriber.php | <?php
namespace common\models;
use Yii;
/**
* This is the model class for table "{{%subscriber}}".
*
* @property int $id
* @property int|null $channel_id
* @property int|null $user_id
* @property int|null $created_at
*
* @property User $channel
* @property User $user
*/
class Subscriber extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%subscriber}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['channel_id', 'user_id', 'created_at'], 'integer'],
[['channel_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['channel_id' => 'id']],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'channel_id' => 'Channel ID',
'user_id' => 'User ID',
'created_at' => 'Created At',
];
}
/**
* Gets query for [[Channel]].
*
* @return \yii\db\ActiveQuery|\common\models\query\UserQuery
*/
public function getChannel()
{
return $this->hasOne(User::className(), ['id' => 'channel_id']);
}
/**
* Gets query for [[User]].
*
* @return \yii\db\ActiveQuery|\common\models\query\UserQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
/**
* {@inheritdoc}
* @return \common\models\query\SubscriberQuery the active query used by this AR class.
*/
public static function find()
{
return new \common\models\query\SubscriberQuery(get_called_class());
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/Comment.php | common/models/Comment.php | <?php
namespace common\models;
use Yii;
use yii\behaviors\BlameableBehavior;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "{{%comment}}".
*
* @property int $id
* @property string $comment
* @property string $video_id
* @property int|null $parent_id
* @property int|null $pinned
* @property string $mention
* @property int|null $created_at
* @property int|null $updated_at
* @property int|null $created_by
*
* @property User $createdBy
* @property Comment $parent
* @property Comment[] $comments
* @property Video $video
*/
class Comment extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%comment}}';
}
public function behaviors()
{
return [
TimestampBehavior::class,
[
'class' => BlameableBehavior::class,
'updatedByAttribute' => false
]
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['comment', 'video_id'], 'required'],
[['comment'], 'string'],
[['parent_id', 'pinned', 'created_at', 'updated_at', 'created_by'], 'integer'],
[['video_id'], 'string', 'max' => 16],
[['mention'], 'string', 'max' => 255],
[['created_by'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['created_by' => 'id']],
[['parent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Comment::className(), 'targetAttribute' => ['parent_id' => 'id']],
[['video_id'], 'exist', 'skipOnError' => true, 'targetClass' => Video::className(), 'targetAttribute' => ['video_id' => 'video_id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'comment' => 'Comment',
'video_id' => 'Video ID',
'parent_id' => 'Parent ID',
'pinned' => 'Pinned',
'mention' => 'Mention',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'created_by' => 'Created By',
];
}
/**
* Gets query for [[CreatedBy]].
*
* @return \yii\db\ActiveQuery|\common\models\query\UserQuery
*/
public function getCreatedBy()
{
return $this->hasOne(User::className(), ['id' => 'created_by']);
}
/**
* Gets query for [[Parent]].
*
* @return \yii\db\ActiveQuery|\common\models\query\CommentQuery
*/
public function getParent()
{
return $this->hasOne(Comment::className(), ['id' => 'parent_id']);
}
/**
* Gets query for [[Comments]].
*
* @return \yii\db\ActiveQuery|\common\models\query\CommentQuery
*/
public function getComments()
{
return $this->hasMany(Comment::className(), ['parent_id' => 'id']);
}
/**
* Gets query for [[Video]].
*
* @return \yii\db\ActiveQuery|\common\models\query\VideoQuery
*/
public function getVideo()
{
return $this->hasOne(Video::className(), ['video_id' => 'video_id']);
}
/**
* {@inheritdoc}
* @return \common\models\query\CommentQuery the active query used by this AR class.
*/
public static function find()
{
return new \common\models\query\CommentQuery(get_called_class());
}
public function belongsTo($userId)
{
return $this->created_by === $userId;
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/VideoView.php | common/models/VideoView.php | <?php
namespace common\models;
use Yii;
/**
* This is the model class for table "{{%video_view}}".
*
* @property int $id
* @property string $video_id
* @property int|null $user_id
* @property int|null $created_at
*
* @property User $user
* @property Video $video
*/
class VideoView extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%video_view}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['video_id'], 'required'],
[['user_id', 'created_at'], 'integer'],
[['video_id'], 'string', 'max' => 16],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
[['video_id'], 'exist', 'skipOnError' => true, 'targetClass' => Video::className(), 'targetAttribute' => ['video_id' => 'video_id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'video_id' => 'Video ID',
'user_id' => 'User ID',
'created_at' => 'Created At',
];
}
/**
* Gets query for [[User]].
*
* @return \yii\db\ActiveQuery|\common\models\query\UserQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
/**
* Gets query for [[Video]].
*
* @return \yii\db\ActiveQuery|\common\models\query\VideoQuery
*/
public function getVideo()
{
return $this->hasOne(Video::className(), ['video_id' => 'video_id']);
}
/**
* {@inheritdoc}
* @return \common\models\query\VideoViewQuery the active query used by this AR class.
*/
public static function find()
{
return new \common\models\query\VideoViewQuery(get_called_class());
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/query/VideoLikeQuery.php | common/models/query/VideoLikeQuery.php | <?php
namespace common\models\query;
use common\models\VideoLike;
/**
* This is the ActiveQuery class for [[\common\models\VideoLike]].
*
* @see \common\models\VideoLike
*/
class VideoLikeQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
return $this->andWhere('[[status]]=1');
}*/
/**
* {@inheritdoc}
* @return \common\models\VideoLike[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* {@inheritdoc}
* @return \common\models\VideoLike|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
public function userIdVideoId($userId, $videoId)
{
return $this->andWhere([
'video_id' => $videoId,
'user_id' => $userId
]);
}
public function liked()
{
return $this->andWhere(['type' => VideoLike::TYPE_LIKE]);
}
public function disliked()
{
return $this->andWhere(['type' => VideoLike::TYPE_DISLIKE]);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/query/CommentQuery.php | common/models/query/CommentQuery.php | <?php
namespace common\models\query;
use common\models\Comment;
use common\models\Video;
/**
* This is the ActiveQuery class for [[\common\models\Comment]].
*
* @see \common\models\Comment
*/
class CommentQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
return $this->andWhere('[[status]]=1');
}*/
/**
* {@inheritdoc}
* @return \common\models\Comment[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* {@inheritdoc}
* @return \common\models\Comment|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
public function videoId($videoId)
{
return $this->andWhere(['video_id' => $videoId]);
}
public function parent()
{
return $this->andWhere(['parent_id' => null]);
}
public function latest()
{
return $this->orderBy("pinned DESC, created_at DESC");
}
public function byChannel($userId)
{
return $this->innerJoin(Video::tableName() . ' v', 'v.video_id = ' . Comment::tableName() . '.video_id')
->andWhere(['v.created_by' => $userId]);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/query/VideoQuery.php | common/models/query/VideoQuery.php | <?php
namespace common\models\query;
use common\models\Video;
/**
* This is the ActiveQuery class for [[\common\models\Video]].
*
* @see \common\models\Video
*/
class VideoQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
return $this->andWhere('[[status]]=1');
}*/
/**
* {@inheritdoc}
* @return \common\models\Video[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* {@inheritdoc}
* @return \common\models\Video|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
public function creator($userId)
{
return $this->andWhere(['created_by' => $userId]);
}
public function latest()
{
return $this->orderBy(['created_at' => SORT_DESC]);
}
public function published()
{
return $this->andWhere(['status' => Video::STATUS_PUBLISHED]);
}
public function byKeyword($keyword)
{
return $this->andWhere("MATCH(title, description, tags)
AGAINST (:keyword)", ['keyword' => $keyword]);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/query/SubscriberQuery.php | common/models/query/SubscriberQuery.php | <?php
namespace common\models\query;
/**
* This is the ActiveQuery class for [[\common\models\Subscriber]].
*
* @see \common\models\Subscriber
*/
class SubscriberQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
return $this->andWhere('[[status]]=1');
}*/
/**
* {@inheritdoc}
* @return \common\models\Subscriber[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* {@inheritdoc}
* @return \common\models\Subscriber|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/models/query/VideoViewQuery.php | common/models/query/VideoViewQuery.php | <?php
namespace common\models\query;
/**
* This is the ActiveQuery class for [[\common\models\VideoView]].
*
* @see \common\models\VideoView
*/
class VideoViewQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
return $this->andWhere('[[status]]=1');
}*/
/**
* {@inheritdoc}
* @return \common\models\VideoView[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* {@inheritdoc}
* @return \common\models\VideoView|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/widgets/Alert.php | common/widgets/Alert.php | <?php
namespace common\widgets;
use Yii;
/**
* Alert widget renders a message from session flash. All flash messages are displayed
* in the sequence they were assigned using setFlash. You can set message as following:
*
* ```php
* Yii::$app->session->setFlash('error', 'This is the message');
* Yii::$app->session->setFlash('success', 'This is the message');
* Yii::$app->session->setFlash('info', 'This is the message');
* ```
*
* Multiple messages could be set as follows:
*
* ```php
* Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']);
* ```
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @author Alexander Makarov <sam@rmcreative.ru>
*/
class Alert extends \yii\bootstrap4\Widget
{
/**
* @var array the alert types configuration for the flash messages.
* This array is setup as $key => $value, where:
* - key: the name of the session flash variable
* - value: the bootstrap alert type (i.e. danger, success, info, warning)
*/
public $alertTypes = [
'error' => 'alert-danger',
'danger' => 'alert-danger',
'success' => 'alert-success',
'info' => 'alert-info',
'warning' => 'alert-warning'
];
/**
* @var array the options for rendering the close button tag.
* Array will be passed to [[\yii\bootstrap\Alert::closeButton]].
*/
public $closeButton = [];
/**
* {@inheritdoc}
*/
public function run()
{
$session = Yii::$app->session;
$flashes = $session->getAllFlashes();
$appendClass = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
foreach ($flashes as $type => $flash) {
if (!isset($this->alertTypes[$type])) {
continue;
}
foreach ((array) $flash as $i => $message) {
echo \yii\bootstrap4\Alert::widget([
'body' => $message,
'closeButton' => $this->closeButton,
'options' => array_merge($this->options, [
'id' => $this->getId() . '-' . $type . '-' . $i,
'class' => $this->alertTypes[$type] . $appendClass,
]),
]);
}
$session->removeFlash($type);
}
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/config/main.php | common/config/main.php | <?php
return [
'name' => 'FreeCodeTube',
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/config/params.php | common/config/params.php | <?php
return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'senderEmail' => 'noreply@example.com',
'senderName' => 'Example.com mailer',
'user.passwordResetTokenExpire' => 3600,
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/config/test.php | common/config/test.php | <?php
return [
'id' => 'app-common-tests',
'basePath' => dirname(__DIR__),
'components' => [
'user' => [
'class' => 'yii\web\User',
'identityClass' => 'common\models\User',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/common/config/bootstrap.php | common/config/bootstrap.php | <?php
Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/_bootstrap.php | frontend/tests/_bootstrap.php | <?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../');
require_once YII_APP_BASE_PATH . '/vendor/autoload.php';
require_once YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php';
require_once YII_APP_BASE_PATH . '/common/config/bootstrap.php';
require_once __DIR__ . '/../config/bootstrap.php';
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/_data/user.php | frontend/tests/_data/user.php | <?php
return [
[
'username' => 'okirlin',
'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv',
'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi',
'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(),
'created_at' => '1391885313',
'updated_at' => '1391885313',
'email' => 'brady.renner@rutherford.com',
],
[
'username' => 'troy.becker',
'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp',
'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2',
'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(),
'created_at' => '1391885313',
'updated_at' => '1391885313',
'email' => 'nicolas.dianna@hotmail.com',
'status' => '0',
],
[
'username' => 'test.test',
'auth_key' => 'O87GkY3_UfmMHYkyezZ7QLfmkKNsllzT',
//Test1234
'password_hash' => '$2y$13$d17z0w/wKC4LFwtzBcmx6up4jErQuandJqhzKGKczfWuiEhLBtQBK',
'email' => 'test@mail.com',
'status' => '9',
'created_at' => '1548675330',
'updated_at' => '1548675330',
'verification_token' => '4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330',
],
[
'username' => 'test2.test',
'auth_key' => '4XXdVqi3rDpa_a6JH6zqVreFxUPcUPvJ',
//Test1234
'password_hash' => '$2y$13$d17z0w/wKC4LFwtzBcmx6up4jErQuandJqhzKGKczfWuiEhLBtQBK',
'email' => 'test2@mail.com',
'status' => '10',
'created_at' => '1548675330',
'updated_at' => '1548675330',
'verification_token' => 'already_used_token_1548675330',
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/_data/login_data.php | frontend/tests/_data/login_data.php | <?php
return [
[
'username' => 'erau',
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
// password_0
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
'created_at' => '1392559490',
'updated_at' => '1392559490',
'email' => 'sfriesen@jenkins.info',
],
[
'username' => 'test.test',
'auth_key' => 'O87GkY3_UfmMHYkyezZ7QLfmkKNsllzT',
// Test1234
'password_hash' => 'O87GkY3_UfmMHYkyezZ7QLfmkKNsllzT',
'email' => 'test@mail.com',
'status' => '9',
'created_at' => '1548675330',
'updated_at' => '1548675330',
'verification_token' => '4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330',
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/acceptance/HomeCest.php | frontend/tests/acceptance/HomeCest.php | <?php
namespace frontend\tests\acceptance;
use frontend\tests\AcceptanceTester;
use yii\helpers\Url;
class HomeCest
{
public function checkHome(AcceptanceTester $I)
{
$I->amOnPage(Url::toRoute('/site/index'));
$I->see('My Application');
$I->seeLink('About');
$I->click('About');
$I->wait(2); // wait for page to be opened
$I->see('This is the About page.');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/acceptance/_bootstrap.php | frontend/tests/acceptance/_bootstrap.php | <?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cepts.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Cept
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/ | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/_bootstrap.php | frontend/tests/unit/_bootstrap.php | <?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Tests.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Tests
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/models/ResetPasswordFormTest.php | frontend/tests/unit/models/ResetPasswordFormTest.php | <?php
namespace frontend\tests\unit\models;
use common\fixtures\UserFixture;
use frontend\models\ResetPasswordForm;
class ResetPasswordFormTest extends \Codeception\Test\Unit
{
/**
* @var \frontend\tests\UnitTester
*/
protected $tester;
public function _before()
{
$this->tester->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php'
],
]);
}
public function testResetWrongToken()
{
$this->tester->expectException('\yii\base\InvalidArgumentException', function() {
new ResetPasswordForm('');
});
$this->tester->expectException('\yii\base\InvalidArgumentException', function() {
new ResetPasswordForm('notexistingtoken_1391882543');
});
}
public function testResetCorrectToken()
{
$user = $this->tester->grabFixture('user', 0);
$form = new ResetPasswordForm($user['password_reset_token']);
expect_that($form->resetPassword());
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/models/VerifyEmailFormTest.php | frontend/tests/unit/models/VerifyEmailFormTest.php | <?php
namespace frontend\tests\unit\models;
use common\fixtures\UserFixture;
use frontend\models\VerifyEmailForm;
class VerifyEmailFormTest extends \Codeception\Test\Unit
{
/**
* @var \frontend\tests\UnitTester
*/
protected $tester;
public function _before()
{
$this->tester->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php'
]
]);
}
public function testVerifyWrongToken()
{
$this->tester->expectException('\yii\base\InvalidArgumentException', function() {
new VerifyEmailForm('');
});
$this->tester->expectException('\yii\base\InvalidArgumentException', function() {
new VerifyEmailForm('notexistingtoken_1391882543');
});
}
public function testAlreadyActivatedToken()
{
$this->tester->expectException('\yii\base\InvalidArgumentException', function() {
new VerifyEmailForm('already_used_token_1548675330');
});
}
public function testVerifyCorrectToken()
{
$model = new VerifyEmailForm('4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330');
$user = $model->verifyEmail();
expect($user)->isInstanceOf('common\models\User');
expect($user->username)->equals('test.test');
expect($user->email)->equals('test@mail.com');
expect($user->status)->equals(\common\models\User::STATUS_ACTIVE);
expect($user->validatePassword('Test1234'))->true();
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/models/ResendVerificationEmailFormTest.php | frontend/tests/unit/models/ResendVerificationEmailFormTest.php | <?php
namespace frontend\tests\unit\models;
use Codeception\Test\Unit;
use common\fixtures\UserFixture;
use frontend\models\ResendVerificationEmailForm;
class ResendVerificationEmailFormTest extends Unit
{
/**
* @var \frontend\tests\UnitTester
*/
protected $tester;
public function _before()
{
$this->tester->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php'
]
]);
}
public function testWrongEmailAddress()
{
$model = new ResendVerificationEmailForm();
$model->attributes = [
'email' => 'aaa@bbb.cc'
];
expect($model->validate())->false();
expect($model->hasErrors())->true();
expect($model->getFirstError('email'))->equals('There is no user with this email address.');
}
public function testEmptyEmailAddress()
{
$model = new ResendVerificationEmailForm();
$model->attributes = [
'email' => ''
];
expect($model->validate())->false();
expect($model->hasErrors())->true();
expect($model->getFirstError('email'))->equals('Email cannot be blank.');
}
public function testResendToActiveUser()
{
$model = new ResendVerificationEmailForm();
$model->attributes = [
'email' => 'test2@mail.com'
];
expect($model->validate())->false();
expect($model->hasErrors())->true();
expect($model->getFirstError('email'))->equals('There is no user with this email address.');
}
public function testSuccessfullyResend()
{
$model = new ResendVerificationEmailForm();
$model->attributes = [
'email' => 'test@mail.com'
];
expect($model->validate())->true();
expect($model->hasErrors())->false();
expect($model->sendEmail())->true();
$this->tester->seeEmailIsSent();
$mail = $this->tester->grabLastSentEmail();
expect('valid email is sent', $mail)->isInstanceOf('yii\mail\MessageInterface');
expect($mail->getTo())->hasKey('test@mail.com');
expect($mail->getFrom())->hasKey(\Yii::$app->params['supportEmail']);
expect($mail->getSubject())->equals('Account registration at ' . \Yii::$app->name);
expect($mail->toString())->stringContainsString('4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/models/ContactFormTest.php | frontend/tests/unit/models/ContactFormTest.php | <?php
namespace frontend\tests\unit\models;
use frontend\models\ContactForm;
use yii\mail\MessageInterface;
class ContactFormTest extends \Codeception\Test\Unit
{
public function testSendEmail()
{
$model = new ContactForm();
$model->attributes = [
'name' => 'Tester',
'email' => 'tester@example.com',
'subject' => 'very important letter subject',
'body' => 'body of current message',
];
expect_that($model->sendEmail('admin@example.com'));
// using Yii2 module actions to check email was sent
$this->tester->seeEmailIsSent();
/** @var MessageInterface $emailMessage */
$emailMessage = $this->tester->grabLastSentEmail();
expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface');
expect($emailMessage->getTo())->hasKey('admin@example.com');
expect($emailMessage->getFrom())->hasKey('noreply@example.com');
expect($emailMessage->getReplyTo())->hasKey('tester@example.com');
expect($emailMessage->getSubject())->equals('very important letter subject');
expect($emailMessage->toString())->stringContainsString('body of current message');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/models/PasswordResetRequestFormTest.php | frontend/tests/unit/models/PasswordResetRequestFormTest.php | <?php
namespace frontend\tests\unit\models;
use Yii;
use frontend\models\PasswordResetRequestForm;
use common\fixtures\UserFixture as UserFixture;
use common\models\User;
class PasswordResetRequestFormTest extends \Codeception\Test\Unit
{
/**
* @var \frontend\tests\UnitTester
*/
protected $tester;
public function _before()
{
$this->tester->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php'
]
]);
}
public function testSendMessageWithWrongEmailAddress()
{
$model = new PasswordResetRequestForm();
$model->email = 'not-existing-email@example.com';
expect_not($model->sendEmail());
}
public function testNotSendEmailsToInactiveUser()
{
$user = $this->tester->grabFixture('user', 1);
$model = new PasswordResetRequestForm();
$model->email = $user['email'];
expect_not($model->sendEmail());
}
public function testSendEmailSuccessfully()
{
$userFixture = $this->tester->grabFixture('user', 0);
$model = new PasswordResetRequestForm();
$model->email = $userFixture['email'];
$user = User::findOne(['password_reset_token' => $userFixture['password_reset_token']]);
expect_that($model->sendEmail());
expect_that($user->password_reset_token);
$emailMessage = $this->tester->grabLastSentEmail();
expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface');
expect($emailMessage->getTo())->hasKey($model->email);
expect($emailMessage->getFrom())->hasKey(Yii::$app->params['supportEmail']);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/unit/models/SignupFormTest.php | frontend/tests/unit/models/SignupFormTest.php | <?php
namespace frontend\tests\unit\models;
use common\fixtures\UserFixture;
use frontend\models\SignupForm;
class SignupFormTest extends \Codeception\Test\Unit
{
/**
* @var \frontend\tests\UnitTester
*/
protected $tester;
public function _before()
{
$this->tester->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php'
]
]);
}
public function testCorrectSignup()
{
$model = new SignupForm([
'username' => 'some_username',
'email' => 'some_email@example.com',
'password' => 'some_password',
]);
$user = $model->signup();
expect($user)->true();
/** @var \common\models\User $user */
$user = $this->tester->grabRecord('common\models\User', [
'username' => 'some_username',
'email' => 'some_email@example.com',
'status' => \common\models\User::STATUS_INACTIVE
]);
$this->tester->seeEmailIsSent();
$mail = $this->tester->grabLastSentEmail();
expect($mail)->isInstanceOf('yii\mail\MessageInterface');
expect($mail->getTo())->hasKey('some_email@example.com');
expect($mail->getFrom())->hasKey(\Yii::$app->params['supportEmail']);
expect($mail->getSubject())->equals('Account registration at ' . \Yii::$app->name);
expect($mail->toString())->stringContainsString($user->verification_token);
}
public function testNotCorrectSignup()
{
$model = new SignupForm([
'username' => 'troy.becker',
'email' => 'nicolas.dianna@hotmail.com',
'password' => 'some_password',
]);
expect_not($model->signup());
expect_that($model->getErrors('username'));
expect_that($model->getErrors('email'));
expect($model->getFirstError('username'))
->equals('This username has already been taken.');
expect($model->getFirstError('email'))
->equals('This email address has already been taken.');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/_support/UnitTester.php | frontend/tests/_support/UnitTester.php | <?php
namespace frontend\tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/_support/FunctionalTester.php | frontend/tests/_support/FunctionalTester.php | <?php
namespace frontend\tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
public function seeValidationError($message)
{
$this->see($message, '.help-block');
}
public function dontSeeValidationError($message)
{
$this->dontSee($message, '.help-block');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/HomeCest.php | frontend/tests/functional/HomeCest.php | <?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
class HomeCest
{
public function checkOpen(FunctionalTester $I)
{
$I->amOnPage(\Yii::$app->homeUrl);
$I->see('My Application');
$I->seeLink('About');
$I->click('About');
$I->see('This is the About page.');
}
} | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/SignupCest.php | frontend/tests/functional/SignupCest.php | <?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
class SignupCest
{
protected $formId = '#form-signup';
public function _before(FunctionalTester $I)
{
$I->amOnRoute('site/signup');
}
public function signupWithEmptyFields(FunctionalTester $I)
{
$I->see('Signup', 'h1');
$I->see('Please fill out the following fields to signup:');
$I->submitForm($this->formId, []);
$I->seeValidationError('Username cannot be blank.');
$I->seeValidationError('Email cannot be blank.');
$I->seeValidationError('Password cannot be blank.');
}
public function signupWithWrongEmail(FunctionalTester $I)
{
$I->submitForm(
$this->formId, [
'SignupForm[username]' => 'tester',
'SignupForm[email]' => 'ttttt',
'SignupForm[password]' => 'tester_password',
]
);
$I->dontSee('Username cannot be blank.', '.help-block');
$I->dontSee('Password cannot be blank.', '.help-block');
$I->see('Email is not a valid email address.', '.help-block');
}
public function signupSuccessfully(FunctionalTester $I)
{
$I->submitForm($this->formId, [
'SignupForm[username]' => 'tester',
'SignupForm[email]' => 'tester.email@example.com',
'SignupForm[password]' => 'tester_password',
]);
$I->seeRecord('common\models\User', [
'username' => 'tester',
'email' => 'tester.email@example.com',
'status' => \common\models\User::STATUS_INACTIVE
]);
$I->seeEmailIsSent();
$I->see('Thank you for registration. Please check your inbox for verification email.');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/ContactCest.php | frontend/tests/functional/ContactCest.php | <?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
/* @var $scenario \Codeception\Scenario */
class ContactCest
{
public function _before(FunctionalTester $I)
{
$I->amOnPage(['site/contact']);
}
public function checkContact(FunctionalTester $I)
{
$I->see('Contact', 'h1');
}
public function checkContactSubmitNoData(FunctionalTester $I)
{
$I->submitForm('#contact-form', []);
$I->see('Contact', 'h1');
$I->seeValidationError('Name cannot be blank');
$I->seeValidationError('Email cannot be blank');
$I->seeValidationError('Subject cannot be blank');
$I->seeValidationError('Body cannot be blank');
$I->seeValidationError('The verification code is incorrect');
}
public function checkContactSubmitNotCorrectEmail(FunctionalTester $I)
{
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester.email',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
]);
$I->seeValidationError('Email is not a valid email address.');
$I->dontSeeValidationError('Name cannot be blank');
$I->dontSeeValidationError('Subject cannot be blank');
$I->dontSeeValidationError('Body cannot be blank');
$I->dontSeeValidationError('The verification code is incorrect');
}
public function checkContactSubmitCorrectData(FunctionalTester $I)
{
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester@example.com',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
]);
$I->seeEmailIsSent();
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/LoginCest.php | frontend/tests/functional/LoginCest.php | <?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
use common\fixtures\UserFixture;
class LoginCest
{
/**
* Load fixtures before db transaction begin
* Called in _before()
* @see \Codeception\Module\Yii2::_before()
* @see \Codeception\Module\Yii2::loadFixtures()
* @return array
*/
public function _fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'login_data.php',
],
];
}
public function _before(FunctionalTester $I)
{
$I->amOnRoute('site/login');
}
protected function formParams($login, $password)
{
return [
'LoginForm[username]' => $login,
'LoginForm[password]' => $password,
];
}
public function checkEmpty(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('', ''));
$I->seeValidationError('Username cannot be blank.');
$I->seeValidationError('Password cannot be blank.');
}
public function checkWrongPassword(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('admin', 'wrong'));
$I->seeValidationError('Incorrect username or password.');
}
public function checkInactiveAccount(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('test.test', 'Test1234'));
$I->seeValidationError('Incorrect username or password');
}
public function checkValidLogin(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('erau', 'password_0'));
$I->see('Logout (erau)', 'form button[type=submit]');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/_bootstrap.php | frontend/tests/functional/_bootstrap.php | <?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cests.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Cests
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/ | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/AboutCest.php | frontend/tests/functional/AboutCest.php | <?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
class AboutCest
{
public function checkAbout(FunctionalTester $I)
{
$I->amOnRoute('site/about');
$I->see('About', 'h1');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/VerifyEmailCest.php | frontend/tests/functional/VerifyEmailCest.php | <?php
namespace frontend\tests\functional;
use common\fixtures\UserFixture;
use frontend\tests\FunctionalTester;
class VerifyEmailCest
{
/**
* Load fixtures before db transaction begin
* Called in _before()
* @see \Codeception\Module\Yii2::_before()
* @see \Codeception\Module\Yii2::loadFixtures()
* @return array
*/
public function _fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php',
],
];
}
public function checkEmptyToken(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => '']);
$I->canSee('Bad Request', 'h1');
$I->canSee('Verify email token cannot be blank.');
}
public function checkInvalidToken(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => 'wrong_token']);
$I->canSee('Bad Request', 'h1');
$I->canSee('Wrong verify email token.');
}
public function checkNoToken(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email');
$I->canSee('Bad Request', 'h1');
$I->canSee('Missing required parameters: token');
}
public function checkAlreadyActivatedToken(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => 'already_used_token_1548675330']);
$I->canSee('Bad Request', 'h1');
$I->canSee('Wrong verify email token.');
}
public function checkSuccessVerification(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => '4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330']);
$I->canSee('Your email has been confirmed!');
$I->canSee('Congratulations!', 'h1');
$I->see('Logout (test.test)', 'form button[type=submit]');
$I->seeRecord('common\models\User', [
'username' => 'test.test',
'email' => 'test@mail.com',
'status' => \common\models\User::STATUS_ACTIVE
]);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/tests/functional/ResendVerificationEmailCest.php | frontend/tests/functional/ResendVerificationEmailCest.php | <?php
namespace frontend\tests\functional;
use common\fixtures\UserFixture;
use frontend\tests\FunctionalTester;
class ResendVerificationEmailCest
{
protected $formId = '#resend-verification-email-form';
/**
* Load fixtures before db transaction begin
* Called in _before()
* @see \Codeception\Module\Yii2::_before()
* @see \Codeception\Module\Yii2::loadFixtures()
* @return array
*/
public function _fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'user.php',
],
];
}
public function _before(FunctionalTester $I)
{
$I->amOnRoute('/site/resend-verification-email');
}
protected function formParams($email)
{
return [
'ResendVerificationEmailForm[email]' => $email
];
}
public function checkPage(FunctionalTester $I)
{
$I->see('Resend verification email', 'h1');
$I->see('Please fill out your email. A verification email will be sent there.');
}
public function checkEmptyField(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams(''));
$I->seeValidationError('Email cannot be blank.');
}
public function checkWrongEmailFormat(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('abcd.com'));
$I->seeValidationError('Email is not a valid email address.');
}
public function checkWrongEmail(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('wrong@email.com'));
$I->seeValidationError('There is no user with this email address.');
}
public function checkAlreadyVerifiedEmail(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('test2@mail.com'));
$I->seeValidationError('There is no user with this email address.');
}
public function checkSendSuccessfully(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('test@mail.com'));
$I->canSeeEmailIsSent();
$I->seeRecord('common\models\User', [
'email' => 'test@mail.com',
'username' => 'test.test',
'status' => \common\models\User::STATUS_INACTIVE
]);
$I->see('Check your email for further instructions.');
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/controllers/CommentController.php | frontend/controllers/CommentController.php | <?php
/**
* User: TheCodeholic
* Date: 11/12/2020
* Time: 8:58 AM
*/
namespace frontend\controllers;
use common\models\Comment;
use common\models\User;
use yii\filters\AccessControl;
use yii\filters\ContentNegotiator;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\ForbiddenHttpException;
use yii\web\NotFoundHttpException;
use yii\web\Response;
/**
* Class CommentController
*
* @author Zura Sekhniashvili <zurasekhniashvili@gmail.com>
* @package frontend\controllers
*/
class CommentController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
'only' => ['create'],
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
'content' => [
'class' => ContentNegotiator::class,
'only' => ['create', 'update', 'delete', 'reply', 'by-parent', 'pin'],
'formats' => [
'application/json' => Response::FORMAT_JSON
]
],
'verb' => [
'class' => VerbFilter::class,
'actions' => [
'delete' => ['POST']
]
]
];
}
public function actionCreate($id)
{
$comment = new Comment();
$comment->video_id = $id;
if ($comment->load(\Yii::$app->request->post(), '') && $comment->save()) {
return [
'success' => true,
'comment' => $this->renderPartial('@frontend/views/video/_comment_item', [
'model' => $comment,
])
];
}
return [
'success' => false,
'errors' => $comment->errors
];
}
public function actionDelete($id)
{
$comment = $this->findModel($id);
if ($comment->belongsTo(\Yii::$app->user->id) || $comment->video->belongsTo(\Yii::$app->user->id)) {
$comment->delete();
return ['success' => true];
}
throw new ForbiddenHttpException();
}
public function actionUpdate($id)
{
$comment = $this->findModel($id);
if ($comment->belongsTo(\Yii::$app->user->id)) {
$commentText = \Yii::$app->request->post('comment');
$comment->comment = $commentText;
if ($comment->save()) {
return [
'success' => true,
'comment' => $this->renderPartial('@frontend/views/video/_comment_item', [
'model' => $comment,
])
];
}
return [
'success' => false,
'errors' => $comment->errors
];
}
throw new ForbiddenHttpException();
}
public function actionReply()
{
$parentId = \Yii::$app->request->post('parent_id');
$parentComment = $this->findModel($parentId);
$commentText = \Yii::$app->request->post('comment');
$mentionUsername = \Yii::$app->request->post('mention');
if (strpos($commentText, '@' . $mentionUsername) !== 0) {
$mentionUsername = null;
} else {
$commentText = trim(str_replace('@' . $mentionUsername, '', $commentText));
}
if ($mentionUsername) {
$mentionUser = User::findByUsername($mentionUsername);
if (!$mentionUser) {
$mentionUsername = null;
} else {
$currentUser = \Yii::$app->user->identity;
\Yii::$app->mailer->compose([
'html' => 'mention-html', 'text' => 'mention-text'
], [
'comment' => $commentText,
'channel' => $mentionUser,
'user' => $currentUser
])
->setFrom(\Yii::$app->params['senderEmail'])
->setTo($mentionUser->email)
->setSubject('User '.$currentUser->username.' mention you in a comment')
->send();
}
}
$comment = new Comment();
$comment->comment = $commentText;
$comment->mention = $mentionUsername;
$comment->video_id = $parentComment->video_id;
if ($parentComment->parent_id) {
$comment->parent_id = $parentComment->parent_id;
} else {
$comment->parent_id = $parentId;
}
if ($comment->save()) {
return [
'success' => true,
'comment' => $this->renderPartial('@frontend/views/video/_comment_item', [
'model' => $comment,
])
];
}
return [
'success' => false,
'errors' => $comment->errors
];
}
public function actionByParent($id)
{
$parentComment = $this->findModel($id);
$finalContent = "";
foreach ($parentComment->comments as $comment) {
$finalContent .= $this->renderPartial('@frontend/views/video/_comment_item', [
'model' => $comment,
]);
}
return [
'success' => true,
'comments' => $finalContent
];
}
public function actionPin($id)
{
$comment = $this->findModel($id);
if ($comment->video->belongsTo(\Yii::$app->user->id)) {
if ($comment->pinned) {
$comment->pinned = 0;
} else {
Comment::updateAll(['pinned' => 0], ['video_id' => $comment->video]);
$comment->pinned = 1;
}
if ($comment->save()) {
return [
'success' => true,
'comment' => $this->renderPartial('@frontend/views/video/_comment_item', [
'model' => $comment,
])
];
}
return [
'success' => false,
'errors' => $comment->errors
];
}
throw new ForbiddenHttpException();
}
protected function findModel($id)
{
$comment = Comment::findOne($id);
if (!$comment) {
throw new NotFoundHttpException;
}
return $comment;
}
} | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/controllers/VideoController.php | frontend/controllers/VideoController.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 11:56 AM
*/
namespace frontend\controllers;
use common\models\Comment;
use common\models\Video;
use common\models\VideoLike;
use common\models\VideoView;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
/**
* Class VideoController
*
* @author Zura Sekhniashvili <zurasekhniashvili@gmail.com>
* @package frontend\controllers
*/
class VideoController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
'only' => ['like', 'dislike', 'history'],
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
'verb' => [
'class' => VerbFilter::class,
'actions' => [
'like' => ['post'],
'dislike' => ['post'],
]
]
];
}
public function actionIndex()
{
$this->layout = 'main';
$dataProvider = new ActiveDataProvider([
'query' => Video::find()->with('createdBy')->published()->latest(),
]);
return $this->render('index', [
'dataProvider' => $dataProvider
]);
}
public function actionView($id)
{
$this->layout = 'auth';
$video = $this->findVideo($id);
$videoView = new VideoView();
$videoView->video_id = $id;
$videoView->user_id = \Yii::$app->user->id;
$videoView->created_at = time();
$videoView->save();
$similarVideos = Video::find()
->published()
->byKeyword($video->title)
->andWhere(['NOT', ['video_id' => $id]])
->limit(10)
->all();
$comments = $video
->getComments()
->with(['createdBy'])
->parent()
->latest()
->all();
return $this->render('view', [
'model' => $video,
'comments' => $comments,
'similarVideos' => $similarVideos
]);
}
public function actionLike($id)
{
$video = $this->findVideo($id);
$userId = \Yii::$app->user->id;
$videoLikeDislike = VideoLike::find()
->userIdVideoId($userId, $id)
->one();
if (!$videoLikeDislike) {
$this->saveLikeDislike($id, $userId, VideoLike::TYPE_LIKE);
} else if ($videoLikeDislike->type == VideoLike::TYPE_LIKE) {
$videoLikeDislike->delete();
} else {
$videoLikeDislike->delete();
$this->saveLikeDislike($id, $userId, VideoLike::TYPE_LIKE);
}
return $this->renderAjax('_buttons', [
'model' => $video
]);
}
public function actionDislike($id)
{
$video = $this->findVideo($id);
$userId = \Yii::$app->user->id;
$videoLikeDislike = VideoLike::find()
->userIdVideoId($userId, $id)
->one();
if (!$videoLikeDislike) {
$this->saveLikeDislike($id, $userId, VideoLike::TYPE_DISLIKE);
} else if ($videoLikeDislike->type == VideoLike::TYPE_DISLIKE) {
$videoLikeDislike->delete();
} else {
$videoLikeDislike->delete();
$this->saveLikeDislike($id, $userId, VideoLike::TYPE_DISLIKE);
}
return $this->renderAjax('_buttons', [
'model' => $video
]);
}
public function actionSearch($keyword)
{
$this->layout = 'main';
$query = Video::find()
->with('createdBy')
->published()
->latest();
if ($keyword) {
$query->byKeyword($keyword);
}
$dataProvider = new ActiveDataProvider([
'query' => $query
]);
return $this->render('search', [
'dataProvider' => $dataProvider
]);
}
public function actionHistory()
{
$this->layout = 'main';
$query = Video::find()
->alias('v')
->innerJoin("(SELECT video_id, MAX(created_at) as max_date FROM video_view
WHERE user_id = :userId
GROUP BY video_id) vv", 'vv.video_id = v.video_id', [
'userId' => \Yii::$app->user->id
])
->orderBy("vv.max_date DESC");
$dataProvider = new ActiveDataProvider([
'query' => $query
]);
return $this->render('history', [
'dataProvider' => $dataProvider
]);
}
protected function findVideo($id)
{
$video = Video::findOne($id);
if (!$video) {
throw new NotFoundHttpException("Video does not exit");
}
return $video;
}
protected function saveLikeDislike($videoId, $userId, $type)
{
$videoLikeDislike = new VideoLike();
$videoLikeDislike->video_id = $videoId;
$videoLikeDislike->user_id = $userId;
$videoLikeDislike->type = $type;
$videoLikeDislike->created_at = time();
$videoLikeDislike->save();
}
} | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/controllers/ChannelController.php | frontend/controllers/ChannelController.php | <?php
/**
* User: TheCodeholic
* Date: 4/18/2020
* Time: 9:48 AM
*/
namespace frontend\controllers;
use common\models\Subscriber;
use common\models\User;
use common\models\Video;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
/**
* Class ChannelController
*
* @author Zura Sekhniashvili <zurasekhniashvili@gmail.com>
* @package frontend\controllers
*/
class ChannelController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
'only' => ['subscribe'],
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
]
],
];
}
public function actionView($username)
{
$channel = $this->findChannel($username);
$dataProvider = new ActiveDataProvider([
'query' => Video::find()->creator($channel->id)->published()
]);
return $this->render('view', [
'channel' => $channel,
'dataProvider' => $dataProvider
]);
}
public function actionSubscribe($username)
{
$channel = $this->findChannel($username);
$userId = \Yii::$app->user->id;
$subscriber = $channel->isSubscribed($userId);
if (!$subscriber) {
$subscriber = new Subscriber();
$subscriber->channel_id = $channel->id;
$subscriber->user_id = $userId;
$subscriber->created_at = time();
$subscriber->save();
\Yii::$app->mailer->compose([
'html' => 'subscriber-html', 'text' => 'subscriber-text'
], [
'channel' => $channel,
'user' => \Yii::$app->user->identity
])
->setFrom(\Yii::$app->params['senderEmail'])
->setTo($channel->email)
->setSubject('You have new subscriber')
->send();
} else {
$subscriber->delete();
}
return $this->renderAjax('_subscribe', [
'channel' => $channel
]);
}
/**
* @param $username
* @return \common\models\User|null
* @throws \yii\web\NotFoundHttpException
* @author Zura Sekhniashvili <zurasekhniashvili@gmail.com>
*/
protected function findChannel($username)
{
$channel = User::findByUsername($username);
if (!$channel) {
throw new NotFoundHttpException("Channel does not exist");
}
return $channel;
}
} | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/controllers/SiteController.php | frontend/controllers/SiteController.php | <?php
namespace frontend\controllers;
use frontend\models\ResendVerificationEmailForm;
use frontend\models\VerifyEmailForm;
use Yii;
use yii\base\InvalidArgumentException;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
use frontend\models\ContactForm;
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup'],
'rules' => [
[
'actions' => ['signup'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return mixed
*/
public function actionIndex()
{
return $this->render('index');
}
/**
* Logs in a user.
*
* @return mixed
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
}
/**
* Logs out the current user.
*
* @return mixed
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
/**
* Signs user up.
*
* @return mixed
*/
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post()) && $model->signup()) {
Yii::$app->session->setFlash('success', 'Thank you for registration. Please check your inbox for verification email.');
return $this->goHome();
}
return $this->render('signup', [
'model' => $model,
]);
}
/**
* Requests password reset.
*
* @return mixed
*/
public function actionRequestPasswordReset()
{
$model = new PasswordResetRequestForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail()) {
Yii::$app->session->setFlash('success', 'Check your email for further instructions.');
return $this->goHome();
} else {
Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for the provided email address.');
}
}
return $this->render('requestPasswordResetToken', [
'model' => $model,
]);
}
/**
* Resets password.
*
* @param string $token
* @return mixed
* @throws BadRequestHttpException
*/
public function actionResetPassword($token)
{
try {
$model = new ResetPasswordForm($token);
} catch (InvalidArgumentException $e) {
throw new BadRequestHttpException($e->getMessage());
}
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
Yii::$app->session->setFlash('success', 'New password saved.');
return $this->goHome();
}
return $this->render('resetPassword', [
'model' => $model,
]);
}
/**
* Verify email address
*
* @param string $token
* @throws BadRequestHttpException
* @return yii\web\Response
*/
public function actionVerifyEmail($token)
{
try {
$model = new VerifyEmailForm($token);
} catch (InvalidArgumentException $e) {
throw new BadRequestHttpException($e->getMessage());
}
if ($user = $model->verifyEmail()) {
if (Yii::$app->user->login($user)) {
Yii::$app->session->setFlash('success', 'Your email has been confirmed!');
return $this->goHome();
}
}
Yii::$app->session->setFlash('error', 'Sorry, we are unable to verify your account with provided token.');
return $this->goHome();
}
/**
* Resend verification email
*
* @return mixed
*/
public function actionResendVerificationEmail()
{
$model = new ResendVerificationEmailForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail()) {
Yii::$app->session->setFlash('success', 'Check your email for further instructions.');
return $this->goHome();
}
Yii::$app->session->setFlash('error', 'Sorry, we are unable to resend verification email for the provided email address.');
}
return $this->render('resendVerificationEmail', [
'model' => $model
]);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/models/ResetPasswordForm.php | frontend/models/ResetPasswordForm.php | <?php
namespace frontend\models;
use yii\base\InvalidArgumentException;
use yii\base\Model;
use common\models\User;
/**
* Password reset form
*/
class ResetPasswordForm extends Model
{
public $password;
/**
* @var \common\models\User
*/
private $_user;
/**
* Creates a form model given a token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws InvalidArgumentException if token is empty or not valid
*/
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidArgumentException('Password reset token cannot be blank.');
}
$this->_user = User::findByPasswordResetToken($token);
if (!$this->_user) {
throw new InvalidArgumentException('Wrong password reset token.');
}
parent::__construct($config);
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['password', 'required'],
['password', 'string', 'min' => 6],
];
}
/**
* Resets password.
*
* @return bool if password was reset.
*/
public function resetPassword()
{
$user = $this->_user;
$user->setPassword($this->password);
$user->removePasswordResetToken();
return $user->save(false);
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/models/PasswordResetRequestForm.php | frontend/models/PasswordResetRequestForm.php | <?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use common\models\User;
/**
* Password reset request form
*/
class PasswordResetRequestForm extends Model
{
public $email;
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['email', 'trim'],
['email', 'required'],
['email', 'email'],
['email', 'exist',
'targetClass' => '\common\models\User',
'filter' => ['status' => User::STATUS_ACTIVE],
'message' => 'There is no user with this email address.'
],
];
}
/**
* Sends an email with a link, for resetting the password.
*
* @return bool whether the email was send
*/
public function sendEmail()
{
/* @var $user User */
$user = User::findOne([
'status' => User::STATUS_ACTIVE,
'email' => $this->email,
]);
if (!$user) {
return false;
}
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
if (!$user->save()) {
return false;
}
}
return Yii::$app
->mailer
->compose(
['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'],
['user' => $user]
)
->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
->setTo($this->email)
->setSubject('Password reset for ' . Yii::$app->name)
->send();
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/models/ResendVerificationEmailForm.php | frontend/models/ResendVerificationEmailForm.php | <?php
namespace frontend\models;
use Yii;
use common\models\User;
use yii\base\Model;
class ResendVerificationEmailForm extends Model
{
/**
* @var string
*/
public $email;
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['email', 'trim'],
['email', 'required'],
['email', 'email'],
['email', 'exist',
'targetClass' => '\common\models\User',
'filter' => ['status' => User::STATUS_INACTIVE],
'message' => 'There is no user with this email address.'
],
];
}
/**
* Sends confirmation email to user
*
* @return bool whether the email was sent
*/
public function sendEmail()
{
$user = User::findOne([
'email' => $this->email,
'status' => User::STATUS_INACTIVE
]);
if ($user === null) {
return false;
}
return Yii::$app
->mailer
->compose(
['html' => 'emailVerify-html', 'text' => 'emailVerify-text'],
['user' => $user]
)
->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
->setTo($this->email)
->setSubject('Account registration at ' . Yii::$app->name)
->send();
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/models/VerifyEmailForm.php | frontend/models/VerifyEmailForm.php | <?php
namespace frontend\models;
use common\models\User;
use yii\base\InvalidArgumentException;
use yii\base\Model;
class VerifyEmailForm extends Model
{
/**
* @var string
*/
public $token;
/**
* @var User
*/
private $_user;
/**
* Creates a form model with given token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws InvalidArgumentException if token is empty or not valid
*/
public function __construct($token, array $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidArgumentException('Verify email token cannot be blank.');
}
$this->_user = User::findByVerificationToken($token);
if (!$this->_user) {
throw new InvalidArgumentException('Wrong verify email token.');
}
parent::__construct($config);
}
/**
* Verify email
*
* @return User|null the saved model or null if saving fails
*/
public function verifyEmail()
{
$user = $this->_user;
$user->status = User::STATUS_ACTIVE;
return $user->save(false) ? $user : null;
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/models/SignupForm.php | frontend/models/SignupForm.php | <?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use common\models\User;
/**
* Signup form
*/
class SignupForm extends Model
{
public $username;
public $email;
public $password;
/**
* {@inheritdoc}
*/
public function rules()
{
return [
['username', 'trim'],
['username', 'required'],
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'],
['username', 'string', 'min' => 2, 'max' => 255],
['email', 'trim'],
['email', 'required'],
['email', 'email'],
['email', 'string', 'max' => 255],
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],
['password', 'required'],
['password', 'string', 'min' => 6],
];
}
/**
* Signs user up.
*
* @return bool whether the creating new account was successful and email was sent
*/
public function signup()
{
if (!$this->validate()) {
return null;
}
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->generateEmailVerificationToken();
return $user->save() && $this->sendEmail($user);
}
/**
* Sends confirmation email to user
* @param User $user user model to with email should be send
* @return bool whether the email was sent
*/
protected function sendEmail($user)
{
return Yii::$app
->mailer
->compose(
['html' => 'emailVerify-html', 'text' => 'emailVerify-text'],
['user' => $user]
)
->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
->setTo($this->email)
->setSubject('Account registration at ' . Yii::$app->name)
->send();
}
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/resendVerificationEmail.php | frontend/views/site/resendVerificationEmail.php | <?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap4\ActiveForm */
/* @var $model \frontend\models\ResetPasswordForm */
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
$this->title = 'Resend verification email';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-resend-verification-email">
<h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out your email. A verification email will be sent there.</p>
<div class="row">
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'resend-verification-email-form']); ?>
<?= $form->field($model, 'email')->textInput(['autofocus' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Send', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/requestPasswordResetToken.php | frontend/views/site/requestPasswordResetToken.php | <?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap4\ActiveForm */
/* @var $model \frontend\models\PasswordResetRequestForm */
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
$this->title = 'Request password reset';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-request-password-reset">
<h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out your email. A link to reset password will be sent there.</p>
<div class="row">
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'request-password-reset-form']); ?>
<?= $form->field($model, 'email')->textInput(['autofocus' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Send', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/signup.php | frontend/views/site/signup.php | <?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap4\ActiveForm */
/* @var $model \frontend\models\SignupForm */
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
$this->title = 'Signup';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-signup">
<h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out the following fields to signup:</p>
<div class="row">
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'form-signup']); ?>
<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<div class="form-group">
<?= Html::submitButton('Signup', ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/login.php | frontend/views/site/login.php | <?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap4\ActiveForm */
/* @var $model \common\models\LoginForm */
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
$this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-login">
<h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out the following fields to login:</p>
<div class="row">
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>
<div style="color:#999;margin:1em 0">
If you forgot your password you can <?= Html::a('reset it', ['site/request-password-reset']) ?>.
<br>
Need new verification email? <?= Html::a('Resend', ['site/resend-verification-email']) ?>
</div>
<div class="form-group">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/index.php | frontend/views/site/index.php | <?php
/* @var $this yii\web\View */
$this->title = 'My Yii Application';
?>
<div class="site-index">
<div class="jumbotron">
<h1>Congratulations!</h1>
<p class="lead">You have successfully created your Yii-powered application.</p>
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
</div>
<div class="body-content">
<div class="row">
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p>
</div>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/resetPassword.php | frontend/views/site/resetPassword.php | <?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap4\ActiveForm */
/* @var $model \frontend\models\ResetPasswordForm */
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
$this->title = 'Reset password';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-reset-password">
<h1><?= Html::encode($this->title) ?></h1>
<p>Please choose your new password:</p>
<div class="row">
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'reset-password-form']); ?>
<?= $form->field($model, 'password')->passwordInput(['autofocus' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/site/error.php | frontend/views/site/error.php | <?php
/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */
use yii\helpers\Html;
$this->title = $name;
?>
<div class="site-error">
<h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/layouts/main.php | frontend/views/layouts/main.php | <?php
/* @var $this \yii\web\View */
/* @var $content string */
use common\widgets\Alert;
$this->beginContent('@frontend/views/layouts/base.php');
?>
<main class="d-flex">
<?php echo $this->render('_sidebar') ?>
<div class="content-wrapper p-3">
<?= Alert::widget() ?>
<?= $content ?>
</div>
</main>
<?php $this->endContent() ?> | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/layouts/base.php | frontend/views/layouts/base.php | <?php
/* @var $this \yii\web\View */
/* @var $content string */
use frontend\assets\AppAsset;
use yii\helpers\Html;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"
rel="stylesheet">
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap h-100 d-flex flex-column">
<div class="wrap h-100 d-flex flex-column">
<?php echo $this->render('_header') ?>
<?php echo $content ?>
</div>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/layouts/_sidebar.php | frontend/views/layouts/_sidebar.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 9:20 AM
*/
?>
<aside class="shadow">
<?php echo \yii\bootstrap4\Nav::widget([
'options' => [
'class' => 'd-flex flex-column nav-pills'
],
'encodeLabels' => false,
'items' => [
[
'label' => '<i class="fas fa-home"></i> Home',
'url' => ['/video/index']
],
[
'label' => '<i class="fas fa-history"></i> History',
'url' => ['/video/history']
]
]
]) ?>
</aside>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/layouts/_header.php | frontend/views/layouts/_header.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 9:20 AM
*/
use yii\bootstrap4\Nav;
use yii\bootstrap4\NavBar;
use yii\helpers\Url;
NavBar::begin([
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => ['class' => 'navbar-expand-lg navbar-light bg-light shadow-sm'],
'innerContainerOptions' => [
'class' => 'container-fluid'
]
]);
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => [
'data-method' => 'post'
]
];
}
?>
<form action="<?php echo Url::to(['/video/search']) ?>"
class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search"
name="keyword"
value="<?php echo Yii::$app->request->get('keyword') ?>">
<button class="btn btn-outline-success my-2 my-sm-0">Search</button>
</form>
<?php
echo Nav::widget([
'options' => ['class' => 'navbar-nav ml-auto'],
'items' => $menuItems,
]);
NavBar::end();
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/layouts/auth.php | frontend/views/layouts/auth.php | <?php
/* @var $this \yii\web\View */
/* @var $content string */
use common\widgets\Alert;
$this->beginContent('@frontend/views/layouts/base.php');
?>
<main class="d-flex">
<div class="content-wrapper p-3">
<?= Alert::widget() ?>
<?= $content ?>
</div>
</main>
<?php $this->endContent() ?> | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/channel/view.php | frontend/views/channel/view.php | <?php
/**
* User: TheCodeholic
* Date: 4/18/2020
* Time: 9:50 AM
*/
use yii\helpers\Url;
/** @var $this \yii\web\View */
/** @var $channel \common\models\User */
/**@var $dataProvider \yii\data\ActiveDataProvider */
$this->title = 'Channel ' . $channel->username . ' | ' . Yii::$app->name;
?>
<div class="jumbotron">
<h1 class="display-4"><?php echo $channel->username ?></h1>
<hr class="my-4">
<?php \yii\widgets\Pjax::begin() ?>
<?php echo $this->render('_subscribe', [
'channel' => $channel
]) ?>
<?php \yii\widgets\Pjax::end() ?>
</div>
<?php echo \yii\widgets\ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '@frontend/views/video/_video_item',
'layout' => '<div class="d-flex flex-wrap">{items}</div>{pager}',
'itemOptions' => [
'tag' => false
]
]) ?>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/channel/_subscribe.php | frontend/views/channel/_subscribe.php | <?php
/**
* User: TheCodeholic
* Date: 4/18/2020
* Time: 9:58 AM
*/
use yii\helpers\Url;
/** @var $channel \common\models\User */
?>
<a class="btn <?php echo $channel->isSubscribed(Yii::$app->user->id)
? 'btn-secondary' : 'btn-danger' ?>"
href="<?php echo Url::to(['channel/subscribe', 'username' => $channel->username]) ?>"
data-method="post" data-pjax="1">
Subscribe <i class="far fa-bell"></i>
</a> <?php echo $channel->getSubscribers()->count() ?>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/history.php | frontend/views/video/history.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 11:56 AM
*/
/** @var $dataProvider \yii\data\ActiveDataProvider */
$this->title = 'My Visited videos | '. Yii::$app->name;
?>
<h1>My Visited videos</h1>
<?php echo \yii\widgets\ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_video_item',
'layout' => '<div class="d-flex flex-wrap">{items}</div>{pager}',
'itemOptions' => [
'tag' => false
]
]) ?>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/_video_item.php | frontend/views/video/_video_item.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 12:00 PM
*/
use yii\helpers\Url;
/** @var $model \common\models\Video */
?>
<div class="card m-3" style="width: 14rem;">
<a href="<?php echo Url::to(['/video/view', 'id' => $model->video_id]) ?>">
<div class="embed-responsive embed-responsive-16by9">
<video class="embed-responsive-item"
poster="<?php echo $model->getThumbnailLink() ?>"
src="<?php echo $model->getVideoLink() ?>"></video>
</div>
</a>
<div class="card-bod p-2">
<h6 class="card-title m-0"><?php echo $model->title ?></h6>
<p class="text-muted card-text m-0">
<?php echo \common\helpers\Html::channelLink($model->createdBy) ?>
</p>
<p class="text-muted card-text m-0">
<?php echo $model->getViews()->count() ?> views .
<?php echo Yii::$app->formatter->asRelativeTime($model->created_at) ?>
</p>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/_buttons.php | frontend/views/video/_buttons.php | <?php
/**
* User: TheCodeholic
* Date: 4/18/2020
* Time: 9:23 AM
*/
/** @var $model \common\models\Video */
use yii\helpers\Url;
?>
<a href="<?php echo Url::to(['/video/like', 'id' => $model->video_id]) ?>"
class="btn btn-sm <?php echo $model->isLikedBy(Yii::$app->user->id) ? 'btn-outline-primary': 'btn-outline-secondary' ?>"
data-method="post" data-pjax="1">
<i class="fas fa-thumbs-up"></i> <?php echo $model->getLikes()->count() ?>
</a>
<a href="<?php echo Url::to(['/video/dislike', 'id' => $model->video_id]) ?>"
class="btn btn-sm <?php echo $model->isDislikedBy(Yii::$app->user->id) ? 'btn-outline-primary': 'btn-outline-secondary' ?>"
data-method="post" data-pjax="1">
<i class="fas fa-thumbs-down"></i> <?php echo $model->getDislikes()->count() ?>
</a>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/search.php | frontend/views/video/search.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 11:56 AM
*/
/** @var $dataProvider \yii\data\ActiveDataProvider */
$this->title = 'Search videos | '. Yii::$app->name;
?>
<h1>Found videos</h1>
<?php echo \yii\widgets\ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_video_item',
'layout' => '<div class="d-flex flex-wrap">{items}</div>{pager}',
'itemOptions' => [
'tag' => false
]
]) ?>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/_comment_item.php | frontend/views/video/_comment_item.php | <?php
/**
* User: TheCodeholic
* Date: 11/12/2020
* Time: 9:19 AM
*/
/** @var $model \common\models\Comment */
$subCommentCount = $model->getComments()->count();
?>
<div class="comment-item <?php echo $model->pinned ? 'pinned-comment' : ''?>" data-parent-id="<?php echo $model->parent_id ?>" data-id="<?php echo $model->id ?>">
<div class="media media-comment">
<img class="mr-3 comment-avatar" src="/img/avatar.svg" alt="">
<div class="media-body">
<h6 class="mt-0">
<?php if ($model->pinned): ?>
<div class="pinned-text text-muted mb-1">
<i class="fas fa-thumbtack"></i> Pinned comment
</div>
<?php endif; ?>
<?php echo \common\helpers\Html::channelLink($model->createdBy) ?>
<small class="text-muted">
<?php echo Yii::$app->formatter->asRelativeTime($model->created_at) ?>
<?php if ($model->created_at !== $model->updated_at): ?>
(edited)
<?php endif; ?>
</small>
</h6>
<div class="comment-text">
<div class="text-wrapper">
<?php if ($model->mention): ?>
<span class="badge bg-info"><?php echo '@'.$model->mention ?></span>
<?php endif; ?>
<?php echo $model->comment ?>
</div>
<div class="bottom-actions my-2">
<button data-action="<?php echo \yii\helpers\Url::to(['/comment/reply']) ?>"
class="btn btn-sm btn-light btn-reply">
REPLY
</button>
</div>
<div class="reply-section">
</div>
<?php if ($subCommentCount): ?>
<div class="mb-2">
<a href="<?php echo \yii\helpers\Url::to(['/comment/by-parent', 'id' => $model->id]) ?>"
class="view-sub-comments">View <?php echo $subCommentCount ?> replies</a>
</div>
<?php endif; ?>
<div class="sub-comments">
</div>
</div>
<?php if ($model->belongsTo(Yii::$app->user->id) || $model->video->belongsTo(Yii::$app->user->id)): ?>
<div class="dropdown comment-actions">
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton"
data-toggle="dropdown">
<i class="fas fa-ellipsis-v"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<?php if (!$model->parent_id && $model->video->belongsTo(Yii::$app->user->id)): ?>
<a class="dropdown-item item-pin-comment"
data-pinned="<?php echo $model->pinned ?>"
href="<?php echo \yii\helpers\Url::to(['/comment/pin', 'id' => $model->id]) ?>">
<i class="fas fa-thumbtack"></i>
<?php if ($model->pinned): ?>
Unpin
<?php else: ?>
Pin
<?php endif; ?>
</a>
<?php endif; ?>
<?php if ($model->belongsTo(Yii::$app->user->id)): ?>
<a class="dropdown-item item-edit-comment" href="#">
<i class="fas fa-edit"></i>
Edit
</a>
<?php endif; ?>
<a class="dropdown-item item-delete-comment"
href="<?php echo \yii\helpers\Url::to(['/comment/delete', 'id' => $model->id]) ?>">
<i class="fas fa-trash"></i>
Delete
</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
<div class="media media-input">
<img class="mr-3 comment-avatar" src="/img/avatar.svg" alt="">
<div class="media-body">
<form class="comment-edit-section" method="post"
action="<?php echo \yii\helpers\Url::to(['/comment/update', 'id' => $model->id]) ?>">
<textarea rows="1"
class="form-control"
name="comment"
placeholder="Add a public comment"></textarea>
<div class="action-buttons text-right mt-2">
<button type="button" class="btn btn-light btn-cancel">Cancel</button>
<button class="btn btn-primary btn-save">Save</button>
</div>
</form>
</div>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/view.php | frontend/views/video/view.php | <?php
/**
* User: TheCodeholic
* Date: 4/18/2020
* Time: 8:48 AM
*/
use yii\helpers\Html;
use yii\helpers\Url;
/** @var $this \yii\web\View */
/** @var $model \common\models\Video */
/** @var $similarVideos \common\models\Video[] */
/** @var $comments \common\models\Comment[] */
$this->title = $model->title . ' | ' . Yii::$app->name;
?>
<div class="row">
<div class="col-sm-8">
<div class="embed-responsive embed-responsive-16by9">
<video class="embed-responsive-item"
poster="<?php echo $model->getThumbnailLink() ?>"
src="<?php echo $model->getVideoLink() ?>"
controls></video>
</div>
<h6 class="mt-2"><?php echo $model->title ?></h6>
<div class="d-flex justify-content-between align-items-center">
<div>
<?php echo $model->getViews()->count() ?> views •
<?php echo Yii::$app->formatter->asDate($model->created_at) ?>
</div>
<div>
<?php \yii\widgets\Pjax::begin() ?>
<?php echo $this->render('_buttons', [
'model' => $model
]) ?>
<?php \yii\widgets\Pjax::end() ?>
</div>
</div>
<div>
<p>
<?php echo \common\helpers\Html::channelLink($model->createdBy) ?>
</p>
<?php echo Html::encode($model->description) ?>
</div>
<div class="comments mt-5">
<h4 class="mb-3"> <span id="comment-count"><?php echo $model->getComments()->count() ?></span> Comments</h4>
<div class="create-comment mb-4">
<div class="media">
<img class="mr-3 comment-avatar" src="/img/avatar.svg" alt="">
<div class="media-body">
<form class="create-comment-form" method="post"
action="<?php echo Url::to(['/comment/create', 'id' => $model->video_id]) ?>">
<input type="hidden" name="video_id" value="<?php echo $model->video_id ?>">
<textarea rows="1"
class="form-control comment-input"
name="comment"
placeholder="Add a public comment"></textarea>
<div class="action-buttons text-right mt-2">
<button type="button" class="btn btn-light btn-cancel">Cancel</button>
<button class="btn btn-primary btn-save">Comment</button>
</div>
</form>
</div>
</div>
</div>
<div id="comments-wrapper" class="comments-wrapper">
<?php foreach ($comments as $comment) {
echo $this->render('_comment_item', [
'model' => $comment,
]);
} ?>
</div>
</div>
</div>
<div class="col-sm-4">
<?php foreach ($similarVideos as $similarVideo): ?>
<div class="media mb-3">
<a href="<?php echo Url::to(['/video/view', 'id' => $similarVideo->video_id]) ?>">
<div class="embed-responsive embed-responsive-16by9 mr-2"
style="width: 120px">
<video class="embed-responsive-item"
poster="<?php echo $similarVideo->getThumbnailLink() ?>"
src="<?php echo $similarVideo->getVideoLink() ?>"></video>
</div>
</a>
<div class="media-body">
<h6 class="m-0"><?php echo $similarVideo->title ?></h6>
<div class="text-muted">
<p class="m-0">
<?php echo \common\helpers\Html::channelLink($similarVideo->createdBy) ?>
</p>
<small>
<?php echo $similarVideo->getViews()->count() ?> views •
<?php echo Yii::$app->formatter->asRelativeTime($similarVideo->created_at) ?>
</small>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/views/video/index.php | frontend/views/video/index.php | <?php
/**
* User: TheCodeholic
* Date: 4/17/2020
* Time: 11:56 AM
*/
/** @var $this \yii\web\View */
/** @var $dataProvider \yii\data\ActiveDataProvider */
$this->title = 'Popular videos | '. Yii::$app->name;
?>
<?php echo \yii\widgets\ListView::widget([
'dataProvider' => $dataProvider,
'pager' => [
'class' => \yii\bootstrap4\LinkPager::class,
],
'itemView' => '_video_item',
'layout' => '<div class="d-flex flex-wrap">{items}</div>{pager}',
'itemOptions' => [
'tag' => false
]
]) ?>
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/assets/AppAsset.php | frontend/assets/AppAsset.php | <?php
namespace frontend\assets;
use yii\web\AssetBundle;
/**
* Main frontend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/app.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap4\BootstrapAsset',
];
}
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/config/main.php | frontend/config/main.php | <?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
return [
'id' => 'app-frontend',
'name' => 'FreeCodeTube',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'defaultRoute' => '/video/index',
'layout' => 'auth',
'controllerNamespace' => 'frontend\controllers',
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => 'advanced-frontend',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/c/<username>' => '/channel/view',
'/v/<id>' => '/video/view',
],
],
'assetManager' => [
'appendTimestamp' => true
]
],
'params' => $params,
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/config/params.php | frontend/config/params.php | <?php
return [
'adminEmail' => 'admin@example.com',
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/config/test.php | frontend/config/test.php | <?php
return [
'id' => 'app-frontend-tests',
'components' => [
'assetManager' => [
'basePath' => __DIR__ . '/../web/assets',
],
'urlManager' => [
'showScriptName' => true,
],
'request' => [
'cookieValidationKey' => 'test',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/frontend/config/bootstrap.php | frontend/config/bootstrap.php | <?php
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/index.php | environments/index.php | <?php
/**
* The manifest of files that are local to specific environment.
* This file returns a list of environments that the application
* may be installed under. The returned data must be in the following
* format:
*
* ```php
* return [
* 'environment name' => [
* 'path' => 'directory storing the local files',
* 'skipFiles' => [
* // list of files that should only copied once and skipped if they already exist
* ],
* 'setWritable' => [
* // list of directories that should be set writable
* ],
* 'setExecutable' => [
* // list of files that should be set executable
* ],
* 'setCookieValidationKey' => [
* // list of config files that need to be inserted with automatically generated cookie validation keys
* ],
* 'createSymlink' => [
* // list of symlinks to be created. Keys are symlinks, and values are the targets.
* ],
* ],
* ];
* ```
*/
return [
'Development' => [
'path' => 'dev',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'console/runtime',
'frontend/runtime',
'frontend/web/assets',
],
'setExecutable' => [
'yii',
'yii_test',
],
'setCookieValidationKey' => [
'backend/config/main-local.php',
'common/config/codeception-local.php',
'frontend/config/main-local.php',
],
],
'Production' => [
'path' => 'prod',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'console/runtime',
'frontend/runtime',
'frontend/web/assets',
],
'setExecutable' => [
'yii',
],
'setCookieValidationKey' => [
'backend/config/main-local.php',
'frontend/config/main-local.php',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/console/config/params-local.php | environments/dev/console/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/console/config/test-local.php | environments/dev/console/config/test-local.php | <?php
return [
]; | php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/console/config/main-local.php | environments/dev/console/config/main-local.php | <?php
return [
'bootstrap' => ['gii'],
'modules' => [
'gii' => 'yii\gii\Module',
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/backend/config/params-local.php | environments/dev/backend/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/backend/config/test-local.php | environments/dev/backend/config/test-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/backend/config/codeception-local.php | environments/dev/backend/config/codeception-local.php | <?php
return yii\helpers\ArrayHelper::merge(
require dirname(dirname(__DIR__)) . '/common/config/codeception-local.php',
require __DIR__ . '/main.php',
require __DIR__ . '/main-local.php',
require __DIR__ . '/test.php',
require __DIR__ . '/test-local.php',
[
]
);
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/backend/config/main-local.php | environments/dev/backend/config/main-local.php | <?php
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
],
],
];
if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/backend/web/index.php | environments/dev/backend/web/index.php | <?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php'
);
(new yii\web\Application($config))->run();
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/backend/web/index-test.php | environments/dev/backend/web/index-test.php | <?php
// NOTE: Make sure this file is not accessible when deployed to production
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../../common/config/test.php',
require __DIR__ . '/../../common/config/test-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php',
require __DIR__ . '/../config/test.php',
require __DIR__ . '/../config/test-local.php'
);
(new yii\web\Application($config))->run();
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/common/config/params-local.php | environments/dev/common/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/common/config/test-local.php | environments/dev/common/config/test-local.php | <?php
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2advanced_test',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/common/config/codeception-local.php | environments/dev/common/config/codeception-local.php | <?php
return yii\helpers\ArrayHelper::merge(
require __DIR__ . '/main.php',
require __DIR__ . '/main-local.php',
require __DIR__ . '/test.php',
require __DIR__ . '/test-local.php',
[
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
],
],
]
);
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/common/config/main-local.php | environments/dev/common/config/main-local.php | <?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/frontend/config/params-local.php | environments/dev/frontend/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/frontend/config/test-local.php | environments/dev/frontend/config/test-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/frontend/config/codeception-local.php | environments/dev/frontend/config/codeception-local.php | <?php
return yii\helpers\ArrayHelper::merge(
require dirname(dirname(__DIR__)) . '/common/config/codeception-local.php',
require __DIR__ . '/main.php',
require __DIR__ . '/main-local.php',
require __DIR__ . '/test.php',
require __DIR__ . '/test-local.php',
[
]
);
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/frontend/config/main-local.php | environments/dev/frontend/config/main-local.php | <?php
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
],
],
];
if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/frontend/web/index.php | environments/dev/frontend/web/index.php | <?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php'
);
(new yii\web\Application($config))->run();
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/dev/frontend/web/index-test.php | environments/dev/frontend/web/index-test.php | <?php
// NOTE: Make sure this file is not accessible when deployed to production
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
}
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../../common/config/test.php',
require __DIR__ . '/../../common/config/test-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php',
require __DIR__ . '/../config/test.php',
require __DIR__ . '/../config/test-local.php'
);
(new yii\web\Application($config))->run();
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/console/config/params-local.php | environments/prod/console/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/console/config/main-local.php | environments/prod/console/config/main-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/backend/config/params-local.php | environments/prod/backend/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/backend/config/main-local.php | environments/prod/backend/config/main-local.php | <?php
return [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/backend/web/index.php | environments/prod/backend/web/index.php | <?php
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php'
);
(new yii\web\Application($config))->run();
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/common/config/params-local.php | environments/prod/common/config/params-local.php | <?php
return [
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
thecodeholic/Yii2-Youtube-Clone | https://github.com/thecodeholic/Yii2-Youtube-Clone/blob/d8d6c35890b5d3ebb00b0cc6ace20deea99974b1/environments/prod/common/config/main-local.php | environments/prod/common/config/main-local.php | <?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
],
],
];
| php | BSD-3-Clause | d8d6c35890b5d3ebb00b0cc6ace20deea99974b1 | 2026-01-05T04:42:11.286050Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.