2017 © Pedro Peláez
 

library asd-framework

Minimalistic framework for PHP7

image

afridlund85/asd-framework

Minimalistic framework for PHP7

  • Tuesday, September 6, 2016
  • by afridlund85
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Asd(name?) PHP7 API Framework Build Status Coverage Status

PHP7 Framework for API applications., (*1)

Installation

None, it is not even close to ready for release., (*2)

Some Key Concepts

  • PHP 7 only
  • No dependencies(expect PSR-7 interfaces)
  • PSR: 1,2,4,7
  • No statics, no globals
  • No forced strict conventions in naming/routing, folder structure etc when using
  • No settings or configs
  • Transparency, no unncessary abstraction/wrapping
  • Use PHP 7 strict types, (except PSR-7 classes, cuz they're not PHP 7)

Intended usage

Presumptions: htaccess configured and PSR-4 autoloading, (*3)

Define routes with HTTP-method, path and controllerclass + method, (*4)

index.php, (*5)

require_once('vendor/autoload.php');

use Asd\Asd;
use Asd\Router\Route;
use Asd\FunctionCallback;
use Asd\MethodCallback;

$app = new Asd();

//Controller class extending from Asd\Controller and has dependency to Asd\Session
$app->addRoute(new Route('GET', '/', new MethodCallback('MyApp\Controllers', 'Welcome', 'start')));

//Just some class with a method
$app->addRoute(new Route('GET', 'about', new MethodCallback('MyApp', 'SomeClass', 'about')));

//Closure/Anonymus function
$app->addRoute(new Route('post', 'blog', new FunctionCallback(function($req, $res){
  //do stuff
  return $this->res; //return response
})));

//Closure/anonymus function with dependency
$app->addRoute(new Route('post', 'auth', new FunctionCallback(function($req, $res, Asd\Session $session){
  //session class automatically injected through DI
  return $this->res;//return response
})));

$app->run();

MyApp/Controllers/Welcome.php, (*6)

namespace MyApp\controllers;

use Asd\Controller;

class Welcome extends Controller
{
  public function __construct(Asd\Session $session)
  {
    //session class automatically injected through DI
  }
  public function start($req, $res)
  {
    return $res->withJsonResponse('Hello!');
  }
}

MyApp/SomeClass.php, (*7)

namespace MyApp;

class SomeClass
{
  public function about($req, $res)
  {
    //do stuff;
    return $res;
  }
}

Setup Development environment

Requires PHP7, (*8)

git clone https://github.com/afridlund85/php7-api-framework.git
cd php7-api-framework
composer install

Tests

Three levels of testing, unit, integration and system., (*9)

Runing tests

Run all test suites, (*10)

composer test

Run Unit test suite, (*11)

composer unit

Run Integration test suite, (*12)

composer integration

Run System test suite, (*13)

composer system

PSR-2 linting

Check for PSR-2 errors, (*14)

composer sniff

Code coverage

Generate code coverage, (*15)

composer coverage

The Versions

06/09 2016

dev-master

9999999-dev

Minimalistic framework for PHP7

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Fridlund

php7 api framework