Search by

A PHP 8.2 application foundation for shared hosting, built on the Stougeiro runtime and module contracts.

Package info

github.com/stougeiro/app

Type:project

pkg:composer/stougeiro/app

Fund package maintenance!

Buymeacoffee

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.0 2026-11-03 03:28 UTC

This package is auto-updated.

Last update: 2026-11-03 03:38:25 UTC


README

PHP PHPStan-Level Pest-php License

App

A small PHP 8.2 application foundation for shared hosting.

The application runs on Apache with PHP-FPM/mod_php and follows the shared-hosting layout: the application lives outside the public directory, while public_html contains only the front controller, .htaccess and public assets.

It is built on stougeiro/base, stougeiro/base-contract, stougeiro/router, stougeiro/http, stougeiro/view, stougeiro/cache, stougeiro/session, stougeiro/event and stougeiro/pdo-database.

The goal is an explicit, inspectable application with no hidden module discovery, no build step required at runtime, and behavior that is predictable on ordinary shared servers.

See ARCHITECTURE.md for boundaries and AGENTS.md for the operational rules used by agents and contributors.

โœจ Features

  • Shared-hosting layout: application in application/, web root in public_html/.
  • Explicit wiring: providers in provider/, modules in app/.
  • Module example: HelloWorld controller, view and middlewares.
  • Error handling: separate development and production error pages.
  • Log separation: application errors, security events and PHP errors are written to different files.
  • Daily logs: application logs use YYYYMMDD file suffixes.
  • Services: cache, view, session, events, routing, database and logging are registered explicitly.
  • Security primitives: optional CSRF, rate limit and security headers middleware under core/Security.
  • Docker development: PHP 8.2 + Apache with the vendor directory kept inside the image.
  • Quality tooling: PHPStan Level 9 and a Pest suite.

๐Ÿ“ฆ Installation

Requirements

  • PHP 8.2 or newer.
  • ext-json.
  • ext-pdo_sqlite for the default database configuration.
  • Apache with mod_rewrite for the front controller.
  • A writable application/storage directory.

Local setup

git clone https://github.com/stougeiro/app.git
cd app

composer install
cp application/env-example.json application/env.json

For production dependencies, generate the vendor externally:

composer install --no-dev --optimize-autoloader

๐Ÿ“ Layout

.
โ”œโ”€โ”€ application/
โ”‚   โ”œโ”€โ”€ modules/      application modules
โ”‚   โ”œโ”€โ”€ bootstrap/    runtime bootstrap
โ”‚   โ”œโ”€โ”€ config/       application configuration
โ”‚   โ”œโ”€โ”€ core/         app-level foundations
โ”‚   โ”œโ”€โ”€ database/     database-facing code
โ”‚   โ”œโ”€โ”€ provider/     service providers
โ”‚   โ””โ”€โ”€ storage/      cache, logs, sessions and temporary files
โ”œโ”€โ”€ public_html/      document root
โ”œโ”€โ”€ tests/            Pest tests
โ”œโ”€โ”€ vendor/           Composer dependencies
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ composer.lock
โ”œโ”€โ”€ phpunit.xml
โ””โ”€โ”€ phpstan.neon

The application must never be exposed through the web server. The document root is public_html.

โš™๏ธ Configuration

Environment:

{
    "environment": "development"
}

Use production on a deployed server.

Providers and modules are declared explicitly:

// application/config/app.php
return [
    'providers' => [
        // ...
    ],

    'modules' => [
        // ...
    ],
];

The default database configuration uses SQLite in application/storage.

๐Ÿงพ Logging

Logs are written under:

application/storage/log/

Files are separated by purpose and date:

error-YYYYMMDD.log
security-YYYYMMDD.log
php-error-YYYYMMDD.log
  • error-*: application 5xx errors;
  • security-*: request 4xx events such as 404 and 405;
  • php-error-*: PHP-level errors and the final fallback.

The php-error daily path is configured on a best-effort basis. If the hosting environment blocks ini_set, the application keeps running and the host/PHP configuration remains in use.

Log retention is an operational concern and is not implemented by the application.

๐Ÿณ Docker development

Docker is a development convenience, not a production requirement.

# from the repository root
composer install
docker compose up -d

Open:

http://localhost/

The development container uses PHP 8.2 + Apache, serves public_html as the document root, keeps vendor/ inside the image and bind-mounts application/ for real-time code and log inspection.

Apache access and error logs are also written under application/storage/log in the Docker environment.

๐Ÿš€ Shared hosting

The production deployment is a normal PHP application. Docker is not required.

application/   -> application directory outside the web root
public_html/   -> web root
vendor/        -> Composer dependencies outside the web root

Steps:

  1. install dependencies externally with --no-dev;
  2. upload application/, public_html/ and vendor/ to the server;
  3. create application/env.json;
  4. make application/storage writable by the application user;
  5. point the document root to public_html.

On shared hosting, Apache access/error logs and HTTP-level rate limiting usually belong to the provider. Application logs remain under application/storage/log.

๐Ÿงช Development

From the repository root:

composer validate
composer stan
composer pest

The test suite covers the application bootstrap, module rendering, error pages, log classification and daily PHP error log configuration.

๐Ÿง  Why?

Shared hosting is heterogeneous and constrained. The application is designed around those limits:

  • no long-running workers or persistent application state;
  • the web root is a fixed public directory;
  • dependencies are resolved before deployment;
  • modules and providers are explicit and easy to inspect;
  • error handling and logs remain useful without requiring platform-specific infrastructure.

Contracts live in stougeiro/base-contract; the FPM runtime lives in stougeiro/base; this repository shows how the application wires both together.

๐Ÿค Contributions

Contributions are welcome. Feel free to open issues or submit pull requests.