A minimalist PHP framework for building REST APIs and web applications.
- PHP 7.4 or higher
- MySQL/MariaDB, SQLite, PostgreSQL, MS SQL or Sybase
- Composer
- Clone the repository:
git clone https://github.com/jdanielcmedina/lapa.git my-app
- Enter the project directory:
cd my-app
- Install dependencies:
composer install
- Copy configuration file:
cp config.example.php config.php
-
Configure your database and other settings in
config.php
-
Start development server:
php -S localhost:8000 -t public
- Simple and intuitive route definition
- Support for multiple HTTP methods (GET, POST, PUT, PATCH, DELETE, OPTIONS)
- Route parameters (/:id, /:slug)
- Route grouping
- Virtual hosts (subdomains)
- 404 handlers
- Wildcard routes
- Auto-loading routes from /routes directory
- Session protection
- HTTPS enforcement
- Password hashing
- Access control
- CSRF protection
- Secure file permissions
- Custom authentication handlers
- File uploads with validation
- File downloads
- File moving/renaming
- Secure file permissions
- Organized directory structure
- Automatic cleanup
- Disk space monitoring
- Public/private storage areas
- MySQL/MariaDB support
- SQLite support
- PostgreSQL support
- MS SQL Server support
- Sybase support
- Safe query building
- Multiple database types
- JSON responses
- Text responses
- XML responses
- HTML/View responses
- File downloads
- Redirects
- Status codes
- Custom headers
- CORS support
- Session handling
- Cookie management
- Cache system
- Flash messages
- Headers management
- SMTP support
- HTML emails
- Attachments
- Multiple configurations
- Logging system
- Debug mode
- String slugification
- Time ago formatting
- Request validation
- Configuration management
- Random string generation
- String cleaning
- Distance calculation
- Auto-loading configuration
composer require jdanielcmedina/lapa
<?php
require 'vendor/autoload.php';
// Initialize app (config.php is auto-loaded)
$app = new Lapa();
// Simple route
$app->on('GET /', function() {
return 'Hello World';
});
// Route with parameters
$app->on('GET /users/:id', function() {
return $this->db->select('users', '*', [
'id' => $this->param('id')
]);
});
// Protected route
$app->on('GET /admin', function() {
$this->protect();
return ['status' => 'admin area'];
});
// Route group
$app->group('/api', function($app) {
$app->on('GET /status', function() {
return ['status' => 'online'];
});
$app->notFound(function() {
return ['error' => 'API endpoint not found'];
});
});
/your-app
/routes
api.php
admin.php
web.php
/storage
/app
/public
/private
/logs
/cache
/temp
/uploads
/public
index.php
config.php
composer.json
Contributions are welcome! Please feel free to submit a Pull Request.
composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CHANGELOG for more information on what has changed recently.
- 📧 Email: [email protected]
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
The MIT License (MIT). Please see License File for more information.
- Daniel Medina (@jdanielcmedina)