Download the PHP package stracker-phil/wpdi without Composer
On this page you can find all versions of the php package stracker-phil/wpdi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stracker-phil/wpdi
More information about stracker-phil/wpdi
Files in stracker-phil/wpdi
Package wpdi
Short Description Truly WordPress-native dependency injection
License GPL-2.0
Informations about the package wpdi
WPDI - WordPress Dependency Injection
Lightweight, WordPress-native dependency injection with auto-discovery and zero configuration.
Features
- Zero Config - Autowires concrete classes in
src/folder - Production Ready - Cached class mapping; only modified files re-scanned during development
- WordPress Native - Follows WordPress coding standards
- PSR-11 Compatible - Standard container interface
- Opinionated - Limited feature-set by design
Philosophy
"Constraint is the feature"
In my experience, DI usually fails in WordPress projects not because they lack features, but because they have too many. It's easy for developers to misuse the container as a global registry, a configuration store, a service locator - all patterns that DI was meant to solve.
WPDI prevents these patterns by design. It does one thing well: wire your classes together automatically. Everything else—configuration, state, WordPress options—stays where it belongs.
Quick Start
Your classes in src/ are auto-discovered and autowired:
Configuration (Optional)
For interface bindings or classes outside src/ (e.g., Composer packages), create wpdi-config.php:
Caching
Autowiring uses reflection to analyze constructor dependencies—but only once. WPDI caches the class mapping and rebuilds it automatically when files change. In production, this means zero overhead: just a single array lookup per service.
For deployment, pre-compile the cache to avoid the initial scan:
Requirements
- PHP 7.4+
- WordPress 5.0+
Documentation
Tip: Use DeepWiki to explore the codebase using AI - https://deepwiki.com/stracker-phil/wpdi
- Getting Started
- Application Flow
- Configuration
- Testing
- WP-CLI Commands
- API Reference
- Troubleshooting
- Multi-Plugin Patterns - Cross-plugin service sharing
- MU-Plugin Installation - For developers working with multiple WPDI plugins
- WPDI vs Modularity - Framework comparison
License
GPL-2.0