serve command starts a local development server for your Lyger application.
Syntax
Specify a custom port number for the server
Basic Usage
Start the server on the default port (8000):Custom Port
Start the server on a custom port:The server will be accessible at
http://localhost:8080Server 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, orliblyger.dll)
Server Configuration
PHP Configuration
Create aphp.ini file in your project root for custom PHP settings:
php.ini
rawr (lines 138-150)
Document Root
The server serves files from thepublic/ directory:
Health Check Endpoints
When using Always-Alive mode, Lyger provides built-in health check endpoints:/api/health
Check server status and memory usage:/api/info
Get server information:Stopping the Server
PressCtrl+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:Permission Denied
Ensure thepublic/ directory has proper permissions:
FFI Not Available
If you see FFI-related warnings, enable it inphp.ini:
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