2017 © Pedro Peláez
 

framework slimmvc

MVC for the PHP microframework Slim

image

revuls/slimmvc

MVC for the PHP microframework Slim

  • Friday, October 18, 2013
  • by thorbenschmitt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 100 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 67 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SlimMVC

SlimMVC is the easiest and flexible way to create your PHP application using a MVC pattern. SlimMVC use the PHP microframework Slim Framework and use the best practices collected in the slim community., (*1)

Getting Started

  1. Get or download the project
  2. Install it using Composer

Folder System

  • lib/
    • Config.php (Class to store with config variables)
    • Core.php (Singleton PDO connection to the DB)
  • models/
  • public/
  • routers/
    • name.router.php (routes by functionalities)
  • templates/

lib/

Here we have the core classes of the connection with the DB, (*2)

models/

Add the model classes here. We are using PDO for the Database., (*3)

Example of class:, (*4)

Stuff.php, (*5)

class Stuff {

    protected $core;

    function __construct() {
        $this->core = Core::getInstance();
    }

    // Get all stuff
    public function getAllStuff() {
        $r = array();

        $sql = "SELECT * FROM stuff";
        $stmt = $this->core->dbh->prepare($sql);

        if ($stmt->execute()) {
            $r = $stmt->fetchAll(PDO::FETCH_ASSOC);
        } else {
            $r = 0;
        }
        return $r;
    }
}

public/

All the public files: * Images, CSS and JS files * index.php, (*6)

routers/

All the files with the routes. Each file contents the routes of an specific functionality. It is very important that the names of the files inside this folder follow this pattern: name.router.php, (*7)

Example of router file:, (*8)

stuff.router.php, (*9)

// Get stuff
$app->get('/stuff', function () use ($app) {
    echo 'This is a GET route';
});

//Create user
$app->post('/stuff', function () use ($app) {
    echo 'This is a POST route';
});

// PUT route
$app->put('/stuff', function () {
    echo 'This is a PUT route';
});

// DELETE route
$app->delete('/stuff', function () {
    echo 'This is a DELETE route';
});

templates/

All the Twig templates., (*10)

How to Contribute

Pull Requests

  1. Fork the SlimMVC repository
  2. Create a new branch for each feature or improvement
  3. Send a pull request from each feature branch to the develop branch

The Versions

18/10 2013

dev-master

9999999-dev https://github.com/thorbenschmitt/SlimMVC

MVC for the PHP microframework Slim

  Sources   Download

MIT

The Requires

 

by revuls

rest mvc microframework router

25/08 2013

dev-development

dev-development https://github.com/revuls/SlimMVC

MVC for the PHP microframework Slim

  Sources   Download

MIT

The Requires

 

by revuls

rest mvc microframework router