Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scorninpc/slim-mvc-skel
Skeleton of Slim Framework 4 with Smarty
https://github.com/scorninpc/slim-mvc-skel
Last synced: 17 days ago
JSON representation
Skeleton of Slim Framework 4 with Smarty
- Host: GitHub
- URL: https://github.com/scorninpc/slim-mvc-skel
- Owner: scorninpc
- License: gpl-3.0
- Created: 2022-04-24T23:44:49.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-26T17:18:23.000Z (about 1 month ago)
- Last Synced: 2024-12-26T18:22:07.527Z (about 1 month ago)
- Language: PHP
- Size: 52.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version](http://poser.pugx.org/scorninpc/slim-mvc-skel/version?style=flat-square)](https://packagist.org/packages/scorninpc/slim-mvc-skel)
[![Total Downloads](http://poser.pugx.org/scorninpc/slim-mvc/downloads?style=flat-square)](https://packagist.org/packages/scorninpc/slim-mvc-skel)
![GitHub](https://img.shields.io/github/license/scorninpc/slim-mvc-skel)
![GitHub issues](https://img.shields.io/github/issues-raw/scorninpc/slim-mvc-skel)# 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
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
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
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 are located on application/configs/routes.php files. This structure are simple:
```php
'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
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
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:
```php
[ // Name of route
'pattern' => "/hello[/{somevar}]", // URL
'type' => ['GET'], // Type
'defaults' => [
//'module' => "main", // Module
'controller' => "index", // Controller
'action' => "hello", // Action
'somevar' => 1 // Some parameter, default if not passed on url
],
],
```And need to remove module directory folder from `application/configs/config.development.php`. Something like:
```php
'application' => [
'name' => "Application",
'location' => dirname(__FILE__) . "/..",
// 'modules_location' => dirname(__FILE__) . "/../modules",
],
```Now you need to change `composer.json`` to change directory of your classes:
```json
"autoload": {
"psr-4": {
"Application\\": "application/"
}
}
```This will look for controller in `application/Controllers/indexController.php`, action `helloAction()`, and will look for template in `application/Views/index/hello.tpl`
## Contributing
If you want to help, just use it. Use issues tab to recommend anything that can help, like some config, some library like database, or anything usefull
## Authors
* [Bruno Pitteli Gonçalves](https://github.com/scorninpc)
## Credits
I cannot forget to thanks Slim equip, to provide some fast, minimalist and cute framework, and Smarty community for the better template enginer created
## License
This use GNU v3.0. This permissions are strong copyleft license and are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.
**But if you use this skel to make money, please lets the 1% giveaway for devs like me, or slim, or smarty. Dont forget that are alot people making stuffs for free, to you make money**