Application Structure
Overviewβ
BowPHP follows the MVC (Model-View-Controller) pattern, a proven architecture that clearly separates the responsibilities of your application.
bow-app/
βββ app/ # Application logic
β βββ Configurations/ # Custom configurations
β βββ Controllers/ # HTTP controllers
β βββ Events/ # Event handlers
β βββ Exceptions/ # Custom exceptions
β βββ Listeners/ # Event listeners
β βββ Middlewares/ # HTTP middlewares
β βββ Models/ # Data models (ORM)
β βββ Commands/ # Custom console commands
β βββ Services/ # Business services
β βββ Tasks/ # Asynchronous tasks (Queue)
β βββ Validations/ # Validation rules
β βββ Kernel.php # Kernel configuration
βββ assets/ # Frontend resources (sources)
β βββ css/ # CSS files
β βββ js/ # JavaScript files
β βββ sass/ # SCSS files
βββ config/ # Configuration files
β βββ app.php # General configuration
β βββ database.php # Database configuration
β βββ mail.php # Email configuration
β βββ storage.php # Storage configuration
β βββ view.php # View configuration
βββ lang/ # Translation files
β βββ en/ # English translations
β βββ fr/ # French translations
βββ migrations/ # Database migrations
βββ public/ # Web entry point (documentroot)
β βββ index.php # Front controller
β βββ css/ # Compiled CSS
β βββ js/ # Compiled JS
βββ routes/ # Route definitions
β βββ app.php # Application routes
βββ seeders/ # Data seeders
βββ templates/ # Tintin views
β βββ layouts/ # Shared layouts
β βββ partials/ # Reusable components
βββ tests/ # Unit and functional tests
βββ var/ # Generated files
β βββ cache/ # Application cache
β βββ logs/ # Error logs
β βββ session/ # User sessions
β βββ storage/ # Uploaded files
β βββ view/ # Compiled view cache
βββ .env.json # Environment variables
βββ bow # Bow Console CLI
βββ composer.json # PHP dependencies
βββ package.json # Node.js dependencies
The app/ folderβ
The heart of your application. This is where you write your business logic.
Controllers/β
Controllers handle HTTP requests and return responses.
namespace App\Controllers;
class UserController
{
public function index()
{
return view("users.index");
}
}
Models/β
Models represent your database tables.
namespace App\Models;
use Bow\Database\Barry\Model;
class User extends Model
{
protected string $table = "users";
}
Services/β
Services encapsulate complex business logic. See the services documentation.
Middlewares/β
Middlewares filter HTTP requests. See the middlewares documentation.
Events/ and Listeners/β
An event system to decouple your application. See the events documentation.
Tasks/β
Asynchronous tasks executed in the background via the queue. See the tasks documentation.
Kernel.phpβ
Configures the application bootstrap:
namespace App;
use Bow\Configuration\Loader;
class Kernel extends Loader
{
public function configurations(): array
{
return [
// List of providers to load
\Bow\Database\DatabaseConfiguration::class,
\Bow\Mail\MailConfiguration::class,
];
}
public function middlewares(): array
{
return [
"auth" => \App\Middlewares\AuthMiddleware::class,
];
}
}
The config/ folderβ
Contains all of the application's configuration files.
| File | Description |
|---|---|
app.php | General configuration (name, timezone, locale) |
database.php | Database connections |
mail.php | SMTP configuration and email drivers |
storage.php | Storage disks (local, S3, FTP) |
view.php | Template engine and cache |
session.php | Session management |
cache.php | Cache configuration |
The routes/ folderβ
Defines the entry points of your API or web application.
$app->get("/", "HomeController::index");
$app->get("/users", "UserController::index");
$app->post("/users", "UserController::store");
$app->get("/users/:id", "UserController::show");
The templates/ folderβ
Your Tintin views (or Twig/Blade depending on configuration).
templates/
βββ layouts/
β βββ app.tintin.php # Main layout
βββ partials/
β βββ header.tintin.php # Header
β βββ footer.tintin.php # Footer
βββ home.tintin.php # Home page
βββ users/
βββ index.tintin.php # User list
βββ show.tintin.php # User details
The public/ folderβ
The only folder accessible from the web.
Configure your web server to point to this folder only. Never expose the other folders.
The var/ folderβ
Files generated automatically by the application.
| Subfolder | Description |
|---|---|
cache/ | Application cache (config, routes) |
logs/ | Log files (errors, debug) |
session/ | Session files (if using the file driver) |
storage/ | Files uploaded by users |
view/ | Compiled views (cache) |
Make sure the web server has write permissions on var/.
The .env.json fileβ
Sensitive environment variables (not versioned):
{
"APP_NAME": "Mon Application",
"APP_ENV": "development",
"APP_DEBUG": true,
"APP_URL": "http://localhost:8080",
"DB_CONNECTION": "mysql",
"DB_HOST": "127.0.0.1",
"DB_DATABASE": "bow_app",
"DB_USERNAME": "root",
"DB_PASSWORD": ""
}
Best practicesβ
- One file = one class: Follow the PSR-4 conventions.
- Explicit naming:
UserController,PaymentService,OrderCreatedEvent. - Separation of concerns: Keep controllers thin, put logic in services.
- Centralized configuration: Use
config/and.env.json.
Is something missing?
If you run into problems with the documentation or have suggestions to improve the documentation or the project in general, please open an issue for us, or send a tweet mentioning the Twitter account @bowframework or directly on github.