Skip to content

Commit 0d3c369

Browse files
committed
adjustments to reorder and recomment some core configs
1 parent 6108454 commit 0d3c369

File tree

4 files changed

+155
-92
lines changed

4 files changed

+155
-92
lines changed

app/config/bootstrap.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,6 @@
2323
*/
2424
$config = require('config.php');
2525

26-
// Whip out the ol' router and we'll pass that to the routes file
27-
$router = $app->router();
28-
29-
/*
30-
* Load the routes file. the $router variable above is passed into the routes.php
31-
* file below so that you can define routes in that file.
32-
* A route is really just a URL, but saying route makes you sound cooler.
33-
* When someone hits that URL, you point them to a function or method
34-
* that will handle the request.
35-
*/
36-
require('routes.php');
37-
/*
38-
* You additionally could just define the routes in this file. It's up to you.
39-
* Example:
40-
$router->get('/', function() {
41-
echo 'Hello World!';
42-
});
43-
*/
44-
4526
/*
4627
* Load the services file.
4728
* A "service" is basically something special that you want to use in your app.
@@ -59,6 +40,18 @@
5940
*/
6041
require('services.php');
6142

43+
// Whip out the ol' router and we'll pass that to the routes file
44+
$router = $app->router();
45+
46+
/*
47+
* Load the routes file. the $router variable above is passed into the routes.php
48+
* file below so that you can define routes in that file.
49+
* A route is really just a URL, but saying route makes you sound cooler.
50+
* When someone hits that URL, you point them to a function or method
51+
* that will handle the request.
52+
*/
53+
require('routes.php');
54+
6255
// At this point, your app should have all the instructions it needs and it'll
6356
// "start" processing everything. This is where the magic happens.
6457
$app->start();

app/config/config_sample.php

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,83 @@
11
<?php
22

3-
use flight\debug\tracy\TracyExtensionLoader;
4-
use Tracy\Debugger;
3+
/**********************************************
4+
* FlightPHP Skeleton Sample Config *
5+
**********************************************
6+
*
7+
* Copy this file to config.php and update values as needed.
8+
* All settings are required unless marked as optional.
9+
*
10+
* Example:
11+
* cp app/config/config_sample.php app/config/config.php
12+
*
13+
* This file is NOT tracked by git. Store sensitive credentials here.
14+
**********************************************/
515

6-
// Set the default timezone
7-
date_default_timezone_set('America/New_York');
16+
/**********************************************
17+
* Application Environment *
18+
**********************************************/
19+
// Set your timezone (e.g., 'America/New_York', 'UTC')
20+
date_default_timezone_set('UTC');
821

9-
// Set the error reporting level
22+
// Error reporting level (E_ALL recommended for development)
1023
error_reporting(E_ALL);
1124

