wp-cli/extension-command
WP-CLI extension-command adds wp plugin and wp theme management: install, activate/deactivate, update, delete, and more. Supports bulk actions, multisite network activation, exclusions, and forcing reactivation to rerun hooks.
wp_list_plugins(), activate_plugin(), etc.), which are unavailable in Laravel. A Laravel-compatible wrapper would require reverse-engineering WordPress logic or building a WordPress-like plugin manager from scratch.wp plugin install), which contrasts with Laravel’s HTTP-driven (Symfony HTTP Kernel) and artisan-command paradigms. Adapting it would require refactoring core logic to fit Laravel’s event system or console components.Low Feasibility Without Heavy Rework:
File and Storage facades to handle plugin directories (/wp-content/plugins).ServiceProvider lifecycle).wp-includes) into Laravel, then use this package as-is.
Key Technical Blocks:
wp_options and wp_plugins tables. Laravel lacks this schema by default.add_action()/add_filter(); Laravel uses events and service containers./wp-content/plugins/), which Laravel’s storage/ or public/ may not replicate.| Risk Area | Severity | Mitigation |
|---|---|---|
| Incompatible Abstractions | Critical | Requires custom Laravel service layer or WordPress integration. |
| Database Dependencies | High | Must replicate WordPress tables or use a proxy (e.g., Eloquent models). |
| Plugin Lifecycle Hooks | High | Need to reimplement activate_plugin(), deactivate_plugin(), etc. |
| Performance Overhead | Medium | Embedding WordPress core adds ~10MB+ to Laravel’s footprint. |
| Security Risks | Medium | Plugin updates/downloads must validate signatures (WordPress uses wp_remote_get). |
| Testing Complexity | High | Requires mocking WordPress APIs or a full WordPress environment for tests. |
spatie/laravel-package-tools for package management).php artisan plugin:install).Storage::disk('plugins')->put()).PluginActivated event).ServiceProvider boot methods).wp_update_plugins()).https://api.wordpress.org/plugins/info/1.0/).| Phase | Action | Tools/Dependencies |
|---|---|---|
| Assessment | Audit existing Laravel plugins/themes and their dependencies. | composer why, php artisan package:discover |
| Abstraction Layer | Build a Laravel service (PluginManager) to wrap WordPress logic. |
Custom classes, Eloquent models for metadata. |
| Database Sync | Replicate WordPress plugin tables (wp_options, wp_plugins) in Laravel. |
Laravel Migrations, Eloquent. |
| File System Setup | Configure Laravel to use /wp-content/plugins (symlink or custom storage). |
Storage::extend(), filesystem drivers. |
| Hook Emulation | Replace WordPress hooks with Laravel events (e.g., plugin_activated). |
Laravel Events, Service Providers. |
| CLI Integration | Create Artisan commands to mirror wp plugin functionality. |
Artisan::command(), Symfony Console. |
| Testing | Mock WordPress APIs or use a headless WordPress instance for tests. | PestPHP, Laravel Dusk, or Dockerized WordPress. |
must-use plugins, network activation).PluginManager service to handle file operations (install/delete).hello.php).plugins and plugin_updates.activate_plugin() with Laravel events (PluginActivated).PluginServiceProvider to load plugins on boot.plugin:install, plugin:activate).composer.json, conflicting with Laravel’s autoloader.require 'vendor/autoload.php' may break Laravel’s PSR-4 autoloading.PluginActivated event").wp_ajax_* hook may conflict with Laravel’s route model binding.How can I help you explore Laravel packages today?