buiduongthe / yii2-ecommerce

Đây là dự án lập trình dùng trong việc nghiên cứu học tập thực hành về sử dụng Framework Yii2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yii 2 Advanced Project Template


Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.

The template includes three tiers: front end, back end, and console, each of which is a separate Yii application.

The template is designed to work in a team development environment. It supports deploying the application in different environments.

Documentation is at docs/guide/README.md.

Latest Stable Version Total Downloads build

DIRECTORY STRUCTURE

common
    config/              contains shared configurations
    mail/                contains view files for e-mails
    models/              contains model classes used in both backend and frontend
    tests/               contains tests for common classes    
console
    config/              contains console configurations
    controllers/         contains console controllers (commands)
    migrations/          contains database migrations
    models/              contains console-specific model classes
    runtime/             contains files generated during runtime
backend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains backend configurations
    controllers/         contains Web controller classes
    models/              contains backend-specific model classes
    runtime/             contains files generated during runtime
    tests/               contains tests for backend application    
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
frontend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains frontend configurations
    controllers/         contains Web controller classes
    models/              contains frontend-specific model classes
    runtime/             contains files generated during runtime
    tests/               contains tests for frontend application
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
    widgets/             contains frontend widgets
vendor/                  contains dependent 3rd-party packages
environments/            contains environment-based overrides

Đây là dự án dùng để học tập và tham khảo, không vì mục đích thương mại

Trân trọng cảm ơn các tác giả của các Theme, thư viện đã được sử dụng trong mã nguồn này

Dụ án có sử dụng các Themes, Thư viện ... được liệt kê sau đây:

- Theme Frontend: Nest - Multipurpose eCommerce HTML Template

- Theme Backend: AdminLte 3

- ...

B1. Install Xampp

Truy cập vào trang chủ Xampp tại Xampp Download và cài đặt/cấu hình theo hướng dẫn sau:



B2. Install Composer

Truy cập vào trang chủ Composer tại Composer Download


B3. Install Git

Truy cập trang chủ Git tại Git Download và thực hiện cài đặt theo hướng dẫn mặc định

B4. Install Yii2

Truy cập vào thư mục htdocs của Xampp để thực hiện câu lệnh bên dưới

Nếu dự án đã được khởi tạo thì chỉ cần gõ lệnh: composer update

composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application

Mở phần mềm PppStorm và thực hiện mở thư mục yii-application, mở chế độ dòng lệnh Terminal và thực thi một trong các lệnh sau:

composer update
composer install --ignore-platform-reqs
composer update --ignore-platform-reqs

Gõ lệnh php init, chọn môi trường dev hoặc pro, sau đó nhấn Yes nếu muốn ghi đè các tập tin cấu hình

php init

B5. Install Notepad ++

Truy cập vào website tại đây và tải phần mềm Notepadd ++ và cài đặt mặc định

B6. Install PhpStorm

Truy cập vào website tại đây và tải phần mềm PhpStorm và cài đặt mặc định

Mở phần mềm PhpStorm, đăng ký bản quyền, mở Project

Vào menu File -> Settings -> Plugins tìm với từ khóa Yii và cài đặt các tiện ích (Yii2 Support,Yii2 Inspection, Yii::t, Yii2-Url)

B7. Config Database

Truy cập vào thư mục common/config/ mở tập tin main-local.php thực hiện cấu hình tham số cho dbname, username, password
<?php

return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=e-commerce',
            '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,
        ],
    ],
];

Import DB db/e-commerce.sql

B8. Custom VirtualHost

Truy cập vào thư mục "E:\xampp\apache\conf\extra" mở tập tin "httpd-vhosts.conf" bằng phần mềm Notepadd ++ (Chọn Yes nếu hỏi quyền Administrator) thêm đoạn mã vào cuối tập tin và khởi động lại Apache

<VirtualHost *:80>
    DocumentRoot "E:/xampp/htdocs/yii-application/frontend/web"
    ServerName banhang.com
    ErrorLog "logs/banhang.com-error.log"
    CustomLog "logs/banhang.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "E:/xampp/htdocs/yii-application/backend/web"
    ServerName admin.banhang.com
    ErrorLog "logs/admin.banhang.com-error.log"
    CustomLog "logs/admin.banhang.com-access.log" common
</VirtualHost>

B9. Config Hosts

Windows: Vào trong thư mục C:\Windows\Systems32\drivers\etc

Mở tập tin hosts bằng phần mềm Notepadd ++ (Chọn Yes nếu hỏi quyền Administrator). Thêm dòng sau đây vào cuối tập tin "hosts", lưu ý cấp quyền ghi vào tập tin "hosts"

Linux: Vào trong thư mục /etc/hosts Thêm dòng sau đây vào cuối tập tin "hosts", lưu ý cấp quyền ghi vào tập tin "hosts"

127.0.0.1 banhang.com
127.0.0.1 admin.banhang.com

B10. Friendly Url

Tạo tập tin .htaccess với nội dung sau:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

Chép tập tin .htaccess vào 2 thư mục frontend/web và backend/web

Truy cập vào backend/config hoặc frontend/config, tùy chỉnh tập tin main.php

Tìm đoạn mã sau

/*
'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
    ],
],
/*

Sửa thành (bỏ thẻ /* */)

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
    ],
],

B11.Testing

Frontend: http://banhang.com

Backend: http://admin.banhang.com

username:admin
password:999999

About

Đây là dự án lập trình dùng trong việc nghiên cứu học tập thực hành về sử dụng Framework Yii2

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:HTML 86.9%Language:PHP 5.9%Language:CSS 3.5%Language:JavaScript 3.4%Language:Hack 0.2%Language:Shell 0.1%Language:Awk 0.0%Language:Batchfile 0.0%Language:Dockerfile 0.0%