- Overview
- Features
- Minimum Requirements
- Docker Services
- Installation With Docker
- Installation Without Docker
- Testing and Analysis Tools
- Running Tests
- Docker Installation
- Docker Compose Installation
- Example Images
This is a task management application built with Laravel 10 for the backend and Vue 3 for the frontend, featuring Pinia for state management and Vuetify for UI components.
- Task Creation and Modification: Users can create new tasks and modify existing ones.
- Task Filtering and Sorting: Tasks can be filtered and sorted based on various criteria.
- Time Tracking:
- Each task includes two time fields:
- Task Estimation Time: The estimated time to complete the task.
- Task Used Time: The time spent working on the task.
- Used Time: Users can add used time to existing tasks, and the time is added to the current Used Time field.
- Each task includes two time fields:
- Task Completion: Tasks can be marked as "completed" and reverted back to "in progress" if needed.
- Docker and Docker Compose
- PHP: 8.1 or higher
- Composer: 2.0 or higher
- MySQL: 5.7 or higher
- Laravel: 10.x
- Node.js 20 or higher
This project uses Docker to containerize the different components of the application. Below is a description of each service defined in the docker-compose.yml file:
-
nginx: The Nginx service serves as a reverse proxy for the application, routing HTTP requests to the appropriate backend services.
-
php: This service runs the PHP application (Laravel) using PHP 8.1. It is the core backend service that handles HTTP requests, interacts with the database, and manages the application logic. The service shares the application codebase with the host machine to enable hot-reloading during development.
-
mysql: This service runs the MySQL database server, which stores the application's data. The database is configured with persistent storage to retain data across container restarts. The database credentials and other environment variables are defined in the
.envfile. -
phpmyadmin: A web-based interface for managing MySQL databases. It allows developers to interact with the database, run queries, and manage tables via a user-friendly UI. The service is accessible via a browser on port 80 (or a custom port defined in the
.envfile). -
node: This service is responsible for building and serving the Vue.js frontend application. It runs the Node.js server, compiles assets, and serves the frontend during development.
-
selenium: This service runs Selenium with a Chrome browser in a container to allow automated browser testing. It listens on port 4444 and is used for running Dusk tests.
First, need a fresh installation of Docker and Docker Compose
Clone the repository to your local machine:
git clone https://github.com/ubul86/task_webapp.git
cd task_webappCopy the .env.example file to .env
cp .env.example .envCopy the .env.testing.example file to .env.testing
cp .env.testing.example .env.testingIn the .env file, you need to set the DB connections and some Host. Here is an example configuration:
DB_CONNECTION=mysql
DB_HOST=mysql82
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password
DB_ROOT_PASSWORD=your_database_root_password
NGINX_PORT=8080
PHPMYADMIN_PORT=45678
VITE_API_URL=/api/
The DB_HOST needs to be mysql82 service name.
Go to the project root directory, where is the docker-compose.yml file and add the following command:
docker-compose up -d --buildInstall PHP dependencies using Composer:
docker exec -it {php_fpm_container_name} composer installor
docker exec -it {php_fpm_container_name} bash
composer installdocker exec -it {php_fpm_container_name} php artisan key:generateor
docker exec -it {php_fpm_container_name} bash
php artisan key:generateRun the database migrations with seed:
docker exec -it {php_fpm_container_name} php artisan migrate:fresh --seedor
docker exec -it {php_fpm_container_name} bash
php artisan migrate:fresh --seeddocker exec -it {node_container_name} npm installor
docker exec -it {node_container_name} npm installdocker exec -it {node_container_name} npm run buildor
docker exec -it {node_container_name} npm run watchIt is necessary to change the user and group inside the PHP container. This is currently an issue using the application with Docker, unfortunately.
docker exec -it {php_container} chown -R www-data:www-data *Clone the repository to your local machine:
git clone https://github.com/yourusername/your-repository.git
cd your-repositoryInstall PHP dependencies using Composer:
composer installCopy the .env.example file to .env
cp .env.example .envCopy the .env.testing.example file to .env.testing
cp .env.testing.example .env.testingCreate a new database for the project and set the database connection in the .env file. Update the following lines in your .env file. There is an example setting:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_passwordRun the database migrations:
php artisan migrateSeed the database with initial data:
php artisan db:seedRun the Laravel development server:
php artisan serveThe application should now be accessible at http://localhost:8000.
npm installnpm run buildor
npm run watchPHPCS is used to check coding standards and style violations.
composer lintor
docker exec -it {php_fpm_container} composer lintPHPStan is used for static code analysis to find bugs and improve code quality.
Run PHPStan:
composer analyseor
docker exec -it {php_fpm_container} composer analyseNote: You might need to update your phpstan.neon configuration if you encounter issues or deprecations.
Unit tests are written using PHPUnit. To run tests, first configure SQLite in-memory database in phpunit.xml or .env.testing file. This setup allows you to run tests without affecting your actual database. The database is created and discarded during each test run, ensuring a clean state.
- Open phpunit.xml and set up the SQLite in-memory database configuration:
<phpunit bootstrap="vendor/autoload.php" colors="true">
<php>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>- Run the tests:
php artisan testor
docker exec -it {php_fpm_container} php artisan testThis will execute all tests in the tests directory and provide a summary of test results.
In addition to unit testing with PHPUnit, this project supports end-to-end testing using Laravel Dusk. To run Dusk tests, the following steps are required:
1. Install the necessary dependencies: Ensure that the necessary environment variables are configured in the .env.sample or .env file.
Add the following lines to the .env.sample file:
DUSK_DRIVER=chrome
DUSK_DRIVER_URL=http://selenium:4444/wd/hub
APP_URL=http://nginx # Set the correct URL for your app when using Docker2. Set up Selenium: Ensure that the selenium service is included in your docker-compose.yml file (as shown above).
3. Install Chromium: If you're running Dusk tests inside a Docker container, ensure that Chromium is installed and accessible. This can be added to the Dockerfile for the PHP service or a separate service if necessary.
4. Run the Dusk tests: Once the environment is configured, run the Dusk tests with the following command:
docker-compose exec php php artisan duskThis will execute all the Dusk tests in the tests/Browser directory. The tests will run using Selenium with the Chrome browser.
By following these updated instructions, you can now run both PHPUnit unit tests and Laravel Dusk browser tests within the Dockerized environment.
- Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
- For Linux Mint: https://computingforgeeks.com/install-docker-and-docker-compose-on-linux-mint-19/
- Docker automatically installs Docker Compose.






