Giter Club home page Giter Club logo

clientplatform's Introduction

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'
# Aktifkan jika ingin mencoba kerja event listenernya
#    event_listeners:
#        - { event: 'kernel.request', class: 'App\EventListener\FilterRequestListener', method: 'filter' }

Create application class Application.php

<?php

namespace App;

use Ihsan\Client\Platform\Bootstrap;
use Psr\Cache\CacheItemPoolInterface;

class Application extends Bootstrap
{
    /**
     * @param string $configDir
     * @param CacheItemPoolInterface|null $cachePool
     * @param array $values
     */
    public function __construct($configDir, CacheItemPoolInterface $cachePool = null, array $values = array())
    {
        parent::__construct($cachePool, $values);
        $this->boot($configDir);
    }

    /**
     * @return string
     */
    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()
    {
        //$this->get('url', $args);
        //$this->post('url', $args);
        //$this->put('url', $args);
        //$this->delete('url', $args);
        //$this->client
        //Client is instance of \Ihsan\Client\Platform\Api\ClientInterface
        //$this->renderResponse('view_name', $viewArgs);
        
        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

clientplatform's People

Contributors

ad3n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clientplatform's Issues

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.