-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0ae071b
Showing
12 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
APP_ENV=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/build | ||
/var/ | ||
/vendor/ | ||
/.php_cs.cache | ||
/.env.local | ||
/.env.local.php | ||
/.env.*.local | ||
.phpunit.result.cache | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in([__DIR__ . '/src', __DIR__ . '/tests']); | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules( | ||
[ | ||
'@Symfony' => true, | ||
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true], | ||
'ordered_imports' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'void_return' => true, | ||
'declare_strict_types' => true, | ||
'yoda_style' => true, | ||
'increment_style' => ['style' => 'post'], | ||
'concat_space' => ['spacing' => 'one'], | ||
] | ||
) | ||
->setFinder($finder) | ||
->setUsingCache(true); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"http": { | ||
"address": "0.0.0.0:8000", | ||
"workers": { | ||
"command": "bin/roadRunnerAgent", | ||
"pool": { | ||
"numWorkers": 4 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
ini_set('display_errors', 'stderr'); | ||
|
||
use App\Kernel; | ||
use Symfony\Component\Debug\Debug; | ||
use Thruster\RoadRunnerBridge\RoadRunnerBridge; | ||
|
||
set_time_limit(0); | ||
|
||
require dirname(__DIR__) . '/config/bootstrap.php'; | ||
|
||
if ($_SERVER['APP_DEBUG']) { | ||
umask(0000); | ||
|
||
if (class_exists(Debug::class)) { | ||
Debug::enable(); | ||
} | ||
} | ||
|
||
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); | ||
$kernel->boot(); | ||
|
||
RoadRunnerBridge::createCLI() | ||
->attach($kernel) | ||
->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "thruster/mikro-web-framework", | ||
"type": "project", | ||
"license": "proprietary", | ||
"require": { | ||
"php": ">=7.3", | ||
"thruster/mikro-kernel": "^1.1", | ||
"thruster/road-runner-bridge": "^1.0", | ||
"thruster/sapi-bridge": "^1.0", | ||
"symfony/dotenv": "^4.2" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "src" | ||
}, | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"App\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"check-style": "php-cs-fixer fix --dry-run --diff --diff-format udiff", | ||
"fix-style": "php-cs-fixer fix" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
require dirname(__DIR__).'/vendor/autoload.php'; | ||
|
||
if (false === class_exists(Dotenv::class)) { | ||
throw new RuntimeException( | ||
'Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.' | ||
); | ||
} | ||
|
||
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); | ||
|
||
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; | ||
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; | ||
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var( | ||
$_SERVER['APP_DEBUG'], | ||
FILTER_VALIDATE_BOOLEAN | ||
) ? '1' : '0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use App\RequestHandler; | ||
|
||
return function (ContainerConfigurator $container) { | ||
$services = $container->services(); | ||
|
||
$container = $services | ||
->defaults() | ||
->autoconfigure() | ||
->autowire(); | ||
|
||
$container->set(RequestHandlerInterface::class, RequestHandler::class) | ||
->alias('request_handler', RequestHandlerInterface::class); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use App\Kernel; | ||
use Symfony\Component\Debug\Debug; | ||
use Thruster\SapiBridge\SapiBridge; | ||
|
||
require dirname(__DIR__) . '/config/bootstrap.php'; | ||
|
||
if ($_SERVER['APP_DEBUG']) { | ||
umask(0000); | ||
|
||
Debug::enable(); | ||
} | ||
|
||
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); | ||
$kernel->boot(); | ||
|
||
SapiBridge::createFromGlobals() | ||
->attach($kernel) | ||
->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Thruster\MikroKernel\MikroKernel; | ||
|
||
class Kernel extends MikroKernel | ||
{ | ||
public function registerContainerConfiguration(LoaderInterface $loader): void | ||
{ | ||
$projectDir = $this->getProjectDir(); | ||
|
||
$loader->load($projectDir . '/config/container.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Thruster\HttpFactory\HttpFactoryInterface; | ||
|
||
class RequestHandler implements RequestHandlerInterface | ||
{ | ||
/** @var HttpFactoryInterface */ | ||
private $httpFactory; | ||
|
||
public function __construct(HttpFactoryInterface $httpFactory) | ||
{ | ||
$this->httpFactory = $httpFactory; | ||
} | ||
|
||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
return $this->httpFactory->response()->createResponse() | ||
->withBody( | ||
$this->httpFactory->stream()->createStream('<h1>Hello World</h1>') | ||
); | ||
} | ||
|
||
} |
Empty file.