Skip to content

Blog website based on Yii 2 Advanced Application Template

License

Notifications You must be signed in to change notification settings

tomasyhy/yii2-blog

Repository files navigation

Blog based on Yii 2 framework

Application is a simple blog website based on Yii2 Advanced Project Template

Functionality:

Admin section

  1. Create\Edit\Hide\Show\Delete posts.
  2. Create\Edit\Delete tags.
  3. Hide\Show\Delete comments.

Frontend

  1. Searching posts by tags.
  2. View post.
  3. Adding comments.
  4. Sending notifications about comments to page admin.
  5. Contact form.

Console

  1. Creating account for admin.

Requirements

  1. PHP > 5.6
  2. Composer

Screenshots

main-page post-update post-content admin-panel-posts-list

Installation

1. Application

  1. Clone or download repository to any folder on your web server.

  2. Inside root folder run the application initialization command.

    php init --env=Production --overwrite=All
    
  3. Inside root folder install required composer dependencies.

    composer update
    

2. Database

  1. Log to your database and create database.

    CREATE SCHEMA `database_name`;
    
  2. Run following migrations inside root folder using terminal:

    php yii migrate
    php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations
    

3. Configuration

  1. Set your database connection by adjust settings under components['db'] key in your common/config/main-local.php file.

  2. Set mailer configuration in components['mailer'] key in your frontend/config/main-local.php file. Example:

    'components' => [
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@frontend/mail',
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.gmail.com',
                'username' => '[email protected]',
                'password' => 'password',
                'port' => '587',
                'encryption' => 'tls',
            ],
            'useFileTransport' => false,
        ],
    ]
    
  3. Create admin account.

    php yii user/create <email> <user_name> <password>
    

4. Setup web server

  1. Add following host configuration to your apache host file and adjust Directory, DocumentRoot and ServerName

    <VirtualHost *:80>
        ServerName blog.com
        DocumentRoot /path-to/root/folder/blog
        <Directory /path-to/root/folder/blog>
            Options Indexes FollowSymLinks
            AllowOverride All
            DirectoryIndex index.php
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    
  2. Change the hosts file to point the domain to your server.

    • for Windows: c:\Windows\System32\Drivers\etc\hosts
    • for Linux: /etc/hosts

    Add the following line:

    127.0.0.1   blog
    

5. Run application:

  1. Noww you can run blog site using following urls:

    • for frontend:
    http://blog
    
    • admin section
    http://blog/admin
    

If you have any problems visit Yii2 Documentation or contact with me.

About

Blog website based on Yii 2 Advanced Application Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published