PHPackages                             jabranr/lassi - 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. jabranr/lassi

ActiveLibrary[Framework](/categories/framework)

jabranr/lassi
=============

PHP boilerplate for quick projects based on Slim and Eloquent

0.0.5(9y ago)58766[2 issues](https://github.com/jabranr/lassi/issues)[2 PRs](https://github.com/jabranr/lassi/pulls)MIT LicensePHPPHP &gt;=5.5.9

Since Oct 2Pushed 2y ago5 watchersCompare

[ Source](https://github.com/jabranr/lassi)[ Packagist](https://packagist.org/packages/jabranr/lassi)[ RSS](/packages/jabranr-lassi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Lassi (Not maintained anymore)
==============================

[](#lassi-not-maintained-anymore)

PHP boilerplate for quick projects using Slim Framework and Eloquent database.

[![Lassi](https://cloud.githubusercontent.com/assets/2131246/10229125/66ff122e-686e-11e5-9351-d6e840c1917b.png)](https://cloud.githubusercontent.com/assets/2131246/10229125/66ff122e-686e-11e5-9351-d6e840c1917b.png)

Lassi is a small PHP boilerplate to use [Slim Framework](http://www.slimframework.com/) with [Eloquent database](https://github.com/illuminate/database) components – enabling you to quickly start building your PHP projects with an MVC design pattern and datastore in no time.

> Warnning: Project is in alpha status. For more see [issues tracker](https://github.com/jabranr/lassi/issues).

Installation and Setup
======================

[](#installation-and-setup)

Install with [composer](http://getcomposer.org) `create-project` command. This will install Lassi and all of it's dependencies i.e. Slim Framework and Eloquent database.

```
$ composer create-project jabranr/lassi
```

#### Configuration

[](#configuration)

Lassi uses `.env` files to setup it's configuration. There is such sample file `.sample.env` packaged with it. Lassi will look for `.dev.env`, `.dist.env` or `.env` respectively at the run time or throws `NotFoundException`.

#### Charset &amp; Collation

[](#charset--collation)

By default `.sample.env` file has charset and collation configurations set to `UTF-8 mb4` to support various type of characters encoding. You can update it with your own choice, of course. For more on best encoding practices, read [Working with UTF-8 at PHP: The Right Way](http://www.phptherightway.com/#php_and_utf8).

#### Routing

[](#routing)

Use the `routes.php` in root directory to setup routes. You would setup routes as you do in Slim Framework. Afterall it is using Slim Framework in background. For more on setting up routes, see [Slim Framework Documentation](http://docs.slimframework.com/routing/overview/).

#### Structure

[](#structure)

**Controllers:** The Controllers are to be saved in `controller/` directory. All Controllers must extend `Lassi\App\Controller` base controller class and pass the `LassiLassi` instance to its constructor using `LassiLassi::getInstance()` method. You can also add relevant Model(s) using `useModel(string|array $model)` method. You can name the controller as you like but do keep up with best practices.

**Models:** All relevant Models are saved in `model/` directory and must extend the `Illuminate\Database\Eloquent\Model` class. You would use models as you do in Eloquent. For more on setting up models and use other options, see [Eloquent database quick start guide](https://github.com/illuminate/database).

There is an example controller and model in mentioned directories for you to get started with.

**Views:** All views/templates are saved in `view/` directory.

**Assets:** All assets are saved in `public/` directory.

#### Example:

[](#example)

**Create project**

Create a project using Composer `create-project` command and `cd` into project directory.

```
$ composer create-project jabranr/lassi
$ cd path/to/lassi
```

**Update configuration**

Update configurations as required in `.dev.env` file.

**Start server**

Start the PHP built-in server and navigate browser to `http://localhost:8000`.

```
$ php -S localhost:8000 -t public
```

**Setup routes**

- Add `hello` route

Add a new route `hello` in `routes.php` and try it in browser by navigating to `http://localhost:8000/hello`

```
$app->get('/hello', function() use ($app) {
	$app->response->write('Hello World');
});
```

- Add `goodbye` route

Add a new route `goodbye` in `routes.php` to render a template. Create a new file `goodbye.php` with basic HTML and save in `/view` directory.

```
>

		Lassi goodbye template

		Goodbye!

```

Call this template to render directly from a route's definition or by using a `Controller`.

**Directly from a route's definition**

```
$app->get('/goodbye', function() use ($app) {
	return $app->render('goodbye.php');
});
```

**Using a controller**

Add a new public method `goodbye()` to `WelcomeController.php` in `/controller` directory.

```
class WelcomeController extends Lassi\App\Controller {
	...

	public function goodbye() {
		return $this->app->render('goodbye.php');
	}
}
```

Modify the route's definition to use controller.

```
$app->get('/goodbye', 'Lassi\Controller\WelcomeController:goodbye');
```

For complete reference, see [Slim Framework documentation](http://docs.slimframework.com/)

#### Using Eloquent

[](#using-eloquent)

To setup any database connection fill in the required information in relevant `*.env` file.

**Setup SQLite database**

At minimum it requires an absolute URL to SQLite file and `db_driver` value set to `sqlite`.

```
db_driver	 = sqlite				(Required)
db_name		 = path/to/foo.sqlite	(Required)
db_prefix	 = lassi_				(Optional)
```

**Setup MySQL, SQL, MSSQL or Sybase database**

```
db_driver	 = mysql		(Required)
db_host		 = localhost	(Required)
db_name		 = lassi		(Required)
db_username	 = root			(Required)
db_password	 = p@ssword		(Required)
db_prefix	 = lassi_		(Optional)
```

Using Eloquent is straight forward after a connection is established. To learn more on how to use Eloquent, see [Official Eloquent Documentation](http://laravel.com/docs/5.1/eloquent).

**Create a table using Eloquent**

You can use the `Illuminate\Database\Capsule\Manager::schema()` method to setup database migrations. Here is an example to create a `lassi_users` table.

```
class WelcomeController extends Lassi\App\Controller {
	...

	public function makeUserTable() {
		Illuminate\Database\Capsule\Manager::schema()->create('users', function($table) {
			$table->increments('id');
			$table->string('name');
			$table->string('email')->unique();
			$table->timestamps();
		});
	}
}
```

Calling `Lassi\Controller\WelcomeController->makeUserTable()` will create a new table in database.

A model can be added to a controller using `useModel()` method in controller's constructor i.e.

```
class WelcomeController extends Lassi\App\Controller {
	public function __construct() {
		parent::__construct(LassiLassi::getInstance());
		$this->useModel('user');
	}
}
```

or it can directly be accessed using `Lassi\Model` namespace i.e.

```
class WelcomeController extends Lassi\App\Controller {
	...

	public function create() {
		$user = new Lassi\Model\User;
		$user->name = 'Jabran Rafique';
		$user->email = 'hello@jabran.me';
		$user->save();
	}
}
```

Getting info from Eloquent and pass it to template.

```
class WelcomeController extends Lassi\App\Controller {
	...

	public function goodbye() {
		$user = Lassi\Model\User::find(1);
		return $this->app->render('goodbye.php', array('user' => $user));
	}
}
```

Issue tracking
==============

[](#issue-tracking)

Please report any issues to [repository issue tracker](https://github.com/jabranr/lassi/issues).

Contribution
============

[](#contribution)

I would love to get some help and extend this boilerplate further so it can be useful to a vast audience. If you think you can improve the boilerplate then fork the project and submit pull request at your convenience.

License
=======

[](#license)

MIT License © 2015 – 2016 Jabran Rafique ([@jabranr](https://twitter.com/jabranr)) | [Contributors](https://github.com/jabranr/lassi/graphs/contributors)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~130 days

Total

4

Last Release

3491d ago

PHP version history (2 changes)0.0.2PHP &gt;=5.4.0

0.0.5PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/bac8f15aa523ecd5653b9eee1649ca5f00c562f2b0f84a595d58d79e409aec66?d=identicon)[jabranr](/maintainers/jabranr)

---

Top Contributors

[![jabranr](https://avatars.githubusercontent.com/u/2131246?v=4)](https://github.com/jabranr "jabranr (32 commits)")[![Art4](https://avatars.githubusercontent.com/u/2162994?v=4)](https://github.com/Art4 "Art4 (12 commits)")[![iGusev](https://avatars.githubusercontent.com/u/1555767?v=4)](https://github.com/iGusev "iGusev (4 commits)")

---

Tags

eloquent-databasephp-boilerplateslim-framework

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jabranr-lassi/health.svg)

```
[![Health](https://phpackages.com/badges/jabranr-lassi/health.svg)](https://phpackages.com/packages/jabranr-lassi)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)[vesp/core

Vesp core library to make backend simple

243.8k5](/packages/vesp-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
