Welcome To the DevWorks MVC Framework

A Very Simple, Low footprint MVC Framework

Using this MVC

Features

  • URL Rewriting with mod_rewrite
  • Full MVC Workflow
  • Core PDO Database Library
  • Flash Messaging

Workflow

Creating a Controller
  1. Create a file in the controllers folder such as Posts.php
  2. Create a class such as Posts and extend the Controller class
  3. Create an index() method which is the default. Access it at http://yourapp/posts
  4. Create another method like add() and access it at http://yourapp/posts/add
  5. You can add an optional parameter to a method such as show($id) and access at http://yourapp/posts/show/12. You can then access the "12" with $id in your show($id) method
  6. Or create an HTACCESS file and use it to SLUG Your Post titles
    ^/posts/title-of-your-post /post/$id
Creating a View
  1. Create a file in the views folder such as index.php or in a subfolder like posts/index.php
  2. Load the view in your controller method with
    $this->view('posts/index');
  3. You can pass data into the view as an associative array like this
    $this->view('posts/index', ['title' => 'Hello World']);
  4. You can access that value in the view with
    <?php echo $data['title'] ?>
  5. You can access the page by visiting
    /pages/post
Creating a Model
  1. Create a file in the models folder such as Post.php
  2. Create a class such as Post
  3. To use the database library, create a private $db property, then create a constructor and instantiate a new db instance with
    $this->db = new Database;

Conclusion


The usage of a Framework such as this is limitless.

We have used this framework on mutliple sites and on the front end, everything looks normal, in the background, this MVC takes care of everything.