PHP Classes

MToolkit: PHP Web application framework that supports MVC

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 192 All time: 8,570 This week: 206Up
Version License PHP version Categories
mpstyle_mtoolkit 0.1GNU Lesser Genera...5.3PHP 5, Libraries, Design Patterns
Description 

Author

This package is a PHP Web application framework that supports MVC.

It provides a collection of classes for many purposes of Web applications including autoloading, different types of base controlller classes, base model classes, HTTP request handling, debugging, file and directory access, caching, date and time manipulation, etc..

Picture of Michele Pagnin
Name: Michele Pagnin <contact>
Classes: 1 package by
Country: Italy Italy

 

Documentation

MToolkit

MToolkit is a simple PHP toolkit, it is compliant with the PSR-0 Standard: - A fully-qualified namespace and class must have the following structure \\\<Vendor Name>\\\(\<Namespace\>)*\\\<Class Name>. - Each namespace must have a top-level namespace ("Vendor Name"). (Missing) - Each namespace can have as many sub-namespaces as it wishes. - Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system. - Each underscore in the class name is converted to a DIRECTORY_SEPARATOR. The underscore has no special meaning in the namespace. - The fully-qualified namespace and class is suffixed with .php when loading from the file system. - Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case.

It borns from a requirement: develop a website quickly and powerfully.

I know, someone can says "Use Zend Framwork, CakePHP!", but I could answer: "They are very good toolkits, but they aren't the toolkit that I want!" :P

The development model of MToolkit is rolling release. I search some people (developer or not) to increase and modify this strategy: my goal is to manage the versioning of this framework.

The experiences with other toolkit in different platforms have led to create this toolkit.

MToolkit borns like a mash-up of two frameworks: .NET and Qt. o_O

Yes, the framework of the evil and the desktop framework for excellence.

Some good features

  • Completely Object Oriented
  • Autoload of classes (PSR-0 Standard)
  • Autorun of pages and of RPC Json web services from controller classes
  • Javascript frameworks compatibility (jQuery, Bootstrap, etc)
  • Master page concept (http://msdn.microsoft.com/it-it/library/system.web.ui.masterpage.aspx)
  • Separation between business logic and graphics
  • Fluent setters

MToolkit components

Like Qt, MToolkit has a lot of components, one for every type of usage. Here the list: - Core - Network - Model/Sql - Controller - View

Software using MToolkit

Let's start

Create a folder for your project.

Download the latest version of MToolkit in the project folder.

On the root of your project create a new file (Settings.php) with this content:


<?php
require_once __DIR__.'/MToolkit/Core/MCore.php';

use MToolkit\Core\MApplication;

class Settings
{
    public static function run()
    {
        // Set the root path of the project
        MApplication::setApplicationDirPath(__DIR__);
    }
}

Settings::run();

This file sets the root of your project and now you no longer have to use require, require_once, include, include_once directives.

This file must be include in every entry page of your project.

Entry page

An entry page is the page loaded at start time. Now, we will see how create the controller of the entry page and his html code.

Controller (Index.php):

<?php

require_once __DIR__ . '/Settings.php';

use \MToolkit\Controller\MAbstractPageController;

class Index extends MAbstractPageController
{
    private $masterPage;

    public function __construct()
    {
        parent::__construct(__DIR__.'/Index.view');
    }

    public function helloWorld()
    {
        return "Hello World";
    }
} 

        
        

And the view file. Every view file must contains the meta tag, with the correct content-type:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Index.view:

<?php /@var $this Index/ ?>
<html>
    <head>
        <title>Entry page</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <b><?php echo $this->helloWorld(); ?></b>
    </body>
</html>

Using Composer

composer.json:

{
  "require": {
    "mpstyle/mtoolkit": "dev-master"
  }
}

On the root of your project create a new file (Settings.php) with this content:


<?php
require_once __DIR__ . '/vendor/autoload.php';

use MToolkit\Core\MApplication;

class Settings
{
    public static function run()
    {
        // Set the root path of the project
        MApplication::setApplicationDirPath(__DIR__);
    }
}

Settings::run();

And now you can create your web app.


  Files folder image Files (160)  
File Role Description
Files folder imageController (9 files)
Files folder imageCore (24 files, 7 directories)
Files folder imageDebugConsole (8 files, 4 directories)
Files folder imageModel (5 files, 1 directory)
Files folder imagenbproject (2 files, 1 directory)
Files folder imageNetwork (5 files, 2 directories)
Files folder imageUnitTest (1 file, 1 directory)
Files folder imageUser (1 file)
Files folder imageView (3 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login HTML file index.html Data Empty document
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:192
This week:0
All time:8,570
This week:206Up