Giter VIP home page Giter VIP logo

framework's Introduction

Latest Stable Version Build Status Total Downloads License PHP 7 ready Code Climate Scrutinizer CQ

DrMVC\Framework

A framework that combines some modules. necessary to create a full-fledged web application.

composer require drmvc/framework

How to use

More examples you can find here.

Example of index.php inside public_html folder:

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

$config = new \DrMVC\Config();
$config->load(__DIR__ . '/../app/database.php', 'database');

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

$app = new \DrMVC\App($config);
$app
    ->get('/', \MyApp\Controllers\Index::class . ':default') //-> public function action_default()
    ->get('/zzz', \MyApp\Controllers\Index::class) //-> public function action_index()
    ->get('/zzz/<action>', \MyApp\Controllers\Index::class)
    ->get('/aaa', function(Request $request, Response $response, $args) {
        print_r($args);
    });

echo $app->run();

Example of Index controller inside app/Controllers folder:

<?php

namespace MyApp\Controllers;

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

class Index
{
    public function action_index(Request $request, Response $response, $args)
    {
        $out = [
            'dummy',
            'array'
        ];

        $json = json_encode($out);
        header('Content-Type: application/json');
        $response->getBody()->write($json);
    }

    public function action_defaultRequest $request, Response $response, $args)
    {
        $out = [
            'test1',
            'test2'
        ];

        $json = json_encode($out);
        header('Content-Type: application/json');
        $response->getBody()->write($json);
    }
}

Where to get help

If you found the bug, please report about this on GitHub Issues page.

About PHP Unit Tests

First need to install all dev dependencies via composer update, then you can run tests by hands from source directory via ./vendor/bin/phpunit command.

Links

  • DrMVC Framework
  • Slim - Is a PHP micro framework, I really like how there are implemented the PSR-4 conception.
  • SimpleMVC - it was a very exciting project, before the author renamed this to Nova
  • Phalcon - Simple and clean code of your application

framework's People

Contributors

evilfreelancer avatar

Watchers

James Cloos avatar

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.