12-
// Set the default character encoding
13-
if(function_exists('mb_internal_encoding') === true) {
25+
// Character encoding
26+
if (function_exists('mb_internal_encoding') === true) {
1427
mb_internal_encoding('UTF-8');
1528
}
1629

17-
// Set the default locale
18-
if(function_exists('setlocale') === true) {
30+
// Default Locale Change as needed or feel free to remove.
31+
if (function_exists('setlocale') === true) {
1932
setlocale(LC_ALL, 'en_US.UTF-8');
2033
}
2134

35+
/**********************************************
36+
* FlightPHP Core Settings *
37+
**********************************************/
38+
2239
// Get the $app var to use below
23-
if(empty($app)) {
40+
if (empty($app) === true) {
2441
$app = Flight::app();
2542
}
2643

27-
// if you want to load classes that have underscores in them, comment out the following line
28-
// Loader::setV2ClassLoading(false);
29-
3044
// This autoloads your code in the app directory so you don't have to require_once everything
45+
// You'll need to namespace your classes with "app\folder\" to include them properly
3146
$app->path(__DIR__ . $ds . '..' . $ds . '..');
3247

33-
// This is where you can set some flight config variables.
34-
$app->set('flight.base_url', '/'); // if this is in a subdirectory, you'll need to change this
35-
$app->set('flight.case_sensitive', false); // if you want case sensitive routes, set this to true
36-
$app->set('flight.log_errors', true); // if you want to log errors, set this to true
37-
$app->set('flight.handle_errors', false); // if you want flight to handle errors, set this to true, otherwise Tracy will handle them
38-
$app->set('flight.views.path', __DIR__ . $ds . '..' . $ds . 'views'); // set the path to your view/template/ui files
39-
$app->set('flight.views.extension', '.php'); // set the file extension for your view/template/ui files
40-
$app->set('flight.content_length', false); // if flight should send a content length header
48+
// Core config variables
49+
$app->set('flight.base_url', '/',); // Base URL for your app. Change if app is in a subdirectory (e.g., '/myapp/')
50+
$app->set('flight.case_sensitive', false); // Set true for case sensitive routes. Default: false
51+
$app->set('flight.log_errors', true); // Log errors to file. Recommended: true in production
52+
$app->set('flight.handle_errors', false); // Let Tracy handle errors if false. Set true to use Flight's error handler
53+
$app->set('flight.views.path', __DIR__ . $ds . '..' . $ds . 'views'); // Path to views/templates
54+
$app->set('flight.views.extension', '.php'); // View file extension (e.g., '.php', '.latte')
55+
$app->set('flight.content_length', false); // Send content length header. Usually false unless required by proxy
4156

42-
/*
43-
* Get Tracy up and running
44-
*
45-
* There lots of setup options for Tracy! Logs, emails, clicking to
46-
* open in your editor and a lot more!
47-
* Check out the docs here:
48-
* https://tracy.nette.org/
49-
*/
50-
Debugger::enable(); // auto tries to figure out your environment
51-
// Debugger::enable(Debugger::DEVELOPMENT) // sometimes you have to be explicit (also Debugger::PRODUCTION)
52-
// Debugger::enable('23.75.345.200'); // you can also provide an array of IP addresses
53-
Debugger::$logDirectory = __DIR__ . $ds . '..' . $ds . 'log';
54-
Debugger::$strictMode = true; // display all errors
55-
// Debugger::$strictMode = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED; // all errors except deprecated notices
56-
if (Debugger::$showBar && php_sapi_name() !== 'cli') {
57-
(new TracyExtensionLoader($app));
58-
}
59-
60-
/*
61-
* This is where you will store database credentials, api credentials
62-
* and other sensitive information. This file will not be tracked by git
63-
* as you shouldn't be pushing sensitive information to a public or private
64-
* repository.
65-
*
66-
* What you store here is totally up to you.
67-
*/
57+
/**********************************************
58+
* User Configuration *
59+
**********************************************/
6860
return [
61+
/**************************************
62+
* Database Settings *
63+
**************************************/
6964
'database' => [
70-
// uncomment the below 4 lines for mysql
71-
// 'host' => 'localhost',
72-
// 'dbname' => 'dbname',
73-
// 'user' => 'user',
74-
// 'password' => 'password'
65+
// MySQL Example:
66+
// 'host' => 'localhost', // Database host (e.g., 'localhost', 'db.example.com')
67+
// 'dbname' => 'your_db_name', // Database name (e.g., 'flightphp')
68+
// 'user' => 'your_username', // Database user (e.g., 'root')
69+
// 'password' => 'your_password', // Database password (never commit real passwords)
7570

76-
// uncomment the following line for sqlite
77-
// 'file_path' => __DIR__ . $ds . '..' . $ds . 'database.sqlite'
71+
// SQLite Example:
72+
// 'file_path' => __DIR__ . $ds . '..' . $ds . 'database.sqlite', // Path to SQLite file
7873
],
7974

80-
// this is just here for an example
75+
// Google OAuth Credentials
8176
// 'google_oauth' => [
82-
// 'client_id' => 'client_id',
83-
// 'client_secret' => 'client_secret',
84-
// 'redirect_uri' => 'redirect_uri'
77+
// 'client_id' => 'your_client_id', // Google API client ID
78+
// 'client_secret' => 'your_client_secret', // Google API client secret
79+
// 'redirect_uri' => 'your_redirect_uri', // Redirect URI for OAuth callback
8580
// ],
81+
82+
// Add more configuration sections below as needed
8683
];

app/config/routes.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
echo '<h1>Hello world! Oh hey '.$name.'!</h1>';
1717
});
1818

19-
$router->group('/api', function() use ($router, $app) {
20-
$Api_Example_Controller = new ApiExampleController($app);
21-
$router->get('/users', [ $Api_Example_Controller, 'getUsers' ]);
22-
$router->get('/users/@id:[0-9]', [ $Api_Example_Controller, 'getUser' ]);
23-
$router->post('/users/@id:[0-9]', [ $Api_Example_Controller, 'updateUser' ]);
19+
$router->group('/api', function() use ($router) {
20+
$router->get('/users', [ ApiExampleController::class, 'getUsers' ]);
21+
$router->get('/users/@id:[0-9]', [ ApiExampleController::class, 'getUser' ]);
22+
$router->post('/users/@id:[0-9]', [ ApiExampleController::class, 'updateUser' ]);
2423
});

app/config/services.php

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,100 @@
33
use flight\Engine;
44
use flight\database\PdoWrapper;
55
use flight\debug\database\PdoQueryCapture;
6+
use flight\debug\tracy\TracyExtensionLoader;
67
use Tracy\Debugger;
78

8-
/**
9-
* @var array $config This comes from the returned array at the bottom of the config.php file
10-
* @var Engine $app
11-
*/
9+
/*********************************************
10+
* FlightPHP Service Setup *
11+
*********************************************
12+
* This file registers services and integrations
13+
* for your FlightPHP application. Edit as needed.
14+
*
15+
* @var array $config From config.php
16+
* @var Engine $app FlightPHP app instance
17+
**********************************************/
1218

13-
// Uncomment the following line for MySQL
19+
20+
21+
/*********************************************
22+
* Session Service Setup *
23+
*********************************************
24+
* To enable sessions in FlightPHP, register the session service.
25+
* Docs: https://docs.flightphp.com/en/v3/awesome-plugins/session
26+
*
27+
* Example:
28+
* $app->register('session', \flight\session\Session::class, [
29+
* [
30+
* 'cookie_name' => 'flight_session', // Name of the session cookie
31+
* 'timeout' => 3600, // Session timeout in seconds
32+
* // ...other options...
33+
* ]
34+
* ]);
35+
*
36+
* For advanced options, see the plugin documentation above.
37+
**********************************************/
38+
39+
/*********************************************
40+
* Tracy Debugger Setup *
41+
*********************************************
42+
* Tracy is a powerful error handler and debugger for PHP.
43+
* Docs: https://tracy.nette.org/
44+
*
45+
* Key Tracy configuration options:
46+
* - Debugger::enable([mode], [ip]);
47+
* - mode: Debugger::Development or Debugger::Production
48+
* - ip: restrict debug bar to specific IP(s)
49+
* - Debugger::$logDirectory: where error logs are stored
50+
* - Debugger::$strictMode: show all errors (true/E_ALL), or filter out deprecated notices
51+
* - Debugger::$showBar: show/hide debug bar (auto-detected, can be forced)
52+
* - Debugger::$maxLen: max length of dumped variables
53+
* - Debugger::$maxDepth: max depth of dumped structures
54+
* - Debugger::$editor: configure clickable file links (see docs)
55+
* - Debugger::$email: send error notifications to email
56+
*
57+
* Example Tracy setups:
58+
* Debugger::enable(); // Auto-detects environment
59+
* Debugger::enable(Debugger::Development); // Explicitly set environment
60+
* Debugger::enable('23.75.345.200'); // Restrict debug bar to specific IPs
61+
*
62+
* For more options, see https://tracy.nette.org/en/configuration
63+
**********************************************/
64+
Debugger::enable(); // Auto-detects environment
65+
// Debugger::enable(Debugger::Development); // Explicitly set environment
66+
// Debugger::enable('23.75.345.200'); // Restrict debug bar to specific IPs
67+
Debugger::$logDirectory = __DIR__ . $ds . '..' . $ds . 'log'; // Log directory
68+
Debugger::$strictMode = true; // Show all errors (set to E_ALL & ~E_DEPRECATED for less noise)
69+
// Debugger::$maxLen = 1000; // Max length of dumped variables (default: 150)
70+
// Debugger::$maxDepth = 5; // Max depth of dumped structures (default: 3)
71+
// Debugger::$editor = 'vscode'; // Enable clickable file links in debug bar
72+
// Debugger::$email = '[email protected]'; // Send error notifications
73+
if (Debugger::$showBar === true && php_sapi_name() !== 'cli') {
74+
(new TracyExtensionLoader($app)); // Load FlightPHP Tracy extensions
75+
}
76+
77+
/**********************************************
78+
* Database Service Setup *
79+
**********************************************/
80+
// Uncomment and configure the following for your database:
81+
82+
// MySQL Example:
1483
// $dsn = 'mysql:host=' . $config['database']['host'] . ';dbname=' . $config['database']['dbname'] . ';charset=utf8mb4';
1584

16-
// Uncomment the following line for SQLite
85+
// SQLite Example:
1786
// $dsn = 'sqlite:' . $config['database']['file_path'];
1887

19-
// Uncomment the below lines if you want to add a Flight::db() service
20-
// In development, you'll want the class that captures the queries for you. In production, not so much.
88+
// Register Flight::db() service
89+
// In development, use PdoQueryCapture to log queries; in production, use PdoWrapper for performance.
2190
// $pdoClass = Debugger::$showBar === true ? PdoQueryCapture::class : PdoWrapper::class;
2291
// $app->register('db', $pdoClass, [ $dsn, $config['database']['user'] ?? null, $config['database']['password'] ?? null ]);
2392

24-
// Got google oauth stuff? You could register that here
93+
/**********************************************
94+
* Third-Party Integrations *
95+
**********************************************/
96+
// Google OAuth Example:
2597
// $app->register('google_oauth', Google_Client::class, [ $config['google_oauth'] ]);
2698

27-
// Redis? This is where you'd set that up
99+
// Redis Example:
28100
// $app->register('redis', Redis::class, [ $config['redis']['host'], $config['redis']['port'] ]);
101+
102+
// Add more service registrations below as needed

0 commit comments

Comments
 (0)