EchoAPI is a minimalist microstack designed for developers who want to build RESTful APIs in PHP with speed, clean structure, and low coupling. Rather than being a full-stack framework, EchoAPI acts as a backend toolbox — delivering only the essential components needed for routing, validation, authentication, caching, logging, and external integrations.
Ideal for developers seeking a functional, lightweight, and maintainable API architecture without the overhead of complex frameworks.
PHP >= 8.1
Composer >= 2.x
MySQL 8+ or MariaDB
Redis (optional, for caching)
PHP Extensions:
Routing with AltoRouter
Lightweight ORM using Medoo
Data validation with Respect\Validation
Structured logging via Monolog
Multiple authentication layers:
Flexible caching via Symfony Cache (Filesystem, Redis, APCu)
Native email support with PHPMailer
Real-time error alerts through Telegram
project-root/
├── app/ # Swagger/OpenAPI docs
├── bootstrap/ # App bootstrap process
├── config/ # Configuration files
├── core/ # Kernel, helpers, services
├── storage/ # Cache & logs
├── middleware/ # HTTP middlewares
├── routes/ # Route definitions
├── src/ # App logic (MVC)
├── .env # Environment settings
├── composer.json # Dependencies & scripts
└── README.md
EchoAPI comes with a default database structure and initial data available in:
core/Migration/auth-migrations.sql
This script creates the basic authentication tables: users
, roles
, user_tokens
, and password_resets
.
[email protected]
master!123@
⚠️ The password is hashed in the database. Use this user only for first login or local development.
If you're using Docker, set the following in your .env
:
AUTO_MIGRATE=true
This will automatically import the auth-migrations.sql
during container startup.
🔐 After successful migration, it is strongly recommended to set
AUTO_MIGRATE=false
to prevent re-imports and protect data integrity.
To start a new project with EchoAPI, run:
composer create-project jandersongarcia/echoapi echoapi-example
More details: https://packagist.org/packages/jandersongarcia/echoapi
git clone https://github.com/jandersongarcia/EchoAPI.git
cd EchoAPI
composer install
cp .env.example .env
chmod -R 775 storage
Configure your .env
with DB, Redis, email, and Telegram.
EchoAPI supports Docker for rapid onboarding.
docker compose up --build -d
docker compose exec app composer install
Access: http://localhost:8080
public/index.php
API_KEY=your_token
in .env
Authorization: Bearer YOUR_KEY
Generate:
composer generate:key
Generate system:
composer make:auth
Includes login, register, password reset, logout endpoints.
Supports Google, LinkedIn, Azure, Facebook, GitHub.
composer make:oauth google linkedin
Uses PHPMailer configured via config/php_mailer.php
.
$mail = new MailHelper();
$mail->send('[email protected]', 'Subject', '<p>Body</p>');
Configured via .env
:
CACHE_DRIVER=redis
REDIS_HOST=redis
Fallbacks to filesystem if not available.
composer swagger:build
Output: app/docs/openapi.json
(for Swagger UI or Redoc).
⚠️ When
APP_ENV=production
, access to/v1/docs/swagger.json
is disabled for security reasons.
Access the interactive Swagger UI at the /docs/
endpoint of your deployed application. For example:
http://localhost:8080/docs/ (local development)
Enable in .env
:
TELEGRAM_BOT_TOKEN=xxx
TELEGRAM_CHAT_ID=xxx
ERROR_NOTIFY_CATEGORIES=critical,error,alert
storage/logs/
app.log
: info+error.log
: error+Test:
composer log:test
Command | Description |
---|---|
make:module | Create controller/service/model |
delete:module | Remove a module |
make:crud | CRUD generator |
delete:crud | Delete CRUD set |
list:crud | List registered CRUDs |
make:auth | JWT authentication scaffold |
delete:auth | Remove JWT files |
make:oauth | OAuth provider integration |
delete:oauth | Remove OAuth config |
generate:key | Generate API Key |
log:test | Generate sample logs |
telegram:test | Test Telegram alert |
swagger:build | Build OpenAPI spec |
APP_ENV=development
APP_DEBUG=true
API_KEY=your_api_key
DB_HOST=db
DB_PORT=3306
DB_NAME=echoapi
DB_USER=root
DB_PASS=root
CACHE_DRIVER=redis
REDIS_HOST=redis
TELEGRAM_BOT_TOKEN=xxx
TELEGRAM_CHAT_ID=xxx
ERROR_NOTIFY_CATEGORIES=critical,error,alert
Code | Description | Details |
---|---|---|
E001 | .env not found |
The .env file is missing. Rename .env.example to .env . |
E002 | Missing environment variable | One or more required environment variables are missing or empty. |
{
"error": "Environment file not found",
"message": "The \".env\" file is required. Please rename \".env.example\" to \".env\" and configure your environment variables.",
"code": "E001"
}
{
"error": "Missing environment variable",
"message": "The environment variable 'DB_HOST' is missing or empty in your .env file.",
"code": "E002"
}
MIT License Developed by Janderson Garcia