Skip to content

Configuration

lpachecob edited this page Mar 24, 2026 · 4 revisions

⚙️ Configuration: boundly.php

Everything in BOUNDLY can be customized. The configuration file config/boundly.php is the bridge between your domain and the infrastructure layer.

All values support .env overrides for clean environment separation.


🔝 locale

The default language for CLI output and system messages.

Value Default Description
'en' English
'es' Spanish
BOUNDLY_LOCALE=es

🌐 api_prefix

The URL segment for all auto-generated endpoints.

Default Description
'api' Generates routes like /api/users, /api/posts, etc.
BOUNDLY_API_PREFIX=v1

📂 paths

Where BOUNDLY's discovery engine scans for your code.

Key Default Description
domain base_path('Domain') Path scanned for #[Entity] attributes.
application base_path('Application') Path scanned for #[Action] attributes.

disable_cache

Controls whether the framework uses the static metadata cache.

Value Behavior
false (default in production) Reads from bootstrap/cache/boundly.php — zero overhead.
true (default in local) Scans and reflects on every request — always fresh.
# Force disable cache during development
BOUNDLY_DISABLE_CACHE=true

⚠️ Note: Run php artisan core:cache before deploying to production. The cache is automatically disabled on APP_ENV=local.


🛡️ auth.default_guard

The Laravel auth guard used by the #[Authorize] middleware when no explicit guard is specified.

Default Description
'sanctum' Works with Laravel Sanctum tokens out of the box.
BOUNDLY_AUTH_GUARD=api

📄 pagination

Controls the default page size for the generic CRUD list endpoint.

Key Default Description
default_per_page 15 Items returned when per_page is not specified.
max_per_page 100 Hard cap to prevent clients from requesting millions of rows.
BOUNDLY_PER_PAGE=20
BOUNDLY_MAX_PER_PAGE=200

rate_limit

Controls API rate limiting to prevent abuse and ensure fair usage.

Key Default Description
enabled true Enable or disable rate limiting globally.
max_attempts 60 Maximum requests allowed per time window.
decay_minutes 1 Time window in minutes before attempts reset.
prefix 'api' Cache key prefix for rate limit counters.
# Disable rate limiting (not recommended for production)
BOUNDLY_RATE_LIMIT_ENABLED=false

# Stricter limits for sensitive endpoints
BOUNDLY_RATE_LIMIT_MAX_ATTEMPTS=30
BOUNDLY_RATE_LIMIT_DECAY_MINUTES=1

Per-Entity Rate Limiting

You can also set rate limits directly on entities using the #[RateLimit] attribute:

#[Entity(table: 'payments')]
#[RateLimit(maxAttempts: 10, decayMinutes: 1)]
class Payment extends AggregateRoot { ... }

See Behavioral-Traits#rate-limit for more details.


🧱 Full Configuration Example

// config/boundly.php
return [
    'locale'        => env('BOUNDLY_LOCALE', 'en'),
    'api_prefix'    => env('BOUNDLY_API_PREFIX', 'api'),

    'paths' => [
        'domain'      => base_path('Domain'),
        'application' => base_path('Application'),
    ],

    'disable_cache' => env('BOUNDLY_DISABLE_CACHE', app()->environment('local')),

    'auth' => [
        'default_guard' => env('BOUNDLY_AUTH_GUARD', 'sanctum'),
    ],

    'pagination' => [
        'default_per_page' => env('BOUNDLY_PER_PAGE', 15),
        'max_per_page'     => env('BOUNDLY_MAX_PER_PAGE', 100),
    ],

    'rate_limit' => [
        'enabled'       => env('BOUNDLY_RATE_LIMIT_ENABLED', true),
        'max_attempts'  => env('BOUNDLY_RATE_LIMIT_MAX_ATTEMPTS', 60),
        'decay_minutes' => env('BOUNDLY_RATE_LIMIT_DECAY_MINUTES', 1),
        'prefix'        => env('BOUNDLY_RATE_LIMIT_PREFIX', 'api'),
    ],
];

🧪 Usage Tips

  1. Environment Aware: All keys support env() — use .env to separate local, staging, and production configs.
  2. CLI Override: --lang in any core:* command takes precedence over locale.
  3. Publish Config: Run php artisan vendor:publish --tag=boundly-config to copy the default config to config/boundly.php.

Next Step: Roadmap 🚀

Clone this wiki locally