minorwork/minorwork

A minimal framework

0.4.3 2019-06-07 03:15 UTC

This package is auto-updated.

Last update: 2024-04-14 22:33:20 UTC


README

Build Status

A minimal PHP framework that is serious on being minimal.

Features:

  • A container.
  • Named routing with redirection support
  • Less than 300 lines.
  • Only external dependency is nikic/fast-route for routing.
  • Optional Twig integration (minorwork-twig)

Install

You can install MinorWork with composer.

composer require minorwork/minorwork

PHP 5.4 or newer required.

Usage

Using MinorWork framework looks like this:

<?php
// This is index.php
// All traffic should bed handled by this file.
// You may need edit your .htaccess for this.

include __DIR__ . '/../vendor/autoload.php';

use MinorWork\App;

$app = new App();
$app->setRouting([
    'root'         => ['/', '\Controller\Index:home'],
    'loginForm'    => ['GET', '/login', '\Controller\Login:form'],
    'loginAction'  => ['POST', '/login', '\Controller\Login:login'],
    'article'      => ['/articles/{id}', '\Controller\Article:show'],
    'users'        => ['\Controller\User:list'], // matches /users
    'userProfile'  => ['/user/{id}', '\Controller\User:profile'],
]);

$app->run();

Define routing, the run the app. MinorWork will take care the rest.

Another example is in example/ folder. You can see it in action using PHP dev server.

cd example
php -S localhost:8765

Read the documentation for more detail.