GithubHelp home page GithubHelp logo

Minwork - PHP Framework

Disclaimer

Currently minwork framework is in alpha stage and can have breaking changes between releases, which also means that examples may be out of date.

It is not recommended to use it in production environment, but if you still want to, then specify exact library version to avoid updates that can break your application.

What is Minwork?

Minwork is a PHP 7 micro framework designed to be fast, compact, easy to use, with interchangeable modules.

Main advantages of Minwork are:

  • Flexible - every part of the framework can be replaced with your own as long as it implements specified interface
  • Event based - all major actions trigger corresponding events for easy hooking and modifying application flow
  • Operations - model utilizes command design pattern which allows to execute, queue and revert any CRUD operation
  • Fast - due to light weight, small and simple modules with only most necessary functionality as well as no external dependencies Minwork is incredibly fast
  • Minimum effort - you can create basic application under 1 minute with less than 15 lines of code
  • PHP 7 - utilizes every benefit of PHP 7 to make your work even smoother and more comfortable
  • IDE friendly - everything you need to know about any module or method is well documented using PHPDoc

Example

This is how to create simple Hello World application

<?php
require 'vendor/autoload.php';

use Minwork\Core\Framework;
use Minwork\Http\Utility\Environment;
use Minwork\Http\Object\Router;
use Minwork\Basic\Controller\Controller;

$controller = new class() extends Controller {
  public function show() {
    return 'Hello world!';
  }
};
$framework = new Framework(new Router(['test' => $controller]), new Environment());
$framework->run('/test');

But what if we want to parse real website url? In that case you will need .htaccess file with content as follows

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?URL=$1 [L,QSA]

And your index.php should look like this

<?php
require 'vendor/autoload.php';

use Minwork\Core\Framework;
use Minwork\Http\Utility\Environment;
use Minwork\Http\Object\Router;
use Minwork\Basic\Controller\Controller;

$controller = new class() extends Controller {
    public function show($name)
    {
        return "Hello {$name}!";
    }
};
$framework = new Framework(new Router(['default_controller' => $controller]), new Environment());
$framework->run($_GET['URL']);

Because show is default controller method, as a result of calling address http://yourwebsitename.com/John framework will output Hello John!

If you want output to be returned instead of printed just change last line to $content = $framework->run($_GET['URL'], true);

minwork's Projects

minwork doesnโ€™t have any public repositories yet.

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.