PHPackages                             scorninpc/slim-mvc-skel - 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. scorninpc/slim-mvc-skel

ActiveLibrary[Framework](/categories/framework)

scorninpc/slim-mvc-skel
=======================

Skeleton of Slim Framework 4 with Smarty

1.0.0(4y ago)041[1 issues](https://github.com/scorninpc/slim-mvc-skel/issues)MITPHP

Since Apr 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/scorninpc/slim-mvc-skel)[ Packagist](https://packagist.org/packages/scorninpc/slim-mvc-skel)[ RSS](/packages/scorninpc-slim-mvc-skel/feed)WikiDiscussions main Synced today

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

[![Version](https://camo.githubusercontent.com/adf7ee38f3e0600bd7ecff347769a1ac320b8cdea068c289b0d64ea90e9b3822/687474703a2f2f706f7365722e707567782e6f72672f73636f726e696e70632f736c696d2d6d76632d736b656c2f76657273696f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/scorninpc/slim-mvc-skel)[![Total Downloads](https://camo.githubusercontent.com/b5db2e1db0c69ec9cdf4baa60cc4b1c2f15d583adde6c46056ad57e9a73c2320/687474703a2f2f706f7365722e707567782e6f72672f73636f726e696e70632f736c696d2d6d76632f646f776e6c6f6164733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/scorninpc/slim-mvc-skel)[![GitHub](https://camo.githubusercontent.com/c8a53319418a16fd69e9e26c60af383825f82c136618ace339725f39fd7fd919/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73636f726e696e70632f736c696d2d6d76632d736b656c)](https://camo.githubusercontent.com/c8a53319418a16fd69e9e26c60af383825f82c136618ace339725f39fd7fd919/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73636f726e696e70632f736c696d2d6d76632d736b656c)[![GitHub issues](https://camo.githubusercontent.com/3cddad907c162fdcb64b233cdc732a4a0eb3ff3d7d5acfee829a8eedb27cd121/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d7261772f73636f726e696e70632f736c696d2d6d76632d736b656c)](https://camo.githubusercontent.com/3cddad907c162fdcb64b233cdc732a4a0eb3ff3d7d5acfee829a8eedb27cd121/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d7261772f73636f726e696e70632f736c696d2d6d76632d736b656c)

Slim MVC Skell with Smarty template engine
==========================================

[](#slim-mvc-skell-with-smarty-template-engine)

This is pure slim framework 4 with Smarty template engine skeleton. This project is only a index.php and directory structure to get templates from pre-defined locations based on controller/action

Built With
----------

[](#built-with)

I could not have created this skeleton without the following contributions:

- [Slim Framework](https://github.com/slimphp/Slim)
- [Smarty](https://github.com/smarty-php/smarty)
- [Slim Smarty View](https://github.com/scorninpc/slim-smarty-view)
- [Slim MVC](https://github.com/scorninpc/slim-mvc)
- [Composer](https://github.com/composer/composer)

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

[](#installation)

Just clone this repository, and download dependencies with composer

```
$ git clone https://github.com/scorninpc/slim-mvc-skel.git mywebsite.com.br
$ cd mywebsite.com.br
$ composer update
$ php -S localhost:8080

```

This commands will:

- download this repository;
- update dependencies, like slim and smarty;
- create auload
- start php build-in server

Getting Started
---------------

[](#getting-started)

To create a new page, you need:

- create a new route
- create or use a existing controller
- create a action
- create the template file

#### Routes

[](#routes)

Routes are located on application/configs/routes.php files. This structure are simple:

```
'test' => [                             // Name of route
	'pattern' => "/hello[/{somevar}]",  // URL
	'type' => ['GET'],                  // Type
	'defaults' => [
		'module' => "main",             // Controller
		'controller' => "index",        // Controller
		'action' => "hello",            // Action
		'somevar' => 1                  // Some parameter, default if not passed on url
	],
],
```

#### Controllers

[](#controllers)

Now you need to create the controller, located on Controller directory of the module. The pattern are create with `nameController.php`, like `productsController.php` or `pagesController.php`The class must extends `\Slim\Mvc\Controller` to provide the view and create location of template files

#### Actions

[](#actions)

With controller on hands, now its time to create the action, who will trigged on page access. When user access the route, the skel will call `nameController::nameAction()` method. So, if you have a route that call products controller, and details action, the skel will trigger `productsController::detailsAction()`

In that example, your controller will be something like:

```
