Skip to main content
The serve command starts a local development server for your Lyger application.

Syntax

integer
default:"8000"
Specify a custom port number for the server

Basic Usage

Start the server on the default port (8000):
Output:

Custom Port

Start the server on a custom port:
The server will be accessible at http://localhost:8080

Server Modes

Lyger supports two server modes:

1. PHP Built-in Server (Default)

The default mode uses PHP’s built-in development server:
This mode is perfect for local development and testing. It automatically serves files from the public/ directory.

2. Always-Alive Mode (Rust + FFI)

For production-like performance during development, Lyger can use the Rust HTTP server via FFI:
Always-Alive mode requires:
  • FFI extension enabled in php.ini
  • Rust library compiled (liblyger.so, liblyger.dylib, or liblyger.dll)

Server Configuration

PHP Configuration

Create a php.ini file in your project root for custom PHP settings:
php.ini
The server automatically loads this configuration:
rawr (lines 138-150)

Document Root

The server serves files from the public/ directory:

Health Check Endpoints

When using Always-Alive mode, Lyger provides built-in health check endpoints:

/api/health

Check server status and memory usage:
Response:

/api/info

Get server information:
Response:

Stopping the Server

Press Ctrl+C in the terminal to stop the server:

Common Use Cases

Development with Hot Reload

For frontend development with live reloading:

Multiple Projects

Run multiple Lyger projects simultaneously using different ports:

Testing API Endpoints

Start the server and test your API:

Troubleshooting

Port Already in Use

If port 8000 is already in use:
Or find and kill the process using the port:

Permission Denied

Ensure the public/ directory has proper permissions:

FFI Not Available

If you see FFI-related warnings, enable it in php.ini:
Then restart the server.

Performance Notes

The PHP built-in server is single-threaded and intended for development only. For production, use:
  • Nginx + PHP-FPM
  • Apache + mod_php
  • Caddy with PHP FastCGI

Next Steps

Make Controller

Create controllers to handle requests

Routing

Define routes for your application

Configuration

Configure your application settings

Deployment

Deploy to production