Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Boot Laravel Package

spiral/boot

Spiral Boot Core provides the kernel bootstrapping foundation for the Spiral Framework. It includes bootloaders, application lifecycle management, and configuration wiring used by Spiral apps and bundles, with strong type-safety and CI-tested quality.

View on GitHub
Deep Wiki
Context7

Getting Started

The spiral/boot package provides foundational infrastructure for bootstrapping Spiral-based applications—primarily as part of the Spiral Framework kernel. It’s not typically used in isolation. To get started:

  • Install as part of a Spiral Framework application (spiral/framework pulls it in as a dependency).
  • Examine spiral/framework’s kernel configuration and bootloader chain (config/boot.php, src/Application/Kernel.php).
  • Start by extending Spiral\Boot\Bootloader\Bootloader to build your own custom bootloaders.
  • First practical use: inject Spiral\Boot\BootloaderManager or use the framework’s Kernel to manage bootloader lifecycle and dependency resolution.

Implementation Patterns

  • Custom Bootloaders: Define your own bootloaders by extending Spiral\Boot\Bootloader\Bootloader. Use boot() method for initialization logic, init() for one-time setup, and depended() for service dependencies (implement DependedInterface).
  • Bootloader Dependency Chain: Bootloaders declare dependencies via public const DEPENDENCIES = [...]. The BootloaderManager resolves and executes them in topologically correct order.
  • Environment Handling: Use Spiral\Boot\EnvironmentInterface (and its implementations) to safely read and mutate environment state during bootstrap (note: immutable by design to prevent race conditions).
  • Dispatcher Integration: Use Spiral\Boot\DispatcherInterface (e.g., CommandDispatcher) to dispatch CLI or background tasks during boot (e.g., seeding, migration check).
  • Debug & Logging Hooks: Early-stage logging is wired via Spiral\Boot\LoggerInterface (deprecated) and ListenerRegistryInterface; prefer PSR-3 logger injection for production.
  • Ioc Scope Management: Since v1.1.11, the manager creates a dedicated IoC scope during booting—ensuring clean separation and avoiding leaks between requests.

Gotchas and Tips

  • PHP Version Requirement: Requires PHP ≥8.1 as of v1.2.6 (per composer.json). Older versions (v1.0–v1.1.x) supported PHP 7.2, but current usage demands 8.1+.
  • Immutability During Boot: Environment variables are immutable during boot (fixed in v1.2.4). Attempting to mutate them after initialization will throw; use safeSet() or set values before kernel boots (e.g., .env or CLI args).
  • No Standalone Usage: This package is internal to Spiral. Using it outside the framework risks breakage—no stable public API beyond Bootloader, EnvironmentInterface, and BootloaderManager.
  • Exception Handling: Since v1.1.10, the bootloader manager no longer wraps exceptions—failures propagate directly, simplifying debugging but requiring robust try/catch in boot() if recovery is needed.
  • Configuration Interfaces: v1.1.2+ introduced ConfigInterface and related config helpers—prefer Spiral\Core\ConfigInterface (in spiral/core) for config access during boot.
  • Finalizers & Termination: Use Spiral\Boot\ListenerRegistryInterface to register cleanup/termination callbacks (e.g., closing DB connections) via addListener(). The terminate() flag in finalizers controls shutdown behavior.
  • Namespace Changes: v1.1.0+ changed namespaces to Spiral\Boot\*. Ensure imports aren’t outdated (e.g., old Spiral\Core\Bootloader → now Spiral\Boot\Bootloader).
  • Maintenance Status: Last release Apr 2020. Though stable, treat as legacy—prefer official Spiral Framework features over direct use of this package unless maintaining older apps.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport