Prerequisites
Before you begin, make sure you have:- Completed the Installation guide
- Lyger framework installed and running
- Basic knowledge of PHP
Your First Route
Lyger makes it easy to define routes. Routes are defined in theroutes/web.php file.
1
Understand the Default Route
When you first install Lyger, Start your server and test it:Visit
routes/web.php contains a default route:routes/web.php
http://localhost:8000 - you should see the JSON response.2
Add a Simple Route
Let’s add a new route. Open Visit
routes/web.php and add:routes/web.php
http://localhost:8000/hello to see your new route in action!3
Add Route Parameters
Routes can accept parameters using curly braces:Try it:
routes/web.php
http://localhost:8000/greet/AliceHTTP Methods
Lyger supports all standard HTTP methods:routes/web.php
Creating Your First Controller
Controllers help organize your application logic. Let’s create one using the Rawr CLI.1
Generate a Controller
Use the This creates
make:controller command:App/Controllers/UserController.php:App/Controllers/UserController.php
2
Add Controller Methods
Edit the controller to add more methods:
App/Controllers/UserController.php
3
Register Controller Routes
Update
routes/web.php to use the controller:routes/web.php
Controllers are automatically resolved from the container. The first parameter is always the
Request object, followed by route parameters.Working with Requests
TheRequest object provides access to all request data:
Response Types
Lyger provides several response types:Building a Complete Example
Let’s build a simple task management API to demonstrate Lyger’s capabilities.1
Create the Controller
App/Controllers/TaskController.php:App/Controllers/TaskController.php
2
Define the Routes
Add routes to
routes/web.php:routes/web.php
3
Test Your API
Start the server if it’s not running:Test your endpoints:
CLI Commands Reference
Lyger includes a powerful CLI tool calledrawr. Here are the essential commands:
Understanding the Request Flow
Here’s how Lyger processes requests:public/index.php:
public/index.php
Next Steps
Congratulations! You’ve built your first Lyger application. Here’s what to explore next:Database & ORM
Learn about Eloquent-style models and migrations
Middleware
Add middleware to your routes
CLI Commands
Explore scaffold commands
Authentication
Secure your application
Pro Tip: Lyger combines PHP simplicity with Rust performance. As you build, you’ll experience the framework’s high-performance features like the Rust-powered query builder and Always-Alive server mode.
Example Projects
Want to see Lyger in action? Check out these example projects:- Dental Clinic Demo - A full-featured application showcasing Lyger’s capabilities
Getting Help
- GitHub Issues: Report bugs or request features
- Documentation: Explore the rest of this documentation
- Source Code: Study the framework source in the
Lyger/directory