2017 © Pedro Peláez
 

library megumin-framework

A simple MVC PHP framework

image

pfcode/megumin-framework

A simple MVC PHP framework

  • Sunday, February 26, 2017
  • by pfcode
  • Repository
  • 2 Watchers
  • 5 Stars
  • 92 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

MeguminFramework

A simple MVC framework written in PHP. Name was inspired by Megumin from Kono Subarashii Sekai ni Shukufuku wo! anime :), (*1)

Name inspired by Megumin from Kono Subarashii Sekai ni Shukufuku wo!, (*2)

Overview

A main purpose of this project is to easily start a new project codebase using set of base classes and tools that are intended to make your work faster and keep the code clean., (*3)

Despite of mainstream PHP frameworks, this one provides only the most common components, such as:, (*4)

  • Dispatcher - performs routing to the controllers (with friendly URLs support)
  • ModelFactory - manipulates Model storage by queries (SQL databases)
  • Model - represents some data in project, such as UserModel, PostModel or so..
  • Controller - handles data from inputs, manipulates on Models and presents results to user
  • View - presents data from isolated variable scope on page

There are also basic implementations of some classes:, (*5)

  • MySQLModelFactory - ModelFactory that handles custom MySQL queries to retreive and manipulate data
  • ScopeDebugView - View that displays informations about controller - can be used for debugging

Installation

You only need to add new dependency to your composer.json file:, (*6)

  "require": {
    "pfcode/megumin-framework": ">=1.0.0"
  }, 

...and update your project (Composer should automatically download latest package):, (*7)

composer update

Quick Start

There's a sample index.php in examples directory that uses MeguminFramework and performs sample routing. Here is the basic part of it (assuming that sample controllers have been defined and autoloaded), (*8)

<?php

// Use MeguminFramework namespace to gain direct access to its components
use pfcode\MeguminFramework\Dispatcher;
use pfcode\MeguminFramework\View;

// Use PSR-4 autoloader generated by composer
require __DIR__ . "/../vendor/autoload.php";

// Set global View parameters (page title doesn't have to be honored by chosen View)
View::setPageTitlePrefix("Website Title");
View::setPageTitleSeparator(" : ");

// Specify namespace that your controllers belongs to 
Dispatcher::setControllersNamespace(__NAMESPACE__);

// Set controllers that should be called when routing fails
Dispatcher::setFallbackControllers(DashboardController::class, NotFoundController::class);

// Specify routing table for the dispatcher 
// (you can omit this call when you don't want to use friendly URLs)
Dispatcher::setUrlPatterns(array(
    "/test/{id}" => TestController::class,
    "/test" => TestController::class,
    "/" => DashboardController::class
));

// Perform routing and execute proper controller
Dispatcher::explosion();

The Versions

26/02 2017

v2.x-dev

2.9999999.9999999.9999999-dev

A simple MVC PHP framework

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

framework

01/01 2017

dev-master

9999999-dev

A simple MVC PHP framework

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

framework

29/08 2016

1.3.0

1.3.0.0

A simple MVC PHP framework

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

framework

10/08 2016

1.2.0

1.2.0.0

A simple MVC PHP framework

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

framework

07/08 2016

1.1.0

1.1.0.0

A simple MVC PHP framework

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

framework

31/07 2016

1.0.0

1.0.0.0

A simple MVC PHP framework

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

framework