README.md 6.45 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# AMOS Basic Template
`by EliteDivision`

This is a skeleton based on [Yii 2 Template](http://www.yiiframework.com/)

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.

## Platform requirements
### Hardware
#### Minimum
- STORAGE 200 GB.
- RAM 8GB
- CPU 4 Core

#### Recommended
- STORAGE 500 GB.
- RAM 16GB
- CPU 8 Core

### Software
- Debian >= 8, CentOS >= 7
- Apache >= 2.4.29
- Php 7.0.X
- MariaDB 10.2.X / MySQL 5.7.X 
- [Composer Dependency Manager](https://www.yiiframework.com/doc/guide/2.0/en/start-installation#installing-composer)

#### Required Apache/Lighttpd extensions
access_compat, alias, auth, autoindex, deflate, dir, env, filter, mime, mpm_prefork, negotiation, php7.0, reqtimeout, rewrite, setenvif, status

#### Required PHP extensions
apc, bcmath, ctype, curl, dom, exif, fileinfo, ftp, gd, gettext, iconv, imagick, intl, json, mbstring, mcrypt, mysqli, opcache, pdo, pdo_mysql, posix, soap, ssl, xml, xsl, zip

#### Required MySQL Options
In file `my.ini` in Windows or `my.cnf` in Linux, from the clause **sql-mode** *remove* options `STRICT_TRANS_TABLES`and `ONLY_FULL_GROUP_BY`
to set it as follows
```
[mysql]
sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
```

## DIRECTORY STRUCTURE
```
common
    config/              contains shared configurations
    mail/                contains view files for e-mails
    models/              contains model classes used in both backend and frontend
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
    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
    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
tests                    contains various tests for the advanced application
    codeception/         contains tests developed with Codeception PHP Testing Framework
```
## Platform configuration/initialization
Please select the environment you want to configure the platform with, follows the default
- Development
- Production

Nowadays main differences between default environments are: 
|Feature | Developments | Production |
|-|-|-|
| [Gii](https://www.yiiframework.com/doc/guide/2.0/en/start-gii) | Enabled | Not Enabled |
| [Debug](https://www.yiiframework.com/extension/yiisoft/yii2-debug/doc/guide/2.0/en/installation) | Enabled | Not Enabled |
| [Cache](https://www.yiiframework.com/doc/guide/2.0/en/caching-data) | [Dummycache](https://www.yiiframework.com/doc/api/2.0/yii-caching-dummycache) | [File cache](https://www.yiiframework.com/doc/api/2.0/yii-caching-filecache)|
| [Mailer](https://www.yiiframework.com/doc/guide/2.0/en/tutorial-mailing) | [Mail to file](https://www.yiiframework.com/doc/api/2.0/yii-mail-basemailer#$useFileTransport-detail) | Send mail |

Default environments can be copied or modified as needed.
Each new environment needs an entry into file "*environments/index.php*" to allow the init system to use it, and should be as follows
```
    'ENVIRONMENT_NAME_HERE' => [
        'path' => 'ENVIRONMENT_DIRECTORY_HERE',
        'setWritable' => [
            'backend/runtime',
            'backend/web/assets',
            'common/uploads',
            'common/uploads/store',
            'common/uploads/temp',
            'frontend/runtime',
            'frontend/web/assets',
        ],
        'setExecutable' => [
            'yii',
            'tests/codeception/bin/yii',
        ],
        'setCookieValidationKey' => [
            'backend/config/main-local.php',
            'frontend/config/main-local.php',
        ],
    ],
```
Please substitute the placeholders `ENVIRONMENT_NAME_HERE`, `ENVIRONMENT_DIRECTORY_HERE` with proper strings.

### Database
Before to install the platform, please create the database that will be layed at the base of it, e.g.
```
# mysql -u DB_USERNAME_HERE -pDB_PASSWORD_HERE -e "CREATE DATABASE
\`DB_NAME_HERE\` COLLATE 'utf8_general_ci';"
```
Then configure the [database connection](https://www.yiiframework.com/doc/guide/2.0/en/start-databases) into file "*environments/ENVIRONMENT_DIRECTORY_HERE/common/config/main-local.php*" as follows
```
'components' => [
    'db' => [
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost;dbname=DB_NAME_HERE',
        'username' => 'DB_USERNAME_HERE',
        'password' => 'DB_PASSWORD_HERE',
        'charset' => 'utf8',
    ],
]
```
Obviuosly into the file path put the directory where your selected environments is (prod, test, dev, demo, new1, etc.)
and substitute the placeholders `DB_NAME_HERE`, `DB_USERNAME_HERE`, `DB_PASSWORD_HERE` with proper strings.

### Environment initialization
Once the environment to be used is properly configured, run the following command to apply configurations to platform
```
# php init
```
### Packages depandency management
Run the following command to download all the required packages 
```
# composer update
```
### Database migration
Run the following command to create tables and views into database, and fill it up with basic data
```
# php yii migrate
```

### Start up account
After installation, the only accout available into the platform is an administrative account having 
`username`: demo
`password`: Demo123!
Please change it after first login.