Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

BinaryKitten/ZeffMu

Repository files navigation

ZeffMu - a micro framework built on ZF2

Zeff - The effective nuclear charge (often symbolize as Zeff or Z*) is the net positive charge experienced by an electron in a multi-electron atom.

Mu - Micron or small

Zeff is also a contraction of the British English pronounced Zed Eff (ZF)


This project is a simple example of how ZF2 could be used to build a really simple micro-framework. It looks exactly like silex, but its core is basically a ServiceManager.

This allows you to have simple closures returning output as complex architectures involving services and more advanced components, such as ZF2's ModuleManager or Doctrine2 ORM.

Important Notes

Please note that this is a project started for fun and to see how similar/different the architectures of Silex and ZF2 are.

We are working on new features and fixes for various things

We are looking to have preliminary stableness for each Milestone, starting with Milestone v0.0.5 . Until this 1st milestone has been reached master is to be considered unstable and volatile.

Installation:

In a project with a composer.json file, type following in your console.

$ composer require binarykitten/zeffmu

You can type * as a required version.

Usage:

In your public/index.php file (assuming public is your webroot), define following:

<?php
chdir(dirname(__DIR__));
require 'vendor/autoload.php';

$app = \ZeffMu\App::init();
$app
    ->route('/', function() {
        return '<a href="/hello">HEllo!</a>';
    })
    ->route('/hello', function() {
        return 'Hi!';
    })
    ->route('/hello/:name', function($params) use ($app) {
        return 'Hello ' . $params['name'];
    })
    ->route('/hello/:name/:surname', function($params) use ($app) {
        return 'Hello, Mr. ' . $params['surname'] . ', or shall I call you ' . $params['name'] . '?';
    })
->run();

Advantages

  • Since the application is a fully functional ZF application, you could also return view models in your closures, thus having templates rendered.
  • You can attach listeners to events like in a standard ZF2 application
  • You can fetch services like in a standard MVC application (i.e. $app->getService('db') or $app->getServiceLocator()->get('db'))
  • You can load modules and have any module functionality as in typical ZF2 applications

Limitations (for now)

  • ZeffMu will currently route all HTTP requests, regardless of the HTTP method.
  • It does not support things such as filtering output strings natively
  • It does not support setting controllers or retrieving them from the internal service locator (since that would require naming the controllers and basically ending up with ZF2's MVC). Routing and dispatching is also quite different from ZF2. A fallback may be interesting.
  • It does not support registering routes other than Zend\Mvc\Router\Http\Part
  • As a default, it has all the service provided in a default ZF2 application
  • Cannot define a parameter named "controller" in route matches, since it is reserved
  • Assembling routes does not yet work
  • Helper methods (view helpers/controller plugins) utilities are not yet accessible in a simple way from the application object. Some simple shortcuts may help.

Advanced usage

  • TBD: services
  • TBD: events

Build status

Build Status

About

Zend Framwork 2 Microframework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages