Introduction to Lithe

Welcome to Lithe, a PHP framework that offers simplicity, flexibility, and expressiveness for developers. Build everything from small applications to complex web platforms quickly and effectively with Lithe.

What is Lithe?

Lithe is more than just a PHP framework; it's the key to unlocking your creativity in web development! With an unwavering focus on simplicity, flexibility, and efficiency, Lithe draws inspiration from the iconic Express.js to empower developers in creating web applications quickly and effectively.

The word "lithe" evokes flexibility and agility, capturing the essence of what we aim to provide. With Lithe, you not only build fast and robust solutions but also adapt easily to the ever-changing demands of your projects.

See how simple it is to create a route that fetches a user by ID:

get('/users/:id', function ($req, $res) {
    $id = $req->param('id');
    $user = User::find($id);
    
    if (!$user) {
        return $res->status(404)->json([
            'error' => 'User not found'
        ]);
    } 

    return view('profile', compact('user'));
});

In this example, when accessing the route /users/:id, Lithe retrieves the corresponding user and displays their profile. If the user is not found, a 404 error is returned, demonstrating the robustness of the framework.


Simple and Flexible Routing

With Lithe, defining routes is as easy as breathing! Use functions like get(), post(), among others, to create routes that respond to different types of HTTP requests in an intuitive and expressive manner:

get('/hello/:name', function ($req, $res) {
    $res->send('Hello, ' . $req->param('name'));
});

Discover how routing in Lithe can simplify your development and give you total control over your application's routes.


Powerful Middleware

Imagine having a robust line of defense in your applications! In Lithe, middleware allows you to inspect, filter, and manipulate HTTP requests before they reach their final routes. This means you can add functionalities like authentication and logging in a modular and reusable way.

Here's how easy it is to define and use a middleware:

// Middleware to check if the token is valid
$EnsureTokenIsValid = function ($req, $res, $next) {
    $token = $req->param('token');

    if ($token !== 'my-secret-token') {
        return $res->send('Invalid token.');
    }

    $next();
};

// Protected route using the middleware
get('/protected/:token', $EnsureTokenIsValid, function ($req, $res) {
    $res->send('Protected content accessed successfully!');
});

Learn more about how middlewares in Lithe can transform the way you develop and maintain your applications.


Database Integration

Connect to your data effortlessly! Lithe supports popular ORMs like Eloquent and native PHP drivers such as MySQLi and PDO. Configure your connections in the .env file and manage schema migrations with ease.

DB_CONNECTION_METHOD=eloquent
DB_CONNECTION=mysql
DB_HOST=localhost
DB_NAME=lithe
DB_USERNAME=root
DB_PASSWORD=
DB_SHOULD_INITIATE=true

Discover more about database integration in Lithe and see how easy it is to manage your data.


Database Migrations

Maintain data consistency and integrity in your applications with automated migrations! With Lithe, creating and applying migrations is quick and easy, using any ORM or database driver interface.

php line make:migration CreateUsersTable --template=eloquent
php line migrate

Learn more about migrations in Lithe and make the most of this functionality to develop robust and scalable applications.


Ready to Revolutionize Your Development?

With Lithe, you have at your fingertips a framework that combines power and simplicity, ideal for projects of all sizes and complexities. Explore the complete documentation and start building your PHP applications in a structured and efficient way.

Get ready to transform your development approach with Lithe!