Left Icon Right Icon
Squehub SqueHub

βš™οΈ 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 credentials
  • debug.php – Controls error display and mode
  • services.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:

For best structure, group your code in /project/ rather than modifying /app/. The /app folder is reserved for framework internals.
;