git clone https://github.com/rknow/payment-processor.git
cd payment-processor
composer install
PAYMENT_GATEWAY=PayPal # PayPal | Stripe | Mock
MOCK_SHOULD_SUCCEED=true
php run.php
=== Payment Processor (Env + PHP-DI) ===
[LOG] PayPal processing payment of $150 [LOG] PayPal refunding $75
=== Done ===
PAYMENT_GATEWAY=Stripe
🧪 Testing
vendor/bin/phpunit --testdox
docker build -t payment-processor .
docker run --rm payment-processor vendor/bin/phpunit --testdox
docker compose up --build
docker run -e PAYMENT_GATEWAY=Stripe payment-processor
Or use your .env file:
docker run --env-file .env payment-processor
⚡ Continuous Integration (GitHub Actions)
The included workflow .github/workflows/ci.yml will:
1. Build the Docker image
2. Run PHPUnit tests inside the container
3. Execute on each push or pull_request to the main branch
You can view your test status under GitHub → Actions.
🛠️ Technologies Used
| Category | Tool |
|---|---|
| Language | PHP 8.3 |
| Dependency Injection | PHP-DI |
| Environment Config | vlucas/phpdotenv |
| Unit Testing | PHPUnit |
| Containerization | Docker & Docker Compose |
| CI/CD | GitHub Actions |
🎨 Concepts Demonstrated
| Concept | Example |
|---|---|
| Interface | PaymentInterface defines the contract |
| Trait | LoggerTrait for reusable logging |
| Dependency Injection | PaymentProcessor depends on PaymentInterface |
| Testing | MockPayment simulates success/failure |
| Configuration | .env controls which gateway is used |
| Automation | CI pipeline builds and tests via Docker |
- Add REST API using Slim or Laravel
- Database-backed transaction logs
- Code coverage reports in CI
- Docker Hub publishing
MIT License © 2025 — Free to use, learn, and modify.
If you find this useful, please star ⭐ the repo or fork it to learn modern PHP project structure and CI integration.