stougeiro / app
A PHP 8.2 application foundation for shared hosting, built on the Stougeiro runtime and module contracts.
Fund package maintenance!
Requires
- php: >=8.2
- ext-pdo: *
- ext-pdo_sqlite: *
- stougeiro/base: ^0.5.0
- stougeiro/base-contract: ^0.1.1
- stougeiro/cache: ^2.0
- stougeiro/container: ^4.0
- stougeiro/event: ^1.0
- stougeiro/http: ^2.2
- stougeiro/pdo-database: ^1.0
- stougeiro/router: ^1.0
- stougeiro/session: ^2.0
- stougeiro/view: ^2.0
Requires (Dev)
- pestphp/pest: ^3.8
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-03 03:38:25 UTC
README
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 inpublic_html/. - Explicit wiring: providers in
provider/, modules inapp/. - 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
YYYYMMDDfile 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_sqlitefor the default database configuration.- Apache with
mod_rewritefor the front controller. - A writable
application/storagedirectory.
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:
- install dependencies externally with
--no-dev; - upload
application/,public_html/andvendor/to the server; - create
application/env.json; - make
application/storagewritable by the application user; - 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.