PHPackages                             apileon/framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. apileon/framework

ActiveLibrary[Framework](/categories/framework)

apileon/framework
=================

A lightweight, enterprise-ready PHP framework focused only on REST APIs

00[1 PRs](https://github.com/bandeto45/apileon/pulls)PHPCI passing

Since Aug 19Pushed 8mo agoCompare

[ Source](https://github.com/bandeto45/apileon)[ Packagist](https://packagist.org/packages/apileon/framework)[ RSS](/packages/apileon-framework/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Apileon 🦁
=========

[](#apileon-)

*A lightweight, enterprise-ready PHP framework focused only on REST APIs.*

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)[![PHP Version](https://camo.githubusercontent.com/88b464e5614cf654f181925115d47b523dc429fcfe41d59565e42e757f306f29/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e312d3838393242462e737667)](https://camo.githubusercontent.com/88b464e5614cf654f181925115d47b523dc429fcfe41d59565e42e757f306f29/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e312d3838393242462e737667)[![Build Status](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)[![PRs Welcome](https://camo.githubusercontent.com/04a4daccbffa4d19acb5431562650baa8cfc58aba75c7d757494d9b4b631f0a9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d677265656e2e737667)](https://camo.githubusercontent.com/04a4daccbffa4d19acb5431562650baa8cfc58aba75c7d757494d9b4b631f0a9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d677265656e2e737667)

---

🚀 Overview
----------

[](#-overview)

**Apileon** is a PHP framework built exclusively for **REST API development**.
It is designed with **simplicity, speed, and scalability** in mind — removing unnecessary overhead and focusing on what matters most: **clean and powerful APIs**.

Think of Apileon as the **enterprise-grade foundation** for your next API project.

---

✨ Features
----------

[](#-features)

- ⚡ **REST-first architecture** – built only for APIs, no bloat
- 🛠 **Simple Routing** – clean and fast endpoint definitions
- 🔐 **Middleware Support** – authentication, CORS, rate limiting
- �️ **Secured Database CRUD** – enterprise-grade database operations with validation
- �📦 **Extensible Core** – modular design for enterprise projects
- 📊 **JSON-first Communication** – optimized for modern web &amp; mobile apps
- 🧪 **Test-Friendly** – structured for PHPUnit &amp; CI/CD pipelines
- 🚀 **Zero Dependencies** – works with just PHP 8.1+, no Composer required
- 🔧 **Auto-loading** – PSR-4 compliant autoloader included
- 🌐 **Production Ready** – enterprise-grade security and performance
- 📈 **Built-in Performance Monitoring** – track response times, memory usage, queries ⭐
- 💾 **Flexible Caching System** – file, array, and Redis support ⭐
- 🎯 **Event System** – decoupled architecture with custom events ⭐
- 🔍 **Health Monitoring** – built-in health checks and metrics endpoints ⭐

---

📦 Installation
--------------

[](#-installation)

### Option 1: With Composer (Recommended)

[](#option-1-with-composer-recommended)

```
composer create-project apileon/framework my-api
```

### Option 2: Without Composer (Simple Setup)

[](#option-2-without-composer-simple-setup)

```
git clone https://github.com/bandeto45/apileon.git my-api
cd my-api
./setup-no-composer.sh
```

**No dependencies required!** - Apileon works with just PHP 8.1+

---

🛠 Quick Start
-------------

[](#-quick-start)

### With Composer

[](#with-composer)

```
composer create-project apileon/framework my-api
cd my-api
composer serve
```

### Without Composer (Just PHP!)

[](#without-composer-just-php)

```
git clone https://github.com/bandeto45/apileon.git my-api
cd my-api
./setup-no-composer.sh
php -S localhost:8000 -t public
```

**2. Define your first route**
Edit `routes/api.php`:

```
use Apileon\Routing\Route;

Route::get('/hello', function () {
    return ['message' => 'Hello from Apileon!'];
});
```

**3. Start the server**

```
# With Composer
composer serve

# Without Composer
php -S localhost:8000 -t public
```

**4. Test your endpoint**

```
curl http://localhost:8000/hello
```

Response:

```
{
  "message": "Hello from Apileon!"
}
```

---

📂 Project Structure
-------------------

[](#-project-structure)

```
my-api/
├── autoload.php                    # Manual autoloader (no Composer needed)
├── app/                           # Application logic
│   ├── Controllers/               # HTTP controllers
│   ├── Models/                   # Data models
│   └── Middleware/               # Custom middleware
├── config/                       # Configuration files
│   ├── app.php                   # App configuration
│   └── database.php              # Database configuration
├── docs/                         # Core documentation
│   ├── README.md                 # Complete framework guide
│   ├── API.md                    # API documentation
│   ├── routing.md                # Routing guide
│   ├── middleware.md             # Middleware guide
│   ├── testing.md                # Testing guide
│   └── no-composer-setup.md      # No-Composer setup
├── docker/                       # Docker configuration
│   ├── nginx.conf                # Nginx configuration
│   ├── supervisord.conf          # Supervisor configuration
│   └── start.sh                  # Docker startup script
├── public/                       # Public web root
│   ├── index.php                 # Smart entry point (Composer + manual)
│   └── index-no-composer.php     # Explicit no-Composer entry
├── routes/                       # Route definitions
│   └── api.php                   # API routes
├── src/                          # Framework core
│   ├── Foundation/               # Application foundation
│   ├── Http/                     # HTTP components & middleware
│   ├── Routing/                  # Routing system
│   └── Support/                  # Helper utilities & functions
├── tests/                        # PHPUnit tests
├── vendor/                       # Composer dependencies (optional)
├── .env.example                  # Environment template
├── composer.json                 # Dependencies & autoloading (optional)
├── phpunit.xml                   # Testing configuration
├── setup.sh                     # Composer setup script
├── setup-no-composer.sh         # No-Composer setup script
├── status.sh                    # Status check script
├── test-no-composer.php         # Framework test (no dependencies)
│
├── # 🚀 Portable Deployment Files
├── deploy-portable.php           # Interactive deployment generator
├── create-portable.php          # Portable ZIP package generator
├── create-standalone.php        # Self-contained executable generator
├── create-database.php          # SQLite database initializer
├── install-zero-deps.sh         # Zero-dependency installer
├── install-php-and-run.sh       # PHP auto-installer
├── run-docker.sh                # Docker launcher (Unix/Linux/macOS)
├── run-docker.bat               # Docker launcher (Windows)
├── Dockerfile.portable          # Docker configuration for portable deployment
├── docker-compose.portable.yml  # Docker Compose for portable deployment
│
├── # 📚 Documentation Files
├── README.md                     # Main framework documentation
├── DOCUMENTATION_INDEX.md        # Complete documentation index
├── PORTABLE_DEPLOYMENT_GUIDE.md  # Portable deployment guide
├── DEPENDENCY_REQUIREMENTS.md    # With/without PHP deployment guide
├── DEPLOYMENT_GUIDE.md          # Production deployment guide
├── SECURE_DEPLOYMENT_GUIDE.md   # Security deployment guide
├── DATABASE_CRUD_GUIDE.md       # Database operations guide
└── QUICK_DEPLOYMENT_CHEAT_SHEET.md # Quick reference for deployment

```

---

⚙️ Configuration
----------------

[](#️-configuration)

- `.env` file for environment variables
- `config/` for database, caching, and app settings

Example `.env`:

```
APP_ENV=local
APP_KEY=base64:randomkeyhere
APP_DEBUG=true
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=apileon
DB_USERNAME=root
DB_PASSWORD=
```

---

🗄️ Database &amp; CRUD Operations
---------------------------------

[](#️-database--crud-operations)

Apileon includes a comprehensive, secured database CRUD system with enterprise-grade features:

### Quick Database Setup

[](#quick-database-setup)

```
# Configure database in .env file
cp .env.example .env

# Run migrations to create tables
php artisan migrate

# Seed database with sample data
php artisan db:seed
```

### Model Example

[](#model-example)

```
use App\Models\User;

// Create a new user (password auto-hashed)
$user = User::create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'password' => 'secure_password'
]);

// Find users
$user = User::find(1);
$users = User::where('status', 'active')->get();
$paginated = User::paginate(10, 1);

// Update user
$user->update(['name' => 'John Smith']);

// Delete user
$user->delete();
```

### Security Features

[](#security-features)

- ✅ **SQL Injection Protection** - All queries use prepared statements
- ✅ **Mass Assignment Protection** - Fillable/guarded attributes
- ✅ **Password Security** - Automatic bcrypt hashing
- ✅ **Input Validation** - 20+ validation rules
- ✅ **Error Handling** - Comprehensive error responses

### Available CLI Commands

[](#available-cli-commands)

```
# Development Commands
php artisan migrate              # Run database migrations
php artisan migrate:rollback     # Rollback migrations
php artisan db:seed             # Seed database with data
php artisan make:model Post     # Generate new model
php artisan make:controller PostController  # Generate controller
php artisan serve               # Start development server

# Security & Deployment Commands
php artisan security:check      # Run comprehensive security validation
php artisan package:secure      # Create secure deployment package

# Portable Deployment Commands
php deploy-portable.php         # Interactive portable deployment generator
php create-portable.php         # Create portable ZIP package
php create-standalone.php       # Create self-contained executable
./install-zero-deps.sh          # Zero-dependency deployment
./install-php-and-run.sh        # Auto-install PHP and run
```

**📖 Complete Guide:** See [DATABASE\_CRUD\_GUIDE.md](DATABASE_CRUD_GUIDE.md) for full documentation.

---

🧩 Middleware Example
--------------------

[](#-middleware-example)

```
use Apileon\Http\Middleware;

class AuthMiddleware extends Middleware {
    public function handle($request, $next) {
        if (!$request->header('Authorization')) {
            return response()->json(['error' => 'Unauthorized'], 401);
        }
        return $next($request);
    }
}
```

Attach middleware to routes:

```
Route::get('/profile', 'UserController@profile')->middleware('auth');
```

---

🧪 Testing
---------

[](#-testing)

### With Composer (Full Testing)

[](#with-composer-full-testing)

```
# Run all tests
composer test

# Run specific test
vendor/bin/phpunit tests/RequestTest.php

# Generate coverage report
vendor/bin/phpunit --coverage-html coverage/
```

### Without Composer (Basic Testing)

[](#without-composer-basic-testing)

```
# Test framework functionality
php test-no-composer.php

# Manual syntax check
find . -name "*.php" -exec php -l {} \;
```

---

📖 Documentation
---------------

[](#-documentation)

Full documentation available in the `docs/` folder and root directory:

### 📚 **Core Framework Documentation**

[](#-core-framework-documentation)

- **[Complete Guide](docs/README.md)** - Framework documentation
- **[No Composer Setup](docs/no-composer-setup.md)** - Use without Composer
- **[API Reference](docs/API.md)** - Endpoint documentation
- **[Routing Guide](docs/routing.md)** - Advanced routing patterns
- **[Middleware Guide](docs/middleware.md)** - Security &amp; custom middleware
- **[Testing Guide](docs/testing.md)** - Unit &amp; integration testing

### 🚀 **Deployment &amp; Production Documentation**

[](#-deployment--production-documentation)

- **[Portable Deployment Guide](PORTABLE_DEPLOYMENT_GUIDE.md)** - Complete portable deployment options
- **[Dependency Requirements](DEPENDENCY_REQUIREMENTS.md)** - With/without PHP deployment guide
- **[Deployment Guide](DEPLOYMENT_GUIDE.md)** - Production deployment and security
- **[Secure Deployment Guide](SECURE_DEPLOYMENT_GUIDE.md)** - Advanced security deployment
- **[Database CRUD Guide](DATABASE_CRUD_GUIDE.md)** - Database operations and security

### 🛠 **Quick Reference**

[](#-quick-reference)

- **[.env.example](.env.example)** - Environment configuration template
- **[composer.json](composer.json)** - Dependencies and autoloading
- **[phpunit.xml](phpunit.xml)** - Testing configuration

---

🚀 Quick Examples
----------------

[](#-quick-examples)

### Create a Simple API

[](#create-a-simple-api)

```
// routes/api.php
use Apileon\Routing\Route;

Route::get('/users', function() {
    return [
        'users' => [
            ['id' => 1, 'name' => 'John Doe', 'email' => 'john@example.com'],
            ['id' => 2, 'name' => 'Jane Smith', 'email' => 'jane@example.com']
        ],
        'total' => 2
    ];
});

Route::get('/users/{id}', function($request) {
    $id = $request->param('id');
    return [
        'user' => [
            'id' => $id,
            'name' => 'User ' . $id,
            'email' => "user{$id}@example.com"
        ]
    ];
});

Route::post('/users', function($request) {
    $data = $request->all();
    return [
        'message' => 'User created successfully',
        'user' => [
            'id' => rand(100, 999),
            'name' => $data['name'] ?? 'Unknown',
            'email' => $data['email'] ?? 'unknown@example.com'
        ]
    ];
});
```

### Add Authentication

[](#add-authentication)

```
// Protected routes
Route::group(['middleware' => ['auth']], function() {
    Route::get('/profile', function($request) {
        return ['user' => ['id' => 1, 'name' => 'Authenticated User']];
    });

    Route::put('/profile', function($request) {
        return ['message' => 'Profile updated', 'data' => $request->all()];
    });
});

// Usage: curl -H "Authorization: Bearer your-token" http://localhost:8000/profile
```

### Custom Controller

[](#custom-controller)

```
// app/Controllers/PostController.php
