Skip to main content
This guide will help you create your first Lyger application. We’ll build a simple API with a “Hello World” endpoint and explore the core concepts of the framework.

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 the routes/web.php file.
1

Understand the Default Route

When you first install Lyger, routes/web.php contains a default route:
routes/web.php
Start your server and test it:
Visit http://localhost:8000 - you should see the JSON response.
2

Add a Simple Route

Let’s add a new route. Open routes/web.php and add:
routes/web.php
Visit http://localhost:8000/hello to see your new route in action!
3

Add Route Parameters

Routes can accept parameters using curly braces:
routes/web.php
Try it: http://localhost:8000/greet/Alice

HTTP 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 make:controller command:
This creates 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

The Request 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

Edit 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 called rawr. Here are the essential commands:

Understanding the Request Flow

Here’s how Lyger processes requests:
The application bootstrap happens in 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:

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