2017 © Pedro Peláez
 

windwalker-package application

Windwalker Application package

image

windwalker/application

Windwalker Application package

  • Saturday, July 28, 2018
  • by asika32764
  • Repository
  • 4 Watchers
  • 1 Stars
  • 208 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 52 Versions
  • 0 % Grown

The README.md

Windwalker Application

Windwalker application is a kernel as main entry of your system., (*1)

Installation via Composer

Add this to the require block in your composer.json., (*2)

``` json { "require": { "windwalker/application": "~3.0" } }, (*3)


## Create An Application Create application and extends the `doExecute()` method to something. ``` php use Windwalker\Application\AbstractApplication; use Windwalker\IO\Input; use Windwalker\Structure\Structure; class MyApplication extends AbstractApplication { protected function init() { // Do stuff. // Get config $this->get('foo'); // bar } public function doExecute() { try { // Some code here... } catch (\Exception $e) { Error::renderErrorPage(); } return true; } } $app = new MyApplication(new Structure(array('foo' => 'bar'))); $app->execute();

Config is Structure object, see Windwalker Structure, (*4)

WebApplication

AbstractWebApplication contains WebEnvironment and WenHttpServer object that help us handle HTTP request and output., (*5)

WebEnvironment

Use WebEnvironment to get information of browser or server., (*6)

``` php $this->environment->browser->getBrowser(); // Get browser name, (*7)


Use `Platform` to get server information. ``` php $this->environment->platform->isUnix();

See: Environment Package, (*8)

PSR7 Handler

dispatch() is a standard PSR7 handler so we can write our logic here, just return Response object and the WebHttpServer object which in Application will render it to client., (*9)

``` php use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Windwalker\Application\AbstractWebApplication;, (*10)

class MyHttpKernel extends AbstractWebApplication { public function dispatch(Request $request, Response $response, $next = null) { // Get request query $query = $request->getQueryParams();, (*11)

    // Get Psr Uri
    $uri = $request->getUri();

    // Write body
    $response->getBody()->write('<h1>Hello World~~~!</h1>');

    return $response;
}

}, (*12)

$app = new MyHttpKernel;, (*13)

$app->execute();, (*14)


Result: ``` html <h1>Hello World~~~!</h1>

Error Handler

Set error handler as final handler so we can use it in dispatch()., (*15)

``` php class MyHttpKernel extends AbstractWebApplication { public function dispatch(Request $request, Response $response, $next = null) { try { throw new \Exception('Whoops~', 500); } catch (\Exception $e) { return $next($e, $request, $response); }, (*16)

    return $response;
}

}, (*17)

$app = new MyHttpKernel;, (*18)

$app->setFinalHandler(function (Exception $e, Request $request, Response $response) { $response->getBody()->write(sprintf(', (*19)

Error %s. Message: %s

', $e->getCode(), $e->getMessage())); });, (*20)

$app->execute();, (*21)


Result: ``` html <h1>Error 500. Message: Whoops~</h1>

See Windwalker Http Package, (*22)

Cli Application

This is a example of a simple cli application., (*23)

``` php // app.php, (*24)

use Windwalker\Application\AbstractCliApplication;, (*25)

class MyCliApp extends AbstractCliApplication { public function doExecute() { // Get options (-h) $help = $this->io->get('h');, (*26)

    if ($help)
    {
        $msg = <<<MSG

Help message: version 1.0

myapp.php [-options], (*27)

foo Description of this command. bar Description of this command. help Description of this command. MSG;, (*28)

        $this->io->out($msg);

        $this->close();
    }

    // Get arguments
    $arg = $this->getArgument(0);

    // Do some stuff...

    return 0; // Exit code 0 means success
}

}, (*29)

$app = new MyCliApp;, (*30)

$app->execute();, (*31)


Now we can access this app by PHP CLI: ``` bash php app.php arg1 arg2 -h --option --foo bar --n=a

See: Windwalker IO, (*32)

The Versions

28/07 2018

dev-master

9999999-dev https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

28/07 2018

3.4.4

3.4.4.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

08/07 2018

3.4.3

3.4.3.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

16/06 2018

3.4.2

3.4.2.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

15/06 2018

3.4.1

3.4.1.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

20/02 2018

dev-test

dev-test https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

20/02 2018
20/02 2018

3.3.1

3.3.1.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

20/02 2018

3.3.2

3.3.2.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0-or-later

The Requires

 

The Development Requires

framework application windwalker

20/02 2018
25/06 2017
25/06 2017
25/06 2017
25/06 2017
25/06 2017
09/06 2017
09/06 2017
05/06 2017
21/03 2017
21/03 2017
21/03 2017
21/03 2017
11/10 2016
11/10 2016
11/10 2016
11/10 2016
10/10 2016
18/07 2016
06/07 2016

3.0-beta2

3.0.0.0-beta2 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

04/07 2016

3.0-beta

3.0.0.0-beta https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

02/04 2016

2.1.9

2.1.9.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

12/02 2016

2.1.7

2.1.7.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

12/02 2016

2.1.8

2.1.8.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

19/08 2015

2.1.1

2.1.1.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

19/08 2015

2.1.2

2.1.2.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

19/08 2015

2.1.4

2.1.4.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

19/08 2015

2.1.5

2.1.5.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

19/08 2015

2.1.6

2.1.6.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

11/08 2015

2.1

2.1.0.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

27/07 2015

2.0.9

2.0.9.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/02 2015

2.0.5

2.0.5.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/02 2015

2.0.6

2.0.6.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/02 2015

2.0.7

2.0.7.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/02 2015

2.0.8

2.0.8.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

26/12 2014

2.0.3

2.0.3.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

26/12 2014

2.0.4

2.0.4.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/12 2014

2.0.0

2.0.0.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/12 2014

2.0.1

2.0.1.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

16/12 2014

2.0.2

2.0.2.0 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

24/11 2014

2.0.0-beta2

2.0.0.0-beta2 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

LGPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

05/10 2014

2.0.0-beta1

2.0.0.0-beta1 https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

framework application windwalker

05/10 2014

2.0.0-alpha

2.0.0.0-alpha https://github.com/ventoviro/windwalker-application

Windwalker Application package

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

framework application windwalker