Skip to main content
Version: CANARY 🚧

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.

app/Controllers/UserController.php
namespace App\Controllers;

class UserController
{
public function index()
{
return view("users.index");
}
}

Models/​

Models represent your database tables.

app/Models/User.php
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:

app/Kernel.php
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.

FileDescription
app.phpGeneral configuration (name, timezone, locale)
database.phpDatabase connections
mail.phpSMTP configuration and email drivers
storage.phpStorage disks (local, S3, FTP)
view.phpTemplate engine and cache
session.phpSession management
cache.phpCache configuration

The routes/ folder​

Defines the entry points of your API or web application.

routes/app.php
$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.

Security

Configure your web server to point to this folder only. Never expose the other folders.

The var/ folder​

Files generated automatically by the application.

SubfolderDescription
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)
Permissions

Make sure the web server has write permissions on var/.

The .env.json file​

Sensitive environment variables (not versioned):

.env.json
{
"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​

Code organization
  • 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.