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.4 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 exec php php artisan migrate:refresh --seed
Updating the database later on can be done by simply running
docker-compose exec php php artisan migrate
The install is almost finished, run the following command once to generate an encryption key:
docker-compose exec php php artisan key:generate
We're done.
You can now reach the following services:
| Service | Location |
|---|---|
| Webserver | localhost |
| DB | 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.
Note: If you get a "Permission denied" or HTTP 500 error when opening the webpage, make sure that PHP has write access to the "bootstrap/cache" folder and the "storage" folder. You can achieve this with chmod 777, but this is insecure. By replacing the ownership of the two folders the same effect will be achieved. The numbers "33" in the command below are the user ID and group ID for "www-data", the user/group used by PHP (in the Docker container).
chown 33:33 bootstrap/cache -R
chown 33:33 storage -R
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
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