wpdiggerstudio / wpzylos-core
Core foundation for WPZylos framework - PluginContext, Application, ServiceProvider, and base utilities for building WordPress plugins
Fund package maintenance!
Paypal
Installs: 473
Dependents: 14
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/wpdiggerstudio/wpzylos-core
Requires
- php: ^8.0
- ext-fileinfo: *
- ext-intl: *
- ext-mbstring: *
- psr/container: ^2.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6 || ^10.0
- squizlabs/php_codesniffer: ^3.7
- szepeviktor/phpstan-wordpress: ^1.3
README
The foundation package for WPZylos framework. Provides core interfaces, context management, and base classes for building WordPress plugins with modern architecture.
📖 Full Documentation | 🐛 Report Issues
✨ Features
- ContextInterface — Plugin identity contract that survives PHP-Scoper
- PluginContext — Default implementation with prefixing, paths, options
- Application — Plugin kernel with service provider registration
- ServiceProvider — Base class for modular service registration
- Paths — Path resolution with named aliases
- Utilities — Arr and Str helper classes
📋 Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.0 |
| WordPress | 6.0+ |
🚀 Installation
composer require wpdiggerstudio/wpzylos-core
📖 Quick Start
use WPZylos\Framework\Core\Application; use WPZylos\Framework\Core\PluginContext; // Create plugin context $context = PluginContext::create([ 'file' => __FILE__, 'slug' => 'my-plugin', 'prefix' => 'myplugin_', 'textDomain' => 'my-plugin', 'version' => '1.0.0', ]); // Create and boot application $app = new Application($context); $app->boot();
🏗️ Core Components
PluginContext
Holds plugin identity and configuration:
$context = PluginContext::create([ 'file' => __FILE__, 'slug' => 'my-plugin', 'prefix' => 'myplugin_', 'textDomain' => 'my-plugin', 'version' => '1.0.0', ]); // Access properties $context->slug(); // 'my-plugin' $context->prefix(); // 'myplugin_' $context->textDomain(); // 'my-plugin' $context->version(); // '1.0.0' // Prefix helpers $context->prefixedOption('setting'); // 'myplugin_setting' $context->prefixedHook('init'); // 'myplugin_init'
Application
Plugin kernel that manages service providers:
$app = new Application($context); // Register service providers $app->register(new DatabaseServiceProvider()); $app->register(new RoutingServiceProvider()); // Boot the application $app->boot(); // Access the container $service = $app->get(MyService::class);
ServiceProvider
Base class for modular service registration:
class MyServiceProvider extends ServiceProvider { public function register(): void { $this->app->bind(MyService::class, function ($app) { return new MyService($app->get('config')); }); } public function boot(): void { // Called after all providers registered } }
Paths
Path resolution with named aliases:
$paths = new Paths(__DIR__); // Register aliases $paths->alias('views', 'resources/views'); $paths->alias('config', 'config'); // Resolve paths $paths->get('views'); // /plugin/resources/views $paths->get('config/app'); // /plugin/config/app
📦 Related Packages
| Package | Description |
|---|---|
| wpzylos-container | PSR-11 dependency injection |
| wpzylos-config | Configuration management |
| wpzylos-hooks | WordPress hook management |
| wpzylos-scaffold | Plugin template |
📖 Documentation
For comprehensive documentation, tutorials, and API reference, visit wpzylos.com.
☕ Support the Project
If you find this package helpful, consider buying me a coffee! Your support helps maintain and improve the WPZylos ecosystem.
📄 License
MIT License. See LICENSE for details.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Made with ❤️ by WPDiggerStudio