PHPackages                             lime/lime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. lime/lime

ActiveLibrary[Framework](/categories/framework)

lime/lime
=========

The PHP micro-framework

1.0.0(10y ago)20012123[9 issues](https://github.com/aheinze/Lime/issues)[2 PRs](https://github.com/aheinze/Lime/pulls)MITPHPPHP &gt;=5.4.2

Since Aug 28Pushed 6y ago23 watchersCompare

[ Source](https://github.com/aheinze/Lime)[ Packagist](https://packagist.org/packages/lime/lime)[ Docs](https://github.com/aheinze/Lime)[ RSS](/packages/lime-lime/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Lime
====

[](#lime)

Lime is a micro web framework for quickly creating web applications in PHP with minimal effort.

```
$app = new Lime\App();

$app->bind("/", function() {
    return "Hello World!";
});

$app->run();
```

Just include one file (~ 35KB) and you're ready to go.

Routes
------

[](#routes)

In Lime, a route is an HTTP method paired with a URL-matching pattern. Each route is associated with a block:

```
$app->get("/", function() {
    return "This was a GET request...";
});

$app->post("/", function() {
    return "This was a POST request...";
});

$app->bind("/", function() {
    return "This was a GET or POST request...";
});
```

Routes are matched in the order they are defined. The first route that matches the request is invoked.

Route patterns may include named parameters, accessible via the params hash:

```
$app->get("/posts/:id/:name", function($params) {
    return $params["id"].'-'.$params["name"];
});

$app->post("/misc/*", function($params) {
    return $params[":splat"];
});

$app->bind("#/pages/(about|contact)#", function($params) {
    return implode("\n", $params[":captures"]);
});
```

Conditions
----------

[](#conditions)

Routes may include a variety of matching conditions, such as the user agent:

```
$app->get("/foo", function() {
    // GET request...
}, strpos($_SERVER['HTTP_USER_AGENT'], "Safari")!==false);
```

Create Urls
-----------

[](#create-urls)

```
$route = $app->routeUrl('/my/route');
$url   = $app->baseUrl('/assets/script.js');
```

Templates
---------

[](#templates)

In general you can utilize any template engine you want. Lime provides a simple template engine:

```
$app->get("/", function() {

        $data = array(
            "name"  => 'Frank',
            "title" => 'Template demo'
        );

        return $this->render("views/view.php with views/layout.php", $data);
});
```

views/view.php:

```

    Hello .

```

views/layout.php:

```
DOCTYPE HTML>
