PHPackages                             uptura-official/flexiapi - 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. uptura-official/flexiapi

ActiveLibrary[Framework](/categories/framework)

uptura-official/flexiapi
========================

FlexiAPI - A powerful CLI-based framework for rapid REST API development with zero configuration

v3.7.25(6mo ago)198MITPHPPHP &gt;=8.0

Since Oct 10Pushed 6mo agoCompare

[ Source](https://github.com/Uptura/flexiapi)[ Packagist](https://packagist.org/packages/uptura-official/flexiapi)[ Docs](https://github.com/Uptura/flexiapi)[ RSS](/packages/uptura-official-flexiapi/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (35)Used By (0)

🚀 FlexiAPI Framework
====================

[](#-flexiapi-framework)

[![Latest Version](https://camo.githubusercontent.com/af2a1e113908aa6412d09d10a4a4d12e8f8b54bc028ee924a5ab26ac91be982d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7570747572612d6f6666696369616c2f666c6578696170692e737667)](https://packagist.org/packages/uptura-official/flexiapi)[![PHP Version](https://camo.githubusercontent.com/e855b058a1c7fed9ec351c57edf2ee1328997804d5ea22361de8a2015a653eff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7570747572612d6f6666696369616c2f666c6578696170692e737667)](https://packagist.org/packages/uptura-official/flexiapi)[![License](https://camo.githubusercontent.com/726e499ebec3df998e93a757af883f572a19cb36d9df33889ddb113418c497eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7570747572612d6f6666696369616c2f666c6578696170692e737667)](https://github.com/Uptura/flexiapi/blob/main/LICENSE)

**FlexiAPI** is a powerful, zero-configuration CLI framework for rapid REST API development. Build production-ready APIs with authentication, encryption, pagination, and CORS in minutes, not hours.

🌟 Key Features
--------------

[](#-key-features)

- 🎯 **Zero Configuration** - Get started immediately without complex setup
- 🔐 **Built-in Authentication** - JWT with custom headers (Auth-x)
- 🛡️ **Field-Level Encryption** - AES-256-CBC encryption for sensitive data
- 📊 **Advanced Querying** - Pagination, search, filtering, and sorting
- 🌐 **Dynamic CORS** - CLI-configurable CORS policies
- ⚡ **Rapid Development** - Create full CRUD APIs in seconds
- 🔧 **Flexible CLI** - Works in development and production environments
- 📦 **Easy Deployment** - Composer-ready package management

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

[](#-installation)

### Global Installation (User Recommended)

[](#global-installation-user-recommended)

```
composer global require uptura-official/flexiapi
mkdir my-api && cd my-api
flexiapi init
```

### Create New Project (Developers)

[](#create-new-project-developers)

```
composer create-project uptura-official/flexiapi
cd flexiapi
flexiapi setup
```

### Create with Custom Directory Name

[](#create-with-custom-directory-name)

```
composer create-project uptura-official/flexiapi .
# Run this inside your desired project directory
```

### Manual Setup

[](#manual-setup)

```
git clone https://github.com/Uptura/flexiapi.git my-api-project
cd my-api-project
composer install
flexiapi setup
```

### Local Dev Test

[](#local-dev-test)

```
php bin/flexiapi --command
```

### Update Framework

[](#update-framework)

```
composer update uptura-official/flexiapi --no-cache
```

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Initialize Your API

[](#1-initialize-your-api)

```
flexiapi setup
# Configures database, authentication, and basic settings
```

### 2. Create Your First Endpoint

[](#2-create-your-first-endpoint)

```
flexiapi create users
# Interactive setup: define columns, data types, encryption
```

### 3. Start Development Server

[](#3-start-development-server)

```
flexiapi serve
# Launches built-in development server with your API
```

### 4. Test Your API

[](#4-test-your-api)

Your API is immediately available with full CRUD operations:

```
# List all users (with pagination)
curl -H "Auth-x: Bearer YOUR_TOKEN" http://localhost:8000/api/v1/users

# Create a new user
curl -X POST -H "Auth-x: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John Doe","email":"john@example.com"}' \
  http://localhost:8000/api/v1/users

# Get specific user
curl -H "Auth-x: Bearer YOUR_TOKEN" http://localhost:8000/api/v1/users/1

# Update user
curl -X PUT -H "Auth-x: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Jane Doe"}' \
  http://localhost:8000/api/v1/users/1

# Delete user
curl -X DELETE -H "Auth-x: Bearer YOUR_TOKEN" http://localhost:8000/api/v1/users/1
```

🔐 Authentication
----------------

[](#-authentication)

FlexiAPI uses JWT tokens with a custom `Auth-x` header for enhanced security.

### Generate API Keys

[](#generate-api-keys)

```
curl -X POST http://localhost:8000/api/v1/auth/generate_keys
```

To solve "Invalid secret", retrieve your JWT secret key from config.php

**Response:**

```
{
  "success": true,
  "message": "API keys generated successfully",
  "data": {
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
    "expires_at": "2025-10-11 22:00:00"
  }
}
```

### Use Authentication

[](#use-authentication)

Include the `Auth-x` header in all authenticated requests:

```
curl -H "Auth-x: Bearer YOUR_TOKEN" http://localhost:8000/api/v1/users
```

🛡️ Field-Level Encryption
-------------------------

[](#️-field-level-encryption)

Protect sensitive data with built-in AES-256-CBC encryption.

### Configure Encryption

[](#configure-encryption)

```
flexiapi update:endpoint users
# Choose option to configure field encryption
```

### Automatic Encryption/Decryption

[](#automatic-encryptiondecryption)

```
# Create user with encrypted field
curl -X POST -H "Auth-x: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","ssn":"123-45-6789"}' \
  http://localhost:8000/api/v1/users

# SSN is automatically encrypted in database
# SSN is automatically decrypted in API responses
```

📊 Advanced Querying
-------------------

[](#-advanced-querying)

### Pagination

[](#pagination)

```
# Get page 2 with 10 items per page
curl -H "Auth-x: Bearer TOKEN" \
  "http://localhost:8000/api/v1/users?page=2&limit=10"
```

### Search Across All Fields

[](#search-across-all-fields)

```
# Search for "john" across all searchable fields
curl -H "Auth-x: Bearer TOKEN" \
  "http://localhost:8000/api/v1/users?search=john"
```

### Column-Specific Search

[](#column-specific-search)

```
# Search by specific column
curl -H "Auth-x: Bearer TOKEN" \
  "http://localhost:8000/api/v1/users/search/email?q=gmail.com"
```

### Sorting

[](#sorting)

```
# Sort by name ascending
curl -H "Auth-x: Bearer TOKEN" \
  "http://localhost:8000/api/v1/users?sort=name&order=ASC"
```

### Combined Queries

[](#combined-queries)

```
# Complex query: search + pagination + sorting
curl -H "Auth-x: Bearer TOKEN" \
  "http://localhost:8000/api/v1/users?search=john&page=1&limit=5&sort=created_at&order=DESC"
```

### Response Format

[](#response-format)

```
{
  "success": true,
  "message": "Records retrieved successfully",
  "data": [
    {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com",
      "created_at": "2025-10-10 12:00:00"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 25,
    "pages": 3
  }
}
```

🌐 CORS Configuration
--------------------

[](#-cors-configuration)

Configure CORS policies dynamically via CLI.

### Interactive CORS Setup

[](#interactive-cors-setup)

```
flexiapi configure:cors
# Guides you through origins, methods, headers, and credentials
```

### Example CORS Configuration

[](#example-cors-configuration)

```
Origins: https://yourdomain.com, https://app.yourdomain.com
Methods: GET, POST, PUT, DELETE, OPTIONS
Headers: Content-Type, Authorization, Auth-x
Credentials: true
Max Age: 86400 seconds
```

🔧 CLI Commands
--------------

[](#-cli-commands)

### Core Commands

[](#core-commands)

```
flexiapi setup                    # Initial framework configuration
flexiapi create:endpoint    # Create new API endpoint
flexiapi update:endpoint    # Modify existing endpoint
flexiapi list:endpoints           # Show all endpoints
flexiapi configure:cors           # Configure CORS policy
flexiapi serve [--port=8000]      # Start development server
```

### Generation Commands

[](#generation-commands)

```
flexiapi generate:postman         # Generate Postman collection
flexiapi export:sql               # Export unified SQL schema
```

### Aliases

[](#aliases)

```
flexiapi create users    # Same as create:endpoint users
flexiapi update users    # Same as update:endpoint users
flexiapi list           # Same as list:endpoints
flexiapi cors           # Same as configure:cors
flexiapi serve          # Start development server
```

📁 Project Structure
-------------------

[](#-project-structure)

```
your-api/
├── config/
│   ├── config.php          # Database & app configuration
│   └── cors.php            # CORS policy settings
├── endpoints/
│   ├── UsersController.php # Generated endpoint controllers
│   └── usersRoutes.php     # Generated route definitions
├── sql/
│   ├── users.sql           # Individual table schemas
│   └── products.sql
├── exports/
│   └── FlexiAPI_Schema_Latest.sql  # Unified schema export
├── public/
│   └── index.php           # API entry point
├── storage/
│   ├── logs/               # Application logs
│   └── cache/              # Rate limiting cache
├── Procfile                # Heroku deployment config
├── .nixpacks.toml          # Railway/Nixpacks deployment config
├── app.json                # Heroku Button configuration
└── .platform.app.yaml     # Platform.sh deployment config

```

🔄 API Response Format
---------------------

[](#-api-response-format)

All API responses follow a consistent format:

### Success Response

[](#success-response)

```
{
  "success": true,
  "message": "Operation completed successfully",
  "data": {
    "id": 1,
    "name": "John Doe"
  }
}
```

### Error Response

[](#error-response)

```
{
  "success": false,
  "message": "Validation failed",
  "errors": {
    "email": "Email is required"
  }
}
```

### Paginated Response

[](#paginated-response)

```
{
  "success": true,
  "message": "Records retrieved successfully",
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 100,
    "pages": 10
  }
}
```

🛠️ Development Workflow
-----------------------

[](#️-development-workflow)

### 1. Create New Feature Endpoint

[](#1-create-new-feature-endpoint)

```
flexiapi create:endpoint products
# Define columns: name, price, description
# Configure encryption for sensitive pricing data
```

### 2. Update Existing Endpoint

[](#2-update-existing-endpoint)

```
flexiapi update:endpoint products
# Add columns, modify types, configure encryption
```

### 3. Test API Endpoints

[](#3-test-api-endpoints)

```
flexiapi generate:postman
# Creates ready-to-use Postman collection
```

### 4. Export Database Schema

[](#4-export-database-schema)

```
flexiapi export:sql
# Creates unified SQL file for deployment
```

🚀 Deployment
------------

[](#-deployment)

### Platform as a Service (PaaS) - One-Click Deploy

[](#platform-as-a-service-paas---one-click-deploy)

#### Heroku

[](#heroku)

[![Deploy to Heroku](https://camo.githubusercontent.com/4eea217b02568cc464752586784ae247b22e99fea520a15b6f919b15934ba8ca/68747470733a2f2f7777772e6865726f6b7563646e2e636f6d2f6465706c6f792f627574746f6e2e737667)](https://heroku.com/deploy)

FlexiAPI includes a `Procfile` for seamless Heroku deployment:

```
web: php -S 0.0.0.0:$PORT -t public

```

#### Railway

[](#railway)

FlexiAPI includes `.nixpacks.toml` for Railway's Nixpacks builder:

```
[start]
cmd = "php -S 0.0.0.0:8080 -t /app/public"
```

Deploy steps:

```
# Connect your GitHub repo to Railway
# Railway auto-detects .nixpacks.toml and Procfile
# Deploys automatically
```

#### Platform.sh

[](#platformsh)

Includes `.platform.app.yaml` for Platform.sh deployment.

### Traditional Server Setup

[](#traditional-server-setup)

1. Create new project:

```
composer create-project uptura-official/flexiapi my-api-project
cd my-api-project
```

2. Configure production database:

```
flexiapi setup
# Enter production database credentials
```

3. Create endpoints and export schema:

```
flexiapi create users
flexiapi export:sql
```

4. Upload to server and import database:

```
mysql -u user -p database
