Overview
Bundles are modular components that extend Framefox’s functionality. They allow you to package services, commands, templates, and configuration into reusable units that can be shared across projects.Bundle System
The bundle system in Framefox provides:- Service Registration: Register services in the dependency injection container
- Command Registration: Add custom CLI commands
- Auto-discovery: Automatically load bundles via entry points
- Lifecycle Management: Control initialization and bootstrapping
- Template & Static Files: Package UI components with your bundle
Creating a Bundle
To create a bundle, extend theAbstractBundle class:
Bundle Discovery
Framefox automatically discovers bundles using Python entry points. Add this to yoursetup.py or pyproject.toml:
setup.py:
BundleManager
TheBundleManager handles bundle lifecycle:
Bundle Lifecycle
Bundles follow this lifecycle:- Discovery: Entry points are scanned and bundle classes loaded
- Service Registration:
register_services()called for each bundle - Command Registration:
register_commands()called for each bundle - Boot:
boot()called after all bundles registered
Example: Analytics Bundle
Here’s a complete example bundle:Best Practices
- Single Responsibility: Each bundle should have a clear, focused purpose
- Dependency Management: Declare bundle dependencies explicitly
- Configuration Schema: Define clear configuration requirements
- Error Handling: Handle initialization errors gracefully
- Documentation: Include clear usage instructions
- Testing: Test bundle initialization and integration