dev-master
9999999-dev https://github.com/joppli/framework.phpJoppli framework
WTFPL
The Requires
- php >=7.0.0
framework joppli
Wallogit.com
2017 © Pedro Pelรกez
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)
root โโ config โ โโ config.yml โโ public โ โโ index.php โโ src | โโ HelloWorld | โโ HelloWorldDispatcher.php โโ composer.json
---
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)
<?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();
<?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)
{
"autoload":
{
"psr-4":
{
"HelloWorld\\": "src/HelloWorld"
}
},
"require":
{
"joppli/php-framework": "*"
}
}
Joppli framework
WTFPL
framework joppli