The primary goal of this project is to create a streamlined and efficient development environment using Docker Compose. This environment will consist of PHP-FPM, Xdebug, Nginx web server, and MariaDB, enabling developers to quickly and easily start working on their PHP projects.
- Easy setup with docker compose and Dockerfile under usage from Docker
- Uses PHP 8.3.8 for better performance, lower CPU and memory usage
- And composer the dependency manager for PHP to start easy your project
- Built on the lightweight nginx 1.27.0 webserver
- Debugging with Xdebug 3.3.2
- Testing with PHPUnit 11.2.1 to ensure code quality and reliability
- Redis 7.2.5 as session storage, database, cache, streaming engine, and message broker
- Database storage with MariaDB 11.4.2
-
Clone the repository:
git clone https://github.com/IshtarStar/docker-compose-nginx-phpfpm-xdebug-mariadb.git ./docker-skeleton cd docker-skeleton
-
Build and start the Docker containers:
docker compose up --build -d
-
Install Composer dependencies:
docker compose exec -T php-fpm composer install
-
Run PHPUnit tests with code coverage:
docker compose exec -T php-fpm ./vendor/bin/phpunit --coverage-text --testdox tests
An example PHPUnit test is included in the tests
directory:
// tests/ExampleTest.php
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use App\Example;
class ExampleTest extends TestCase
{
public function testExample()
{
$example = new Example();
$this->assertTrue($example->doSomething());
}
}
See also: Blog-Post: Dockerize your PHP application with Nginx and PHP8 FPM