Repository navigation
Setup
These instructions will help setup the development environment using docker. It is also possible to run without docker, however no instructions are provided for that.
The following items are required when using these instructions.
- Docker (when using Windows make sure you're able to use Hyper-V)
The following items are recommended to make your life easier.
- PHPStorm to make use of pre-configured Xdebug
- PHP >= 7.1 installed
- Composer (http://getcomposer.org)
- NodeJS (https://nodejs.org)
- Yarn (https://yarnpkg.com)
For convenience sake the PHP container is able to run composer and yarn commands. However, it is often easier to run them outside of Docker.
First clone the repository (or use the HTTPS clone version)
git clone git@github.com:HuInstituteForICT/workplacelearning.git
Enter the project folder
cd workplacelearning
Copy the .env.example to .env. It is not yet necessary to configure the values inside.
Install the PHP dependencies. This can be done through the PHP container, or if you have Composer installed locally through there.
# First build the container as it does not exist yet, can take a while, grab a coffee.
docker-compose build --no-cache php && docker-compose run php composer install
or
composer install
Now start the other containers with
docker-compose up -d
Sometimes it is necessary for the next step to run docker-compose up -d again. This happens when the DB is not completely started.
Create the database schema by running the migrations with
# Yes, double php. First denotes container, second calls PHP executable
docker-compose run php php artisan migrate:refresh --seed
Updating the database later on can be done by simply running
docker-compose run php php artisan migrate
The install is almost finished, run the following command once to generate an encryption key:
docker-compose run php php artisan key:generate
We're done.
You can now reach the following services:
| Service | Location |
|---|---|
| Webserver | localhost |
| DB client | localhost:3306 |
| PhpMyAdmin | localhost:8080 |
| Mailcatcher | localhost:1080 |
When registering a new account is might be necessary to increase the account's rights to teacher or admin. This should be done through the PhpMyAdmin service. The login details of the database are found in the .env file.
Javascript and CSS assets have compiled versions in the repository. This is a necessary evil currently and might change in the future.
Javascript and CSS should be compiled before first use and after every asset update.
Asset compilation can be done using Laravel Mix.
This requires that the dependencies are installed, install them with:
docker-compose exec php yarn
Or if yarn is available on host machine use yarn
Now you can compile assets with
docker-compose exec php yarn dev
To keep compiling on changes
docker-compose exec php yarn watch
Translations can be added and modified manually by editing the right lang files in resources/lang/*.
Another approach is to use the Laravel Translation Manager package, available in dev environment at localhost/translations.
Instructions on how to use it can be found at its github page.
React/JS translations are stored in resources/lang/*/react.php. These are compiled to the public/messages.js file with php artisan lang:js.
So don't forget to compile whenever you add new translations that are used in React/JS.
Laravel has three ways to use translations:
- Lang::get('namespace.key')
- trans('namespace.key')
- __('namespace.key') or __('string to translate')
with the latter using .json files first. We only use the __('') function as it will check both json and normal translations files, removing the need to decide which helper to use.
Tests can be ran in the IDE by configuring PHPUnit in it.
Alternatively you can execute it in the PHP container by running:
docker-compose exec php ./vendor/bin/phpunit