βοΈ Configuration in Squehub
Squehub provides a flexible configuration system that separates core settings from environment-specific variables and project logic. This helps developers maintain a clean, secure, and scalable architecture.
π Main Configuration Files
.env
β Environment-specific variables (not committed to Git)./config/
β Directory containing modular config files such as:debug.php
β Configuration for error reporting and debug mode.mail.php
β Email driver and SMTP credentials.- Other optional config files like
cache.php
,services.php
, etc.
π§ͺ .env File
This file stores sensitive environment variables. It is automatically loaded and should be excluded from version control.
APP_NAME=Squehub
APP_URL=http://localhost
APP_DEBUG=true
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp
DB_USERNAME=root
DB_PASSWORD=
πͺ² config/debug.php
This file handles how your application displays and manages errors depending on whether DEBUG_MODE
is enabled. Itβs automatically loaded by the framework to configure error reporting at runtime.
When debug mode is enabled, Squehub uses the filp/whoops
package to show friendly
and informative error pages. In production, errors are hidden from the browser for security.
<?php
// config/debug.php
use Whoops\Run;
use App\Core\Exceptions\CustomPrettyPageHandler;
$whoops = new Run();
$whoops->pushHandler(new CustomPrettyPageHandler());
$whoops->register();
if (DEBUG_MODE) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (class_exists(\Whoops\Run::class)) {
$whoops = new \Whoops\Run;
$handler = new \Whoops\Handler\PrettyPageHandler;
$handler->setPageTitle("Squehub Debug Mode - An Error Occurred");
$whoops->pushHandler($handler);
$whoops->register();
} else {
echo '<div style="background: #111; color: #fff; padding: 10px; font-family: monospace;">
<strong>Website Debug Mode Is ON</strong> - Install <code>filp/whoops</code> for better error UI.
</div>';
}
} else {
error_reporting(0);
ini_set('display_errors', 0);
}
if (DEBUG_MODE) {
echo '<div style="
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background: #1f1f1f;
color: #fff;
padding: 10px;
font-size: 14px;
font-family: monospace;
z-index: 9999;
border-top: 1px solid #444;
">
βοΈ DEBUG MODE: ON; Squehub Debug Bar β Loaded at: ' . date('H:i:s') . '
</div>';
}
β οΈ Tip: Always keep DEBUG_MODE
set to false
in production
environments to prevent sensitive information from being exposed.
π οΈ Note: You can enable or disable debug mode by setting DEBUG_MODE=true
or
false
in your .env
file.
π Modular Config Files
Located inside /config/
, these files keep specific settings organized:
mail.php
β Email driver and credentialsdebug.php
β Controls error display and modeservices.php
β External APIs and integrations (optional)cache.php
β Caching options (optional)
Example: config/mail.php
<?php
// config/mail.php
return [
'host' => 'smtp.example.com',
'port' => '587',
'username' => 'noreply@example.com',
'password' => 'sample-password-123!',
'encryption' => 'tls',
'from_address' => 'noreply@example.com',
'from_name' => 'Example App Mailer'
];
π§ Accessing Config Values
Use the global config()
helper in your code:
$appName = config('app_name');
$mailHost = config('mail.host');
π§© Project Directory Configuration
The /project/
folder is where your app-specific code lives. You donβt need extra config files to
register these classes β Squehub automatically loads them.
π Controllers β /project/controllers
Create controller classes here. They automatically respond to routes via Controller@method
format.
namespace Project\Controllers;
class UserController {
public function index() {
return View::render('user.index');
}
}
π Models β /project/Models
Create models that extend the base Model
class. You can configure table name, primary key, etc.
namespace Project\Models;
use App\Core\Model;
class User extends Model {
protected static \$table = 'users';
protected static \$primaryKey = 'id';
}
π Middleware β /project/Middleware
Write custom logic that intercepts requests before reaching a controller.
namespace Project\Middleware;
class AuthMiddleware {
public function handle(\$request, \$next) {
if (!isset(\$_SESSION['user_id'])) {
return redirect('/login');
}
return \$next(\$request);
}
}
π¦ Packages β /project/Package
Drop your custom reusable modules here. You can organize by vendor/package and include config files inside the package directory.
π Routes β /project/Routes
Squehub scans this directory and loads all route files. You can split routes by module or feature:
\$router->add('GET', '/users', 'UserController@index');
\$router->add('POST', '/user/store', 'UserController@store');
π‘ Tip:
/project/
rather than modifying /app/
. The
/app
folder is reserved for framework internals.