2017 © Pedro Pelรกez
 

library framework

image

joppli/framework

  • Sunday, April 1, 2018
  • by superhero
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Joppli v.0.1

PHP Framework

License: MIT., (*1)


This documentation is very basic, the framework is developed by me to used by my self. If an interest is shown by others I will extend the documentation. Show interest by dropping me a line on twitter @ErikLandvall or simply star/follow/fork the project., (*2)

Specific characteristics of the framework: the possibility to use a series of dispatchers on each request., (*3)

Skeleton

root
โ”œโ”€ config
โ”‚  โ””โ”€ config.yml
โ”œโ”€ public
โ”‚  โ””โ”€ index.php
โ”œโ”€ src
|  โ””โ”€ HelloWorld
|     โ””โ”€ HelloWorldDispatcher.php
โ””โ”€ composer.json

config/config.yml

---
route:
- deliverer: Joppli\Deliverer\JsonDeliverer
- dispatchers:
  - HelloWorld\HelloWorldDispatcher
  policy:
  - validator: PathCompareValidator
    options:
      path: /
  - validator: MethodValidator
      options:
        method: get
...

The config file can be of what ever flavor you desire as long as you convert it to a php array in the end. I prefer YAML., (*4)

The config files branches are case insensitive, the leafs are not., (*5)

public/index.php

<?php

// Changes root directory
$root = dirname(__DIR__);
chdir($root);

// Auto loader
require 'vendor/autoload.php';

$parsers = ['yml' => new Joppli\Parser\YamlParser];
$paths   = ['config'];
$config  = (new Joppli\Config\ConfigFactory)->create($parsers, $paths);
$request = (new Joppli\Request\RequestFactory)->create();

// Run application
(new Joppli\Application\ApplicationBuilder)->build($config, $request)->run();

src/HelloWorld/HelloWorldDispatcher.php

<?php

namespace HelloWorld;

use Joppli\Dispatcher\Dispatcher;
use Joppli\Request\Aware\RequestAware;
use Joppli\Request\Aware\RequestAwareTrait;
use Joppli\Response\Aware\ResponseAware;
use Joppli\Response\Aware\ResponseAwareTrait;

class HelloWorldDispatcher implements Dispatcher, RequestAware, ResponseAware
{
  use
  RouteAwareTrait,
  UserAwareTrait;

  public function dispatch()
  {
    $host = $this->request->getHost();

    $this->response->message  = 'Hello world!';
    $this->response->host     = $host;
  }
}

The dispatcher only needs to implement the Dispatcher interface. However, this example also shows how to access the Request and Response instances by declaring awareness., (*6)

composer.json

{
  "autoload":
  {
    "psr-4":
    {
      "HelloWorld\\": "src/HelloWorld"
    }
  },

  "require":
  {
    "joppli/php-framework": "*"
  }
}

The Versions

01/04 2018

0.1.0

0.1.0.0

  Sources   Download

23/03 2018

dev-master

9999999-dev https://github.com/joppli/framework.php

Joppli framework

  Sources   Download

WTFPL

The Requires

  • php >=7.0.0

 

framework joppli