Skip to content
Draft
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
03c44ad
ignore apm_fallback.log
fadrian06 Sep 10, 2025
86250f9
fix warning about optional parameter before required parameter in php…
fadrian06 Sep 10, 2025
d2bb4c3
composer require flightphp/apm:^0.4.1 flightphp/core:^3.17 -W & compo…
fadrian06 Sep 10, 2025
16fbe8f
composer rector
fadrian06 Sep 10, 2025
81dfe72
npx @biomejs/biome check --write **/*.js **/*.css **/*.json
fadrian06 Sep 10, 2025
83bcc1c
ensure newline at end of files
fadrian06 Sep 10, 2025
3c26c75
phpcbf --standard=PSR12 app/ public/index.php rector.php swoole_serve…
fadrian06 Sep 10, 2025
6844c95
rename CustomFlight -> CustomEngine
fadrian06 Sep 10, 2025
8dce425
change require to require_once in swoole_server.php
fadrian06 Sep 10, 2025
19d1d5a
add type coercions in translate_content.php
fadrian06 Sep 10, 2025
294ed2d
composer require symfony/var-dumper:^7.3 --dev -W
fadrian06 Sep 11, 2025
c045a59
mb_internal_encoding and setlocale were added since php 4
fadrian06 Sep 11, 2025
75e8a9e
middleware usage simplification
fadrian06 Sep 11, 2025
fac2984
simplify $app declaration in config_sample.php
fadrian06 Sep 11, 2025
1ae39b4
$rootDir variable extraction in config_sample.php
fadrian06 Sep 11, 2025
fa09cc3
Tracy\Debugger::DEVELOPMENT @deprecated use Debugger::Development
fadrian06 Sep 11, 2025
10a22a5
reduce line lengths in config_sample.php
fadrian06 Sep 11, 2025
7245c72
mark HeaderSecurityMiddleware as final
fadrian06 Sep 11, 2025
7608763
documented HeaderSecurityMiddleware::$nonce
fadrian06 Sep 11, 2025
08955d2
apply code style in HeaderSecurityMiddleware::before
fadrian06 Sep 11, 2025
6f5d0cc
treat nullable $executedRoute in HeaderSecurityMiddleware
fadrian06 Sep 11, 2025
e3d92c5
extract $oneDay variable in HeaderSecurityMiddleware::after
fadrian06 Sep 11, 2025
d36fc8b
composer require flightphp/container -W
fadrian06 Sep 11, 2025
31cf17f
fix autoload of app/utils/CustomEngine
fadrian06 Sep 11, 2025
e7a3ac2
simplify notFound route
fadrian06 Sep 11, 2025
a319e99
sort DocsLogic members
fadrian06 Sep 11, 2025
c46a506
replace $this->app->latte by $this->latte from the container
fadrian06 Sep 11, 2025
d7b7b5a
add void return types in HeaderSecurityMiddleware
fadrian06 Sep 11, 2025
c1c3d05
add Swoole\Engine validation
fadrian06 Sep 11, 2025
76abc35
change fqcn SwooleServerDriver usage for local use
fadrian06 Sep 11, 2025
d63d2df
normalize line spacing in routes.php
fadrian06 Sep 11, 2025
dfafd26
mark CustomEngine class as final
fadrian06 Sep 11, 2025
568b234
add rector --dry-run to composer lint script
fadrian06 Sep 11, 2025
30d7038
ignore StringClassNameToClassConstantRector rector rule
fadrian06 Sep 11, 2025
eab7601
remove DocsLogic::latte property for compatibility with DocsController
fadrian06 Sep 11, 2025
e240bb0
mark DocsController as final readonly and $app property as private
fadrian06 Sep 11, 2025
101fbac
set lang html attribute dinamically
fadrian06 Sep 11, 2025
f343b80
improve format of layout.latte -> head
fadrian06 Sep 11, 2025
ffaa83a
improve format of links.latte
fadrian06 Sep 11, 2025
56cea79
improve spacing in DocsLogic::compileScrollspyPage
fadrian06 Sep 11, 2025
4dddbe1
update bootstrap and bootstrap-icons
fadrian06 Sep 11, 2025
da82b9e
remove $ds variable
fadrian06 Sep 11, 2025
3a4e624
remove $app usage in config_sample.php
fadrian06 Sep 11, 2025
edea803
remove $app usage in bootstrap.php - variable remains for compatibility
fadrian06 Sep 11, 2025
fe292fb
remove $app usage in routes.php
fadrian06 Sep 12, 2025
f1a24db
fix /single-page in windows
fadrian06 Sep 12, 2025
00f736c
fix /search in windows
fadrian06 Sep 12, 2025
4a028c3
add cache singleton in the container
fadrian06 Sep 12, 2025
d7005be
empty comment to force brackets in different lines in sublime text ls…
fadrian06 Sep 12, 2025
54d6b75
improve naming in services.php
fadrian06 Sep 14, 2025
b65d78f
simplify DocsController, improve naming, typing and remove unnecesary…
fadrian06 Sep 14, 2025
af4d9de
improve spacing
fadrian06 Sep 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ app/cache/
*.sublime-*
biome.*
.runway-config.json
apm.db*
apm.db*
apm_fallback.log
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ php82 -S localhost:8000 -t public/

Please note that the additional translations are provided by ChatGPT and are not official translations. Please don't make a PR to fix a translation as when the documentation is retranslated, your contribution will be lost.

If your translation is really not good, please open an issue and we will look into possible having you maintain that translation without the assistance of ChatGPT.
If your translation is really not good, please open an issue and we will look into possible having you maintain that translation without the assistance of ChatGPT.
55 changes: 32 additions & 23 deletions app/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@
* for every request made to the application.
*/

