A modern, lightweight RESTful API service built with Lumen framework for managing articles and tags. The service provides comprehensive CRUD operations with advanced filtering capabilities, following clean architecture principles and best practices.
- Full CRUD Operations: Complete management of articles and tags
- Advanced Filtering: Filter articles by multiple tags with flexible criteria
- Clean Architecture: Repository pattern, dependency injection, and service layers
- Type Safety: PHPStan-compliant code with comprehensive type annotations
- Comprehensive Testing: Full test coverage with PHPUnit
- Containerized Deployment: Docker-based infrastructure for consistent environments
- Modern PHP: Built with PHP 8.4 and latest language features
- Standardized Responses: Consistent API response format across all endpoints
POST /articles- Create a new article with tagsPUT /articles/{id}- Update an existing articleDELETE /articles/{id}- Delete an articleGET /articles/{id}- Get article by ID with all associated tagsGET /articles- List all articles with optional tag filtering
POST /tags- Create a new tagPUT /tags/{id}- Update an existing tagGET /tags/{id}- Get tag by IDGET /tags- List all tags
# Get articles with specific tags
GET /articles?tags=php,laravel
# Filter articles by name
GET /articles?name=introduction- Lumen 11.0 - Micro-framework for building fast APIs
- PHP 8.4 - Modern PHP with latest language features
- Eloquent ORM - Database abstraction and relationships
- Docker & Docker Compose - Containerization and orchestration
- MySQL 8.0 - Primary database for data persistence
- Nginx 1.17 - Web server and reverse proxy
- PHP-FPM - PHP FastCGI Process Manager
- PHPUnit 11.0 - Unit and feature testing
- PHPStan (Larastan) - Static analysis for type safety
- Laravel Pint - Code style formatting
- Rector - Code refactoring and modernization
- Faker - Test data generation
- Mockery - Mocking framework for tests
- Repository Pattern - Data access abstraction
- Dependency Injection - Loose coupling and testability
- Service Layer - Business logic separation
- DTO (Data Transfer Objects) - Type-safe data transfer
- Validation Services - Centralized input validation
- Docker and Docker Compose
- Make (optional, for convenience commands)
-
Clone the repository
git clone https://github.com/Simtel/rest-article-service cd rest-article-service -
One-command setup
make install
This command will:
- Build Docker containers
- Start services
- Copy environment configuration
- Install Composer dependencies
- Run database migrations
- Seed initial data
-
Verify installation
make test
If you prefer step-by-step installation:
# Build containers
make build
# Start services
make up
# Copy environment file
make env
# Install dependencies
make composer-install
# Run migrations
make migrate
# Seed database
make db-seedmake install # Complete installation process
make up # Start all services
make down # Stop all services
make build # Build Docker containers
make test # Run test suite
make migrate # Run database migrations
make db-seed # Seed database with sample data
make shell # Access PHP container shell
make logs # View container logsThe project includes comprehensive test coverage:
# Run all tests
make test
# Run specific test file
docker-compose exec app vendor/bin/phpunit tests/ArticleTest.php
# Run tests with coverage
docker-compose exec app vendor/bin/phpunit --coverage-html coverageTest categories:
- Unit Tests - Individual component testing
- Feature Tests - API endpoint testing
- Integration Tests - Database interaction testing
# Static analysis with PHPStan
docker-compose exec app vendor/bin/phpstan analyse
# Code formatting with Pint
docker-compose exec app vendor/bin/pint
# Code refactoring with Rector
docker-compose exec app vendor/bin/rector process# Create new migration
docker-compose exec app php artisan make:migration create_new_table
# Run migrations
make migrate
# Rollback migrations
docker-compose exec app php artisan migrate:rollback
# Fresh database with seeding
make db-fresh-
Environment Configuration
- Set
APP_ENV=production - Configure proper database credentials
- Set up application key
- Configure logging levels
- Set
-
Performance Optimization
- Enable OPcache in PHP configuration
- Configure proper memory limits
- Set up database connection pooling
- Implement caching strategies (Redis/Memcached)
-
Security
- Use HTTPS in production
- Implement rate limiting
- Configure CORS properly
- Set up proper firewall rules
-
Monitoring
- Add application monitoring (New Relic, DataDog)
- Configure log aggregation
- Set up health check endpoints
- Monitor database performance
# Build production image
docker build -f docker/web.Dockerfile -t rest-article-service:latest .
# Run with production compose
docker-compose -f docker-compose.prod.yml up -d-
Authentication & Authorization
- JWT token-based authentication
- Role-based access control (RBAC)
- API key management
- OAuth2 integration
-
Advanced Features
- Full-text search for articles
- Article versioning and history
- Bulk operations (import/export)
- File attachments for articles
- Article scheduling and publishing
-
Performance Optimizations
- Redis caching layer
- Database query optimization
- API response caching
- Database read replicas
- CDN integration for static assets
-
Microservices Evolution
- Split into separate services (Articles, Tags, Users)
- Event-driven architecture with message queues
- Service mesh implementation
- API Gateway integration
-
Advanced Patterns
- CQRS (Command Query Responsibility Segregation)
- Event Sourcing for audit trails
- Domain-Driven Design (DDD) implementation
- Hexagonal Architecture
-
Integration Capabilities
- REST API versioning (v1, v2)
- GraphQL endpoint implementation
- WebSocket support for real-time updates
- Webhook system for external integrations
-
CI/CD Pipeline
- GitHub Actions or GitLab CI
- Automated testing and deployment
- Code quality gates
- Security scanning integration
-
Monitoring & Observability
- Prometheus metrics collection
- Grafana dashboards
- Distributed tracing (Jaeger)
- Log aggregation (ELK stack)
-
Scalability
- Kubernetes deployment
- Horizontal Pod Autoscaling
- Load balancing strategies
- Database sharding
-
Documentation
- OpenAPI/Swagger documentation
- Postman collection
- Interactive API documentation
- Developer onboarding guides
-
Development Tools
- Local development environment improvements
- Hot reload for development
- Debug tools integration
- IDE extensions and helpers
Detailed API documentation is available in the /docs directory or can be generated using:
# Generate API documentation
make docsThe service provides consistent JSON responses with the following structure:
{
"success": true,
"data": {
"id": 1,
"title": "Sample Article",
"tags": [
{"id": 1, "name": "php"},
{"id": 2, "name": "laravel"}
]
},
"message": "Article created successfully"
}- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
make test) - Run code quality tools (
make lint) - Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Laravel Documentation
- Lumen Documentation
- Docker Documentation
- PHPUnit Documentation
- PHPStan Documentation
Built with β€οΈ using modern PHP practices and clean architecture principles.