Skip to content

Commit f3ba3a0

Browse files
committed
Nette framework addition
Nette framework addition - readme & config correct dir version name
1 parent ff13aa3 commit f3ba3a0

File tree

12 files changed

+168
-0
lines changed

12 files changed

+168
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ Note: This project is based on
234234
* [Laravel](https://github.com/laravel/laravel)
235235
* [Leaf](https://github.com/leafsphp/leaf)
236236
* [Lumen](https://github.com/laravel/lumen)
237+
* [Nette](https://github.com/nette/web-project)
237238
* [PhRoute](https://github.com/mrjgreen/phroute)
238239
* [Silex](https://github.com/silexphp/Silex)
239240
* [Slim](https://github.com/slimphp/Slim)

config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ laravel-10.3
2525
laravel-11.0
2626
leaf-3.11
2727
lumen-10.0
28+
nette-4.0
2829
phroute-2.2
2930
pure-php
3031
silex-2.3

nette-3.3/_benchmark/clean.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
rm -rf !("_benchmark")
3+
find -path './.*' -delete
4+
rm -rf _benchmark/temp
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
# clear cache
3+
echo -e "done"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
url="$base/$fw/www/index.php/hello/index"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace app;
6+
7+
use Nette;
8+
use Nette\Bootstrap\Configurator;
9+
10+
11+
class Bootstrap
12+
{
13+
private Configurator $configurator;
14+
private string $rootDir;
15+
16+
17+
public function __construct()
18+
{
19+
$this->rootDir = dirname(__DIR__);
20+
$this->configurator = new Configurator;
21+
$this->configurator->setTempDirectory($this->rootDir . '/temp');
22+
}
23+
24+
25+
public function bootWebApplication(): Nette\DI\Container
26+
{
27+
$this->initializeEnvironment();
28+
$this->setupContainer();
29+
return $this->configurator->createContainer();
30+
}
31+
32+
33+
public function initializeEnvironment(): void
34+
{
35+
//$this->configurator->setDebugMode('secret@23.75.345.200'); // enable for your remote IP
36+
$this->configurator->enableTracy($this->rootDir . '/log');
37+
38+
$this->configurator->createRobotLoader()
39+
->addDirectory(__DIR__)
40+
->register();
41+
}
42+
43+
44+
private function setupContainer(): void
45+
{
46+
$configDir = $this->rootDir . '/config';
47+
$this->configurator->addConfig($configDir . '/common.neon');
48+
$this->configurator->addConfig($configDir . '/services.neon');
49+
}
50+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace app\Core;
6+
7+
use Nette;
8+
use Nette\Application\Routers\RouteList;
9+
10+
/*
11+
PHP-Frameworks-Bench
12+
this is a simple hello world controller to make benchmark
13+
*/
14+
final class RouterFactory
15+
{
16+
use Nette\StaticClass;
17+
18+
public static function createRouter(): RouteList
19+
{
20+
$router = new RouteList;
21+
$router
22+
->withPath('index.php')
23+
->addRoute('hello/index', function () {
24+
echo 'Hello World!';
25+
});
26+
27+
return $router;
28+
}
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# see https://doc.nette.org/en/configuring
2+
3+
parameters:
4+
5+
6+
application:
7+
mapping: App\Presentation\*\**Presenter
8+
9+
10+
database:
11+
dsn: 'sqlite::memory:'
12+
user:
13+
password:
14+
15+
16+
latte:
17+
strictTypes: yes
18+
strictParsing: yes
19+
extensions:
20+
- App\Presentation\Accessory\LatteExtension
21+
22+
23+
assets:
24+
mapping:
25+
default:
26+
path: assets
27+
# type: vite # Uncomment to activate Vite for asset building
28+
29+
30+
di:
31+
export:
32+
parameters: no
33+
tags: no
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
- App\Core\RouterFactory::createRouter
3+
4+
5+
search:
6+
- in: %appDir%
7+
classes:
8+
- *Facade
9+
- *Factory
10+
- *Repository
11+
- *Service
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require __DIR__ . '/../vendor/autoload.php';
6+
7+
$bootstrap = new app\Bootstrap;
8+
$container = $bootstrap->bootWebApplication();
9+
$application = $container->getByType(Nette\Application\Application::class);
10+
$application->run();
11+
12+
/* *** PHP-Frameworks-Bench *** */
13+
require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php';

0 commit comments

Comments
 (0)