REST API developed in PHP with JWT authentication for user and board management.
- JWT Authentication (Access + Refresh Tokens)
- Password hashing with bcrypt
- User CRUD operations
- Board CRUD operations
- Protected routes with middleware
- Input validation
- MariaDB database
- Docker for development
- Comprehensive documentation
- PHP 8.x
- Composer
- Docker Desktop (for database)
- MariaDB 11.5
git clone https://github.com/Ariff-dev/HybridgeCommunityBackend.git
cd HybridgeCommunityBackendcomposer installcp .env.example .envEdit .env with your credentials:
DB_USER=your_user
DB_PASS=your_password
DB_NAME=hybridge_community
DB_HOST=localhost
DB_ROOT_PASSWORD=your_root_password
JWT_SECRET=generate-a-secure-random-secret
JWT_ACCESS_TOKEN_EXPIRY=900
JWT_REFRESH_TOKEN_EXPIRY=604800
API_DEBUG=trueGenerate JWT Secret:
php -r "echo bin2hex(random_bytes(32));"docker-compose up -dConnect to database (port 2025) and import database_schema.sql:
mysql -h 127.0.0.1 -P 2025 -u your_user -p your_database < database_schema.sqlOr use DBeaver/phpMyAdmin.
php -S localhost:8000 -t publicAPI will be available at: http://localhost:8000/api
- API Documentation - Complete endpoint reference
- React Integration - Frontend integration guide
- Deployment Guide - Shared hosting deployment
- Development Guide - Local development setup
- Docker Guide - Containerized development
POST /api/auth/register # Register user
POST /api/auth/login # Login
POST /api/auth/refresh # Refresh access tokenGET /api/auth/me # Current user
POST /api/auth/logout # Logout
GET /api/users # List users
GET /api/board # List board items
POST /api/board # Create item
PUT /api/board # Update itemcurl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}'curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "password123"
}'Save the access_token from response.
curl -X GET http://localhost:8000/api/auth/me \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"HybridgeCommunityBackend/
├── public/
│ └── index.php # Entry point
├── src/
│ ├── Auth/
│ │ └── JwtHandler.php # JWT management
│ ├── Config/
│ │ └── database.php # Database connection
│ ├── Controllers/
│ │ ├── AuthController.php # Authentication
│ │ ├── UserController.php # Users
│ │ └── BoardController.php # Boards
│ ├── Models/
│ │ ├── UserModel.php
│ │ ├── BoardItem.php
│ │ └── RefreshTokenModel.php
│ ├── Middlewares/
│ │ ├── JwtAuth.php # JWT middleware
│ │ └── ApiKeyAuth.php # API Keys (legacy)
│ ├── Helpers/
│ │ └── Uuid.php
│ └── Routes/
│ └── api.php # Route definitions
├── vendor/ # Composer dependencies
├── .env # Environment variables
├── composer.json
├── docker-compose.yml
├── database_schema.sql # Database schema
├── API_DOCUMENTATION.md
├── REACT_INTEGRATION.md
└── DEPLOYMENT.md
- Passwords hashed with bcrypt
- JWT tokens with expiration
- Revocable refresh tokens
- Prepared statements (SQL injection prevention)
- Input validation
- Configurable CORS headers
See DEPLOYMENT.md for detailed deployment instructions on shared hosting.
Summary:
composer install --no-dev- Configure production
.env - Import SQL schema
- Upload files to hosting
- Configure
.htaccess
- PHP 8.x - Backend language
- MariaDB 11.5 - Database
- Firebase PHP-JWT - JWT token management
- vlucas/phpdotenv - Environment variables
- Docker - Database container
- PDO - Database abstraction layer
- Access tokens expire in 15 minutes
- Refresh tokens expire in 7 days
- Database port: 2025 (development)
- Set
API_DEBUG=falsein production
See REACT_INTEGRATION.md for:
- Complete AuthContext
- Automatic token refresh handling
- Example components (Login, Register, Dashboard)
- Protected Routes
For issues or questions:
- Review documentation
- Check PHP logs
- Verify dependencies are installed
- Confirm
.envis configured correctly
This project is open source.
- Add unit tests (PHPUnit)
- Implement rate limiting
- Add pagination to listings
- Implement DELETE method for boards
- Add advanced roles and permissions
- OpenAPI/Swagger documentation