Giter Site home page Giter Site logo

mvc-framework's Introduction

(another) PHP MVC Framework

Includes autoloader and routing.

Server Setup

Tested on PHP7 and Apache2

  1. sudo a2enmod rewrite
  2. Configure apache2.conf Needs AllowOverrride All for htaccess rewrite
<Directory /path/to/webroot/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        Allow from localhost
</Directory>

Use

  1. Request URIs follow this pattern /controller/method/param1/paramN
    1. Configuration
      1. Add new routes in /config/Routes.php
      2. Add new namespaces in /config/Namespaces.php
  2. Interfaces
    1. List of Intefaces in Core (src/)
      1. Controller - instantiates Service and View
      2. Service - instantiates mappers, business logic classes, and entities (returns)
      3. Mapper - uses DBHelper for repository queries
      4. Entity - Getters/Setters store for View
      5. View - uses entities and renders views/templates
  3. Exceptions
    1. Update /public/index.php with new exception classes to catch them
    2. Uncaught excpetions go to Exception|Error handled and logged with error code
  4. Tests
    1. Only test classes under app directory
    2. Unit - where no other resource (class, filesystem, database, etc) is needed for the method being tested
    3. Integration - where other resources are included in the test
    4. Functional - client tests (eg rendered page, api response, etc)

Data Flow

#           ##
#         ##  ##
#       ##      ##
#     ##  Client  ## <-------------------------------------------+
#       ##      ##                                               |
#         ##  ##                                                 |
#           ##                                                   |
#            |                                                   |
#            v                                                   |
#   ##################         ##################         ################
#   #                #         #                #         #              #
#   #   index.php    # ------> #   controller   #-------> #     View     #
#   #                #         #                #         #              #
#   ##################         ##################         ################
#                                 |         ^                    ^
#                                 |         |                    |
#                                 v         |                    v
#                              ##################         +--------------+
#                              #                #         |              |
#                              #   Service      #         |   Templates  |
#                              #                #         |              |
#                              ##################         +--------------+
#                                      ^
#                 +--------------------+--------------------+
#                 v                    v                    v
#   ##################         ##################         ################
#   #                #         #                #         #              #
#   #   Mapper       #         #   BL Classes   #         #     Entity   #
#   #                #         #                #         #              #
#   ##################         ##################         ################
#          ^
#          |
#          v
#      ##########
#      #        #
#      #        #
#      #   DB   #
#      #        #
#      #        #
#      ##########
#

References

  1. Inspirations from: https://github.com/andrejrs/php-mvc-example

mvc-framework's People

Contributors

dhammon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.