$ds = DIRECTORY_SEPARATOR;
require_once __DIR__ . $ds . '..' . $ds . '..' . $ds . 'vendor' . $ds . 'autoload.php';
use app\utils\CustomEngine;
use app\utils\SwooleServerDriver;
use flight\Container;
use flight\Engine;

if (file_exists(__DIR__ . $ds . 'config.php') === false) {
require_once __DIR__ . '/../../vendor/autoload.php';

if (!file_exists(__DIR__ . '/config.php')) {
Flight::halt(500, 'Config file not found. Please create a config.php file in the app/config directory to get started.');
}

// this has to be hard code required because autoload hasn't been registered yet.
require_once __DIR__ . $ds . '..' . $ds . 'utils' . $ds . 'CustomFlight.php';

// It is better practice to not use static methods for everything. It makes your
// app much more difficult to unit test easily.
$app = Flight::app();
$app = Container::getInstance()->get(CustomEngine::class);
Flight::setEngine($app);

/*
* Load the config file
* P.S. When you require a php file and that file returns an array, the array
* will be returned by the require statement where you can assign it to a var.
*/
$config = require __DIR__ . $ds . 'config.php';
$app->set('config', $config);
$config = require __DIR__ . '/config.php';
Flight::set('config', $config);

// Whip out the ol' router and we'll pass that to the routes file
$router = $app->router();
$router = Flight::router();

/*
* Load the routes file. the $router variable above is passed into the routes.php
Expand All @@ -38,7 +40,7 @@
* When someone hits that URL, you point them to a function or method
* that will handle the request.
*/
require_once __DIR__ . $ds . 'routes.php';
require_once __DIR__ . '/routes.php';

/*
* You additionally could just define the routes in this file. It's up to you.
Expand All @@ -55,33 +57,40 @@
* Need caching? You can setup a Redis service
* Need to send email? You can setup a mailgun/sendgrid/whatever service to send emails.
* Need to send SMS? You can setup a Twilio service.
*
*
* All the services and how they are configured are setup in the services file.
* In many cases, services are all attached to something called a "services container"
* or more simply, a "container". The container manages if you should share the same
* service, or if you should create a new instance of the service every time you need it.
* That's a discussion for another day. Suffice to say, that Flight has a basic concept
* of a services container by registering classes to the Engine class.
*/
require_once __DIR__ . $ds . 'services.php';
require_once __DIR__ . '/services.php';

// At this point, your app should have all the instructions it needs and it'll
// "start" processing everything. This is where the magic happens.

// This is where swoole will start listening for requests and processing them.
if(!defined("NOT_SWOOLE")) {
// Require the SwooleServerDriver class since we're running in Swoole mode.
require_once(__DIR__.'/../utils/SwooleServerDriver.php');
if (!defined("NOT_SWOOLE")) {
if (!class_exists('Swoole\Runtime')) {
throw new Exception('Swoole is not installed. Please install Swoole or define the NOT_SWOOLE constant in public/index.php to run without Swoole.');
}

call_user_func('Swoole\Runtime', 'enableCoroutine');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this better than Swoole\Runtime::enableCoroutine();? I'm actually more confused why you're calling this with call_user_func()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LSP-intelephense shows me an error because Swoole classes aren't recognized

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather go for end user readability than making an LSP error go away. This just raises questions as to why it's call_user_func() like is there some hidden functionality with it that the user isn't aware of.


$swooleServerDriver = new SwooleServerDriver(
'127.0.0.1',
9501,
Container::getInstance()->get(Engine::class)
);

Swoole\Runtime::enableCoroutine();
$Swoole_Server = new app\utils\SwooleServerDriver('127.0.0.1', 9501, $app);
$Swoole_Server->start();
$swooleServerDriver->start();
} else {
$app->start();
Flight::start();
}
/*
.----..---. .--. .----. .---. .---. .-. .-. .--. .---. .----. .-. .-..----. .----..-. .-.
{ {__ {_ _}/ {} \ | {} }{_ _} {_ _}| {_} | / {} \{_ _} | {} }| { } || {} }| {} }\ \/ /
.-._} } | | / /\ \| .-. \ | | | | | { } |/ /\ \ | | | .--' | {_} || .--' | .--' } {
`----' `-' `-' `-'`-' `-' `-' `-' `-' `-'`-' `-' `-' `-' `-----'`-' `-' `--'
{ {__ {_ _}/ {} \ | {} }{_ _} {_ _}| {_} | / {} \{_ _} | {} }| { } || {} }| {} }\ \/ /
.-._} } | | / /\ \| .-. \ | | | | | { } |/ /\ \ | | | .--' | {_} || .--' | .--' } {
`----' `-' `-' `-'`-' `-' `-' `-' `-' `-'`-' `-' `-' `-' `-----'`-' `-' `--'
*/
43 changes: 18 additions & 25 deletions app/config/config_sample.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use flight\Container;
use flight\debug\tracy\TracyExtensionLoader;
use Tracy\Debugger;

Expand All @@ -10,30 +11,22 @@
error_reporting(E_ALL);

// Set the default character encoding
if (function_exists('mb_internal_encoding') === true) {
mb_internal_encoding('UTF-8');
}
mb_internal_encoding('UTF-8');

// Set the default locale
if (function_exists('setlocale') === true) {
setlocale(LC_ALL, 'en_US.UTF-8');
}
setlocale(LC_ALL, 'en_US.UTF-8');

/*
* Set some flight variables
*/
if (empty($app)) {
$app = Flight::app();
}

$app->path(__DIR__ . $ds . '..' . $ds . '..');
$app->set('flight.base_url', '/'); // if this is in a subdirectory, you'll need to change this
$app->set('flight.case_sensitive', false); // if you want case sensitive routes, set this to true
$app->set('flight.log_errors', true); // if you want to log errors, set this to true
$app->set('flight.handle_errors', false); // if you want flight to handle errors, set this to true
$app->set('flight.views.path', __DIR__ . $ds . '..' . $ds . 'views'); // set the path to your view/template/ui files
$app->set('flight.views.extension', '.php'); // set the file extension for your view/template/ui files
$app->set('flight.content_length', true); // if flight should send a content length header
Flight::path(__DIR__ . '/../..');
Flight::set('flight.base_url', '/'); // if this is in a subdirectory, you'll need to change this
Flight::set('flight.case_sensitive', false); // if you want case sensitive routes, set this to true
Flight::set('flight.log_errors', true); // if you want to log errors, set this to true
Flight::set('flight.handle_errors', false); // if you want flight to handle errors, set this to true
Flight::set('flight.views.path', __DIR__ . '/../views'); // set the path to your view/template/ui files
Flight::set('flight.views.extension', '.php'); // set the file extension for your view/template/ui files
Flight::set('flight.content_length', true); // if flight should send a content length header

/*
* Get Tracy up and running
Expand All @@ -44,26 +37,26 @@
* https://tracy.nette.org/
*/
Debugger::enable(); // auto tries to figure out your environment
// Debugger::enable(Debugger::DEVELOPMENT) // sometimes you have to be explicit (also Debugger::PRODUCTION)
// Debugger::enable(Debugger::Development); // sometimes you have to be explicit (also Debugger::PRODUCTION)
// Debugger::enable('23.75.345.200'); // you can also provide an array of IP addresses
Debugger::$logDirectory = __DIR__ . $ds . '..' . $ds . 'log';
Debugger::$logDirectory = __DIR__ . '/../log';
Debugger::$strictMode = true; // display all errors
// Debugger::$strictMode = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED; // all errors except deprecated notices

if (Debugger::$showBar) {
$app->set('flight.content_length', false); // if Debugger bar is visible, then content-length can not be set by Flight
new TracyExtensionLoader($app);
// if Debugger bar is visible, then content-length can not be set by Flight
Flight::set('flight.content_length', false);
Container::getInstance()->get(TracyExtensionLoader::class);
}

/*
/*
* This is where you will store database credentials, api credentials
* and other sensitive information. This file will not be tracked by git
* as you shouldn't be pushing sensitive information to a public or private
* repository.
*
*
* What you store here is totally up to you.
*/

define('ENVIRONMENT', 'development');

return [];
Loading