Client Platform
What
Client platform is simple framework that aim to simplify Frontend Developer that working with API Platform
Installation
Add composer.json
{
"require": {
"ad3n/client-platform": "~1.0"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
}
}
Create configuration file config.yml
app:
base_url: 'abc'
routes:
- { path: '/{a}/{b}', controller: 'App:HomeController@index', methods: ['GET'] }
template:
path: '/var/views'
cache_dir: '/var/cache'
Create application class Application.php
<?php
namespace App;
use Ihsan\Client\Platform\Bootstrap;
use Psr\Cache\CacheItemPoolInterface;
class Application extends Bootstrap
{
public function __construct($configDir, CacheItemPoolInterface $cachePool = null, array $values = array())
{
parent::__construct($cachePool, $values);
$this->boot($configDir);
}
protected function projectDir()
{
return __DIR__.'/..';
}
}
Create Front Controller aka index.php
<?php
require __DIR__.'/../vendor/autoload.php';
use App\Application;
use Symfony\Component\HttpFoundation\Request;
$configDir = __DIR__.'/../app/config';
$request = Request::createFromGlobals();
$app = new Application();
$app->boot($configDir);
$app->handle($request);
Create Controller HomeController.php
<?php
namespace App\Controller;
use Ihsan\Client\Platform\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
class HomeController extends AbstractController
{
public function indexAction()
{
return new Response('Hello World!.');
}
}
For more information about controller, please read Ihsan\Client\Platform\Controller\AbstractController.php
Configuration
For more information about configuration, please read Ihsan\Client\Platform\Configuration\Configuration.php#L78-L166
Example
Check: https://github.com/ad3n/ClientApplication