1. Go to this page and download the library: Download windwalker/application library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
windwalker / application example snippets
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();
php
$this->environment->browser->getBrowser(); // Get browser name
php
$this->environment->platform->isUnix();
php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Windwalker\Application\AbstractWebApplication;
class MyHttpKernel extends AbstractWebApplication
{
public function dispatch(Request $request, Response $response, $next = null)
{
// Get request query
$query = $request->getQueryParams();
// Get Psr Uri
$uri = $request->getUri();
// Write body
$response->getBody()->write('<h1>Hello World~~~!</h1>');
return $response;
}
}
$app = new MyHttpKernel;
$app->execute();
php
// app.php
use Windwalker\Application\AbstractCliApplication;
class MyCliApp extends AbstractCliApplication
{
public function doExecute()
{
// Get options (-h)
$help = $this->io->get('h');
if ($help)
{
$msg = <<<MSG
Help message: version 1.0
------------------------------------
myapp.php <command> [-options]
foo Description of this command.
bar Description of this command.
help Description of this command.
MSG;
$this->io->out($msg);
$this->close();
}
// Get arguments
$arg = $this->getArgument(0);
// Do some stuff...
return 0; // Exit code 0 means success
}
}
$app = new MyCliApp;
$app->execute();
bash
php app.php arg1 arg2 -h --option --foo bar --n=a
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.