DIS Project
This project is merging two frontend and backend technology together in the same repository. It uses Yii2 and Vue in order to get the most benifit both great frameworks.
The template contains the basic features including user login/logout and a contact page. It includes all commonly used configurations that would allow you to focus on adding new features to your application.
DIRECTORY STRUCTURE
The application structure is similar to a Vue project created by the vue-cli with the command vue create <app name>
.
There are two remarkable differences: an extra backend directory that contains Yii2 code, the dist folder that contains the build version was renamed to web.
+-- backend Yii2 Code (Server Side / API)
| +-- assets/ assets definition
| +-- behaviors/ Special-Purpose Calculation, e.g. IGSN, AutoIncr
| +-- commands/ yii console commands (controllers)
| +-- config/ application configurations (web, db backends)
| +-- controllers/ Web controller classes
| +-- dis_migration/ migration classes for Legacy DIS import
| +-- mail/ view files (templates) for notification e-mails
| +-- models/ model classes (twoway-data bindings)
| +-- modules/ modules (Code Generator as an example)
| +-- resources/ overriden data model classes for the API (User.php)
| +-- rest/ customizations for rest api classes (IndexAction.php)
| +-- runtime/ files generated during runtime (cache, logs, debug info...)
| +-- vendor/ dependent 3rd-party PHP packages
| +-- views/ view files for the Web application
| +-- widgets/ general purpose components (Alert.php)
+-- public public static assets (index.html, index.php, favicons)
+-- src Vue source code
| +-- assets vue logo only
| +-- components Display components and input components
| +-- forms Input forms (similar to src/pages)
| +-- mixins Input validators (not really components or screens)
| +-- pages Screens: Login, CoreSection, Dashboard
| +-- plugins vuetify.js (user interface components)
| +-- services BackendService (Auth), CrudService (data manipulation)
| +-- store state management: at this time: is logged in, isDark, snackbar
| +-- style stylus directives, will be compiled to css
| +-- util 1 Form (local storage)
+-- web output folder for command `npm run build`
REQUIREMENTS
The minimum requirement by this project template that your Web server supports PHP 7.1.
INSTALLATION
Install via Composer
@TODO
Install from an Archive File
@TODO
Install with Docker
Clone the repository and cd to it.
Prepare docker environment file by copying .env-dev
to .env
.
Update your vendor packages
docker-compose run --rm php composer update --prefer-dist
Run the installation triggers (creating cookie validation code)
docker-compose run --rm php composer install
Run post project creation triggers (set required permissions)
docker-compose run --rm php composer run-script post-create-project-cmd
Install frontend dependencies
npm install
To generate frontend bundle, use one of the following commands
npm run serve # starts a dev server (see https://cli.vuejs.org/guide/cli-service.html#vue-cli-service-serve)
npm run build # produces a production-ready bundle in the /web directory (see https://cli.vuejs.org/guide/cli-service.html#vue-cli-service-build)
Start the containers
docker-compose up # add -d to run as deamon (in the background)
You can then access the application at http://127.0.0.1:8000
After adding nodejs to the php container, first build time was increased. Take the build option out and uncomment the image line if do not need nodejs in the container. check here and here for suggested solutions.
On the command line you should see something like this:
docker ps | grep dis
Result:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
71b25a7418dd yiisoftware/yii2-php:7.1-apache "docker-php-entrypoi…" 23 hours ago Up 13 seconds 0.0.0.0:8000->80/tcp dis_php_1
57cdf5ca735e mariadb "docker-entrypoint.s…" 23 hours ago Up 23 hours 0.0.0.0:8001->3306/tcp dis_db_1
7424a0f9f6a7 adminer "entrypoint.sh docke…" 3 days ago Up 3 days 0.0.0.0:8002->8080/tcp dis_adminer_1
Rightmost Column NAMES
signifies:
-
dis_php_1
- Webserver with PHP/Yii2 Application -
dis_db_1
- Mariadb, Database Server -
dis_adminer_1
- Adminer, Web-based Database Administration Tool
Optionally, stop the containers with docker stop dis_php_1 dis_db_1 dis_adminer_1
.
Apply database migrations to create required tables and seed data
# bash into php container
docker exec -it dis_php_1 bash
# then call yii migrations
yii migrate
# seed users accounts
yii seed/users
# load DSEIS data
yii seed/example-dump
# seed users forms permissions
yii seed/form-permissions
The mariadb
container stores persistent DIS data inside volume dis_dbvolume
:
docker volume inspect dis_dbvolume
This enables the container to "survive" restarts, keeping data created by both the yii migrate
command and data eventually entered by the DIS user.
NOTES:
- Minimum required Docker engine version
17.04
for development (see Performance tuning for volume mounts) - The default configuration uses a host-volume in your home directory
.composer-docker
for php-composer caches
CONFIGURATION
Database
This configuration is not needed for docker installation.
Edit the file config/db.php
with real data, for example:
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=your_host;dbname=your_db_name',
'username' => 'your_db_user',
'password' => 'your_db_password',
'charset' => 'utf8',
];