A production-ready Raw PHP REST API Starter Kit with JWT authentication, user management, file uploads, caching, rate limiting, and Docker support.
- ✅ JWT Authentication - Secure token-based authentication
- ✅ User Management - Complete CRUD operations
- ✅ File Upload/Download - Secure file handling
- ✅ Rate Limiting - API request throttling
- ✅ Input Validation - Request data validation
- ✅ Caching System - File-based caching
- ✅ Error Handling - Centralized error management
- ✅ Logging - Request/error logging
- ✅ Health Checks - System monitoring
- ✅ Docker Support - Containerized deployment
- ✅ PHPUnit Testing - Comprehensive test suite
- ✅ API Documentation - Complete endpoint docs
- ✅ Debug Bar - Development debugging toolbar with performance monitoring
- ✅ CLI Support - Command-line interface for development tasks
- ✅ API Versioning - Multiple API versions with backward compatibility
- ✅ Queue System - Background job processing with Redis/Database drivers
Debug Bar Configuration (Optional)
Queue System Configuration (Optional)
After running migrations and seeders, use these credentials to test the API:
- GET /api/v1/health - Health check
- POST /api/v1/auth/register - Register new user
- POST /api/v1/auth/login - Login user
- GET /api/v1/users - Get all users (paginated)
- GET /api/v1/users/{id} - Get user by ID
- POST /api/v1/users - Create user
- PUT /api/v1/users/{id} - Update user
- DELETE /api/v1/users/{id} - Delete user
- GET /api/v2/health - Health check with metadata
- POST /api/v2/auth/register - Register with enhanced response
- POST /api/v2/auth/login - Login with structured response
- GET /api/v2/users - Get users with enhanced pagination
- GET /api/v2/users/{id} - Get user with metadata
- POST /api/v2/users - Create user with structured response
- PUT /api/v2/users/{id} - Update user with action tracking
- DELETE /api/v2/users/{id} - Delete user with confirmation
Note: These endpoints default to V1 behavior for backward compatibility
- POST /api/auth/register - Register new user
- POST /api/auth/login - Login user
- POST /api/auth/logout - Logout user
- GET /api/users - Get all users (paginated)
- GET /api/users/{id} - Get user by ID
- POST /api/users - Create user
- PUT /api/users/{id} - Update user
- DELETE /api/users/{id} - Delete user
- POST /api/files/upload - Upload file
- DELETE /api/files/{id} - Delete file
- GET /api/health - Health check
- GET /api/health/info - System info
The HRMS includes the following tables:
- users - Employee accounts with roles (admin, hr, employee)
- departments - Company departments
- employee_profiles - Extended employee information
- attendance - Daily attendance tracking
- leave_types - Leave categories (Annual, Sick, etc.)
- leave_requests - Leave applications with approval workflow
- payroll - Monthly salary processing
- performance_reviews - Employee performance evaluations
- tokens - JWT authentication tokens
- Application: Main app bootstrap and container
- Router: URL routing and middleware pipeline
- Request/Response: HTTP abstraction layer
- Database: PDO wrapper with query builder
- Authentication: JWT-based auth system
- Cache: File-based caching system
- Validation: Input validation and sanitization
- Password hashing (bcrypt)
- JWT token authentication
- Rate limiting (60 requests/hour per IP)
- Input sanitization and validation
- CORS middleware
- SQL injection protection (prepared statements)
The built-in debug bar provides real-time development insights with minimal performance impact.
- Performance Monitoring - Execution time and memory usage tracking
- Database Queries - All SQL queries with timing information
- Debug Messages - Categorized logging (info, warning, error)
- Request Data - HTTP method, URI, headers, and parameters
- Custom Timers - Measure specific code execution times
Add to your .env file:
- Database Queries: All PDO queries are automatically tracked
- Memory Usage: Current and peak memory consumption
- Request Info: HTTP method, URI, headers automatically captured
HTML Pages: Debug toolbar appears at the bottom of the page JSON APIs: Debug data included in X-Debugbar-Data response header (Base64 encoded JSON)
- Automatically disabled when DEBUGBAR_ENABLED=false
- IP whitelist support for production-like environments
- No sensitive data exposure (credentials are filtered)
- Zero performance impact when disabled
Visit http://localhost:8000/welcome to see the debug bar in action.
The framework supports multiple API versions with backward compatibility and flexible version detection.
- URI Path (Recommended)
- X-API-Version Header
- Accept Header
- Standard JSON responses
- Basic error handling
- Simple data structure
- Enhanced response format
- Structured error codes
- Metadata inclusion
- Timestamp tracking
V1 Features:
- Basic CRUD operations
- Simple response format
- Standard HTTP status codes
V2 Features:
- Enhanced error handling with error codes
- Metadata in responses
- Improved pagination info
- Structured error responses
- Create version directory: app/controllers/v3/
- Create versioned controllers
- Add route file: app/routes/api_v3.php
- Update Application.php to load new routes
For New Projects:
- Use explicit versioning from the start: /api/v1/
- Avoid legacy endpoints
For Existing Projects:
- Legacy endpoints (/api/) remain unchanged
- Gradually migrate clients to versioned endpoints
- Deprecate legacy endpoints in future versions
Best Practices:
- Always specify version in new integrations
- Use semantic versioning for major changes
- Maintain at least 2 versions simultaneously
- Provide migration guides for version changes
The framework includes a powerful queue system for background job processing with support for multiple drivers.
- Background Job Processing - Asynchronous task execution
- Multiple Drivers - Database and Redis support
- Email Queues - Reliable email delivery
- File Processing - Image resize, file conversion, compression
- Job Retry Logic - Automatic retry with exponential backoff
- Failed Job Handling - Dead letter queue for failed jobs
- CLI Workers - Command-line queue processors
Add to your .env file:
SendEmailJob - Email delivery
- Automatic retry on failure
- SMTP configuration support
- HTML/text email support
ProcessFileJob - File processing
- Image resizing
- File compression
- Format conversion
- Batch processing support
Database Driver
- Uses MySQL/PostgreSQL for job storage
- Automatic table creation
- Transaction support
- No external dependencies
Redis Driver
- High performance
- Atomic operations
- Delayed job support
- Requires Redis extension
The framework includes a powerful command-line interface for development tasks.
- PHP 8.0+
- MySQL 5.7+
- Composer
- Docker (optional)
- Fork the repository
- Create feature branch (git checkout -b feature/amazing-feature)
- Commit changes (git commit -m 'Add amazing feature')
- Push to branch (git push origin feature/amazing-feature)
- Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Md Rasheduzzaman
Full-Stack Software Engineer & Technical Project Manager
Building scalable, secure & AI-powered SaaS platforms across ERP, HRMS, CRM, LMS, and E-commerce domains.
Over 10 years of experience leading full-stack teams, cloud infrastructure, and enterprise-grade software delivery.
🌐 Portfolio: jmrashed.github.io
✉️ Email: [email protected]
💼 LinkedIn: linkedin.com/in/jmrashed
📝 Blog: medium.com/@jmrashed
💻 GitHub: github.com/jmrashed
“Need a Reliable Software Partner? I build scalable, secure & modern solutions for startups and enterprises.”
.png)
