Skip to content

Refactors #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e2b2152
chore(composer.json): add faslatam author
fadrian06 Mar 10, 2025
ddf5b8a
composer require flightphp/container -W
fadrian06 Mar 10, 2025
30e74da
chore: improve rector and phpstan configurations
fadrian06 Mar 10, 2025
0b3cfa5
composer require phpunit/phpunit --dev -W
fadrian06 Mar 10, 2025
96683ce
ci: add php workflow
fadrian06 Mar 10, 2025
4317e29
fix(ci): add automatic config creation
fadrian06 Mar 10, 2025
2ed7cfc
fix(ci): invalid path app/cache in linux
fadrian06 Mar 10, 2025
77c240d
npm i husky -D
fadrian06 Mar 10, 2025
636eeeb
fix(ci): remove rector from ci, until all migration be completed
fadrian06 Mar 10, 2025
635d6f0
style(tests): format braces to k&r
fadrian06 Mar 11, 2025
a4aa344
tests(e2e): add tests for bootstrap, routes and about
fadrian06 Mar 11, 2025
437f176
composer require phpstan/phpstan-deprecation-rules --dev -W
fadrian06 Mar 13, 2025
6c82d6c
tests(e2e): add install page test
fadrian06 Mar 13, 2025
5bd10e7
refactor(bootstrap.php): removed unnecesary $ds
fadrian06 Mar 13, 2025
3673258
refactor(CustomFlight): removed unused by interpreted code class
fadrian06 Mar 13, 2025
35b2296
refactor($app): removed $app
fadrian06 Mar 13, 2025
7de5cf5
chore(composer.json): setup composer autoloader
fadrian06 Mar 13, 2025
b5d7f61
feat(config): improve config handling
fadrian06 Mar 13, 2025
82ec92d
refactor($router): removed unused global $router
fadrian06 Mar 13, 2025
4218ad8
composer require symfony/polyfill-mbstring -W
fadrian06 Mar 13, 2025
ba9f6f1
refactor(config): setlocale comes with php since version 4
fadrian06 Mar 13, 2025
cc11d71
composer require flightphp/container:^1.1 -W
fadrian06 Mar 13, 2025
203895c
refactor(config): removed $app
fadrian06 Mar 13, 2025
32db61a
refactor(config): removed duplicated and deprecated configurations
fadrian06 Mar 13, 2025
67a3656
style(routes): format using LSP-intelephense per mode
fadrian06 Mar 13, 2025
23e40df
refactor(routes): simplified middleware usage
fadrian06 Mar 13, 2025
d018b10
refactor(routes): simplified routes registration, improve code readab…
fadrian06 Mar 13, 2025
b421340
tests(unit): ConfigTest, DocsLogicTest and TranslatorTest
fadrian06 Mar 15, 2025
73e0baa
Merge master
fadrian06 Mar 15, 2025
d01fe94
merge master
fadrian06 Mar 20, 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
39 changes: 39 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHP Composer

on:
push:
branches: [ "main", "refactors" ]
pull_request:
branches: [ "main", "refactors" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Start PHP Development Server
run: php -S localhost:61001 -t public &

- name: Run ci suite
run: composer run-script ci
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ app/cache/
.DS_Store
*.sublime-*
biome.*
.phpunit.result.cache
node_modules/
tests/cache/
.coverage
.runway-config.json
apm.db*
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer validate --no-ansi
composer ci
6 changes: 6 additions & 0 deletions .runway-config-sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"apm": {
"source_type": "sqlite",
"dest_db_dsn": "sqlite::memory:"
}
}
27 changes: 9 additions & 18 deletions app/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,20 @@
* for every request made to the application.
*/

$ds = DIRECTORY_SEPARATOR;
require_once __DIR__ . $ds . '..' . $ds . '..' . $ds . 'vendor' . $ds . 'autoload.php';
use app\utils\Config;

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();

/*
* 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);

// Whip out the ol' router and we'll pass that to the routes file
$router = $app->router();
Flight::set('config', new Config(require __DIR__ . '/config.php'));

/*
* Load the routes file. the $router variable above is passed into the routes.php
Expand All @@ -38,7 +28,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 @@ -63,11 +53,12 @@
* 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.
$app->start();
Flight::start();

/*
.----..---. .--. .----. .---. .---. .-. .-. .--. .---. .----. .-. .-..----. .----..-. .-.
{ {__ {_ _}/ {} \ | {} }{_ _} {_ _}| {_} | / {} \{_ _} | {} }| { } || {} }| {} }\ \/ /
Expand Down
35 changes: 10 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,13 @@
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');
}

/*
* Set some flight variables
*/
if (empty($app)) {
$app = Flight::app();
}
setlocale(LC_ALL, 'en_US.UTF-8');

$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::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

/*
* Get Tracy up and running
Expand All @@ -44,15 +28,16 @@
* 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 bar is visible, then content-length can not be set by Flight
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);
Flight::set('flight.content_length', false);
(new Container)->get(TracyExtensionLoader::class);
}

/*
Expand Down
Loading
Loading