PHPackages                             xsanisty/slim-starter - 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. xsanisty/slim-starter

ActiveLibrary[Framework](/categories/framework)

xsanisty/slim-starter
=====================

Slim Framework in MVC environment with Eloquent as database provider and Twig as template engine

1.0.0-alpha(11y ago)2882.1k69[12 issues](https://github.com/xsanisty/SlimStarter/issues)[2 PRs](https://github.com/xsanisty/SlimStarter/pulls)MITJavaScriptPHP &gt;= 5.3.0

Since May 26Pushed 7y ago28 watchersCompare

[ Source](https://github.com/xsanisty/SlimStarter)[ Packagist](https://packagist.org/packages/xsanisty/slim-starter)[ RSS](/packages/xsanisty-slim-starter/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (8)Versions (3)Used By (0)

SlimStarter
===========

[](#slimstarter)

SlimStarter is a bootstrap application built with Slim Framework in MVC architecture, with Laravel's Eloquent as database provider (Model) and Twig as template engine (View).

Additional package is Sentry as authentication provider and Slim-facade which provide easy access to underlying Slim API with static interface like Laravel syntax (built based on Laravel's Facade).

Showcase
--------

[](#showcase)

You can test SlimStarter in live site by visiting here : (shared hosting) (pagodabox)

with username `admin@admin.com` and password `password`.

Installation
------------

[](#installation)

> You can now install SlimStarter on pagodabox via App Cafe

#### 1 Manual Install

[](#1-manual-install)

You can manually install SlimStarter by cloning this repo or download the zip file from this repo, and run `composer install`.

```
$git clone https://github.com/xsanisty/SlimStarter.git .
$composer install

```

#### 2 Install via `composer create-project`

[](#2-install-via-composer-create-project)

Alternatively, you can use `composer create-project` to install SlimStarter without downloading zip or cloning this repo.

```
composer create-project xsanisty/slim-starter --stability="dev"

```

#### 3 Setup Permission

[](#3-setup-permission)

After composer finished install the dependencies, you need to change file and folder permission.

```
chmod -R 777 app/storage/
chmod 666 app/config/database.php

```

#### 4 Configure and Setup Database

[](#4-configure-and-setup-database)

You can now access the installer by pointing install.php in your browser

```
http://localhost/path/to/SlimStarter/public/install.php

```

Configuration
-------------

[](#configuration)

Configuration file of SlimStarter located in `app/config`, edit the database.php, cookie.php and other to match your need

Routing
-------

[](#routing)

Routing configuration is located in `app/routes.php`, it use Route facade to access underlying Slim router. If you prefer the 'Slim' way, you can use $app to access Slim instance

Route to closure

```
Route::get('/', function(){
    View::display('welcome.twig');
});

/** the Slim way */
$app->get('/', function() use ($app){
    $app->view->display('welcome.twig');
});
```

Route to controller method

```
/** get method */
Route::get('/', 'SomeController:someMethod');

/** post method */
Route::post('/post', 'PostController:create');

/** put method */
Route::put('/post/:id', 'PostController:update');

/** delete method */
Route::delete('/post/:id', 'PostController:destroy');
```

Route Middleware

```
/** route middleware */
Route::get('/admin', function(){
    //route middleware to check user login or redirect
}, 'AdminController:index');
```

Route group

```
/** Route group to book resource */
Route::group('/book', function(){
    Route::get('/', 'BookController:index'); // GET /book
    Route::post('/', 'BookController:store'); // POST /book
    Route::get('/create', 'BookController:create'); // Create form of /book
    Route::get('/:id', 'BookController:show'); // GET /book/:id
    Route::get('/:id/edit', 'BookController:edit'); // GET /book/:id/edit
    Route::put('/:id', 'BookController:update'); // PUT /book/:id
    Route::delete('/:id', 'BookController:destroy'); // DELETE /book/:id
});
```

Route Resource this will have same effect on route group above like Laravel Route::resource

```
/** Route to book resource */
Route::resource('/book', 'BookController');
```

RouteController

```
/** Route to book resource */
Route::controller('/book', 'BookController');

/**
 * GET /book will be mapped to BookController:getIndex
 * POST /book will be mapped to BookController:postIndex
 * [METHOD] /book/[path] will be mapped to BookController:methodPath
 */
```

Model
-----

[](#model)

Models are located in `app/models` directory, since Eloquent is used as database provider, you can write model like you write model for Laravel, for complete documentation about eloquent, please refer to

file : app/models/Book.php

```
class Book Extends Model{}
```

> Note: Eloquent has some limitations due to dependency to some Laravel's and Symfony's components which is not included, such as `remember()`, `paginate`, and validation method, which is depend on `Illuminate\Cache`, `Illuminate\Filesystem`, `Symfony\Finder`, etc.

Controller
----------

[](#controller)

Controllers are located in `app/controllers` directory, you may extends the BaseController to get access to predefined helper. You can also place your controller in namespace to group your controller.

file : app/controllers/HomeController.php

```
Class HomeController extends BaseController{

    public function welcome(){
        $this->data['title'] = 'Some title';
        View::display('welcome.twig', $this->data);
    }
}
```

Controller helper
-----------------

[](#controller-helper)

### Get reference to Slim instance

[](#get-reference-to-slim-instance)

You can access Slim instance inside your controller by accessing $app property

```
$this->app; //reference to Slim instance
```

### Loading javascript assets or CSS assets

[](#loading-javascript-assets-or-css-assets)

SlimStarter shipped with default master template with js and css asset already in place, to load your own js or css file you can use `loadJs` or `loadCss` , `removeJs` or `removeCss` to remove js or css, `resetJs` or `resetCss`to remove all queued js or css file.

```
/**
 * load local js file located in public/assets/js/application.js
 * by default, it will be placed in the last list,
 * to modify it, use position option in second parameter
 * array(
 *      'position' => 'last|first|after:file|before:file'
 * )
 */
$this->loadJs('application.js', ['position' => 'after:jquery.js'])

/**
 * load external js file, eg: js in CDN
 * use location option in second parameter
 * array(
 *      'location' => 'internal|external'
 * )
 */
$this->loadJs('http://code.jquery.com/jquery-1.11.0.min.js', ['location' => 'external']);

/** remove js file from the list */
$this->removeJs('user.js');

/** reset js queue, no js file will be loaded */
$this->resetJs();

/** load local css file located in public/assets/css/style.css */
$this->loadCss('style.css')

/** load external css file, eg: js in CDN */
$this->loadCss('//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['location' => 'external']);

/**
```

### Publish PHP variable to javascript

[](#publish-php-variable-to-javascript)

You can also publish PHP variable to make it accessible via javascript (must extends master.twig)

```
/** publish the variable */
$this->publish('user', User::find(1)->toArray());

/** remove the variable */
$this->unpublish('user');
```

the user variable will be accessible in 'global' namespace

```
console.log(global.user);
```

### Default variable available in template

[](#default-variable-available-in-template)

View
----

[](#view)

Views file are located in `app/views` directory in twig format, there is master.twig with 'body' block as default master template shipped with SlimStarer that will provide default access to published js variable.

For detailed Twig documentation, please refer to

file : app/views/welcome.twig

```
{% extends 'master.twig' %}
{% block body %}
    Welcome to SlimStarter
{% endblock %}
```

### Rendering view inside controller

[](#rendering-view-inside-controller)

If your controller extends the BaseController class, you will have access to $data property which will be the placeholder for all view's data.

```
View::display('welcome.twig', $this->data);
```

Hooks and Middlewares
---------------------

[](#hooks-and-middlewares)

You can still hook the Slim event, or registering Middleware to Slim instance in `app/bootstrap/app.php`, Slim instance is accessible in `$app` variable.

```
$app->hook('slim.before.route', function(){
    //do your hook
});

$app->add(new SomeActionMiddleware());
```

You can write your own middleware class in `app/middlewares` directory.

file : app/middlewares/SomeActionMiddleware.php

```
class SomeActionMiddleware extends Middleware
{
    public function call()
    {
        // Get reference to application
        $app = $this->app;

        // Run inner middleware and application
        $this->next->call();

        // do your stuff
    }
}
```

In case autoloader cannot resolve your classes, do `composer dump-autoload` so composer can resolve your class location

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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

Unknown

Total

1

Last Release

4368d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38407a758e03620c0811456dc2b3a6c4dc43cd0d09d55f4c9b04e983ebab3a14?d=identicon)[xsanisty](/maintainers/xsanisty)

---

Top Contributors

[![ikhsan017](https://avatars.githubusercontent.com/u/1480166?v=4)](https://github.com/ikhsan017 "ikhsan017 (109 commits)")[![ardianta](https://avatars.githubusercontent.com/u/4420029?v=4)](https://github.com/ardianta "ardianta (1 commits)")[![nasaorc](https://avatars.githubusercontent.com/u/3199251?v=4)](https://github.com/nasaorc "nasaorc (1 commits)")

---

Tags

frameworktwigslimeloquentmvcslim-starter

### Embed Badge

![Health badge](/badges/xsanisty-slim-starter/health.svg)

```
[![Health](https://phpackages.com/badges/xsanisty-slim-starter/health.svg)](https://phpackages.com/packages/xsanisty-slim-starter)
```

###  Alternatives

[slim/twig-view

Slim Framework 4 view helper built on top of the Twig 3 templating component

3708.0M210](/packages/slim-twig-view)

PHPackages © 2026

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