Skip to main content
Lyger is a high-performance PHP framework with Rust FFI integration that combines the simplicity of PHP with the speed of Rust. This guide will walk you through installing and configuring Lyger on your system.

Requirements

Before installing Lyger, ensure your system meets these requirements:

PHP 8.0 or higher

Lyger requires PHP 8.0 or later with modern PHP features

FFI Extension

The FFI extension must be enabled for Rust integration

PHP Version Check

php -v
You should see PHP 8.0 or higher in the output.

Installation Steps

1

Clone the Repository

Clone the Lyger Framework repository from GitHub:
git clone https://github.com/betoalien/Lyger-PHP-Framework.git
cd Lyger-framework
2

Enable FFI Extension

Create a php.ini file in the root directory of your project:
php.ini
[PHP]
ffi.enable = 1
The FFI extension is required for Lyger’s Rust integration, which provides high-performance features like Always-Alive server mode and zero-copy database operations.
3

Install Dependencies

Install PHP dependencies using Composer:
composer install
If you don’t have Composer installed globally, Lyger includes a local copy:
php composer.phar install
4

Run the Interactive Installer (Optional)

Lyger includes a Zero-Bloat installer that configures your stack and removes unused components:
php rawr install
The installer will guide you through:
  • Architecture: API Headless or Full-Stack
  • Frontend: Vue.js, React, or Svelte (if Full-Stack)
  • Database: PostgreSQL, MySQL, or SQLite
  • Authentication: Lyger Session, JWT, or None
The installer removes unused files to keep your project lean. This is a one-time setup that cannot be undone.
5

Verify Installation

Start the development server:
php rawr serve
Visit http://localhost:8000 in your browser. You should see the Lyger welcome page.

Configuration

Environment Setup

Copy the example environment file and configure your settings:
cp .env.example .env
Edit the .env file to configure your application:
# Application
APP_NAME="Lyger Framework"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000

# Database
DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

Supported Databases

Lyger supports multiple database engines through its Rust-powered query builder:
  • SQLite - Best for development and small applications
  • PostgreSQL - Best for complex queries and analytics
  • MySQL - Best for write-heavy CRUD applications
  • MariaDB - Compatible with MySQL configuration
  • MongoDB - NoSQL document database

Additional Configuration

The .env file includes other configuration options:
.env
# API Configuration
API_PREFIX=api
API_VERSION=v1

# Authentication
AUTH_TOKEN=your-secret-token-here
TOKEN_EXPIRY=3600

# CORS Configuration
CORS_ALLOWED_ORIGINS=*
CORS_ALLOWED_METHODS=GET,POST,PUT,DELETE,OPTIONS
CORS_ALLOWED_HEADERS=Content-Type,Authorization,X-Requested-With

# Rate Limiting
RATE_LIMIT_MAX_ATTEMPTS=60
RATE_LIMIT_DECAY_SECONDS=60

# Rust FFI
FFI_LIB_PATH=libraries/liblyger.dylib

# Logging
LOG_LEVEL=debug
LOG_FILE=logs/lyger.log

Directory Structure

After installation, your Lyger project will have the following structure:
Lyger-framework/
├── App/
│   ├── Controllers/       # Application controllers
│   └── Models/           # Database models
├── Lyger/                # Framework core
│   ├── Routing/          # Router and route handling
│   ├── Http/             # Request and Response
│   ├── Database/         # ORM and query builder
│   └── ...
├── public/               # Web server document root
│   └── index.php         # Application entry point
├── routes/
│   └── web.php          # Route definitions
├── database/
│   └── migrations/      # Database migrations
├── vendor/              # Composer dependencies
├── .env                 # Environment configuration
├── composer.json        # Composer configuration
├── php.ini             # PHP configuration
└── rawr                # CLI tool

Server Modes

Lyger offers two server modes:

PHP Built-in Server (Default)

php rawr serve

# Custom port
php rawr serve --port=8080
This mode uses PHP’s built-in development server.

Legacy Mode

php rawr serve:php
Alternative command for the PHP built-in server.
The Always-Alive server mode with Rust HTTP server is available when the FFI extension is enabled and the Rust library is compiled.

Troubleshooting

FFI Extension Not Found

If you see an error about the FFI extension:
  1. Check if FFI is available: php -m | grep FFI
  2. If not available, install it via your package manager:
    • Ubuntu/Debian: sudo apt-get install php-ffi
    • macOS (Homebrew): FFI is included in PHP 8.0+
  3. Ensure ffi.enable = 1 is in your php.ini

Composer Install Fails

If Composer installation fails:
# Use the bundled Composer
php composer.phar install

# Or update Composer
php composer.phar self-update

Port Already in Use

If port 8000 is already in use:
php rawr serve --port=3000

Next Steps

Now that you have Lyger installed, you’re ready to build your first application:

Quickstart Guide

Build your first Lyger application

Routing

Learn about routing and controllers

Database

Work with models and migrations

CLI Commands

Explore the Rawr CLI tool