Skip to content
Yii2 module for blog
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
LICENSE
README.md
composer.json

README.md

Yii2 module for blog, advanced template. Backend blog management, SBadmin panel.

Advantages

Posts, comments, rubrics, tags, users, authors.

Imperavi redactor. Files & Images uploading. Photos chain for carousel slider.

Comment management. Nested set rubric.

Avatars for users and authors. User registration with email confirmation.

RBAC.

Installation

After installation Yii2 advanced template.

Change project composer file

Package has dev-master version and depends on the same packages, so

In app directory change composer.json:

  "minimum-stability": "dev",
  "prefer-stable": true,

Install package

$ composer require --prefer-dist sergmoro1/yii2-blog-tools "dev-master"

Run migrations

$ php yii migrate --migrationPath=@vendor/notgosu/yii2-meta-tag-module/src/migrations
$ php yii migrate --migrationPath=@vendor/sergmoro1/yii2-byone-uploader/migrations
$ php yii migrate --migrationPath=@vendor/sergmoro1/yii2-lookup/src/migrations
$ php yii migrate --migrationPath=@vendor/sergmoro1/yii2-user/src/migrations
$ php yii migrate --migrationPath=@vendor/sergmoro1/yii2-blog-tools/src/migrations

Git init

$ git init

Copy predefined files to appropriate folders

In app directory:

$ cp ./vendor/sergmoro1/yii2-blog-tools/src/initblog ./
$ php initblog
$ chmod -R 777 ./frontend/web/files
$ chmod 777 ./frontend/config/params.php

Configs

Set up in backend/config/main.php.

return [
  'defaultRoute' => '/blog/site/index',
  'layoutPath' => '@vendor/sergmoro1/yii2-blog-tools/src/views/layouts',
  'modules' => [
    'uploader' => ['class' => 'sergmoro1\uploader\Module'],
  ],
  'components' => [
    'authManager' => [
      'class' => 'yii\rbac\PhpManager',
      'defaultRoles' => ['commentator', 'author', 'admin'],
      'itemFile' => __DIR__ . '/../../console/rbac/items.php',
      'ruleFile' => __DIR__ . '/../../console/rbac/rules.php',
    ],
    'user' => [
      'class' => 'yii\web\User',
      'identityClass' => 'common\models\User',
      'enableAutoLogin' => true,
      'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
    ],
    'urlManager' => [
      'class' => 'yii\web\UrlManager',
      'enablePrettyUrl' => true,
      'showScriptName' => false,
      'enableStrictParsing' => false,
    ],
    'errorHandler' => [
      'errorAction' => '/blog/site/error',
    ],
  ],
];

Set up in common/config/main.php.

return [
  ...
  'language' => 'ru-RU', // 'en-US',
  'bootstrap' => ['blog'],
  'modules' => [
    'lookup' => ['class' => 'sergmoro1\lookup\Module'],
    'blog' => ['class' => 'sergmoro1\blog\Module'],
    'user' => ['class' => 'sergmoro1\user\Module'],
    'seo' => [
      'class' => 'notgosu\yii2\modules\metaTag\Module',
    ],
  ],
  'components' => [
    'authManager' => [
      'class' => 'yii\rbac\PhpManager',
    ],
    'user' => [
      'class' => 'yii\web\User',
    ],
    'mailer' => [
      'class' => 'yii\swiftmailer\Mailer',
      'useFileTransport' => false,
      'viewPath' => '@vendor/sergmoro1/yii2-user/src/mail',
      /* Definition of Yandex post office for your domain (example).
      'transport' => [
        'class' => 'Swift_SmtpTransport',
        'host' => 'smtp.yandex.ru',
        'username' => 'admin@your-site.ru',
        'password' => 'your-password',
        'port' => '465',
        'encryption' => 'ssl',
      ],
      */
    ],
    'i18n' => [
      'translations' => [
        'app*' => [
          'class' => 'yii\i18n\PhpMessageSource',
          'basePath' => '@app/../messages',
          'sourceLanguage' => 'en-US',
          'fileMap' => [
            'app' => 'app.php',
            'app/error' => 'error.php',
          ],
        ],
        'metaTag' => [
          'class' => 'yii\i18n\PhpMessageSource',
        ],
        // sergmoro1/user/models/LoginForm is used in frontend/controllers/SiteController, so
        // it is not used within the Module then translation should be defined twice
        // here and in a sergmoro1/user/Module::registerTranslations()
        'sergmoro1/user/*' => [
          'class' => 'yii\i18n\PhpMessageSource',
          'sourceLanguage' => 'en-US',
          'basePath' => '@vendor/sergmoro1/yii2-user/src/messages',
          'fileMap' => [
            'sergmoro1/user/core' => 'core.php',
          ],
        ],
      ],
    ],
  ],
];

Don't forget add .htaccess file to backend/web and frontend/web.

Start

Enter http://your-app/backend/web and Login.

Name: Admin

Password: 123456

You can’t perform that action at this time.