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

Extension Command Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require wp-cli/extension-command
    

    Ensure WP-CLI is installed globally (wp --version) and the package is autoloaded via Composer.

  2. First Use Case: List installed plugins with their status:

    wp plugin list --status=active
    

    Verify output includes active plugins (e.g., akismet, hello).

  3. Key Files:

    • src/Plugin.php: Core logic for plugin operations.
    • src/PluginCommand.php: Command handler for CLI integration.
    • tests/: Unit and Behat tests for validation.

Implementation Patterns

Workflows

  1. Plugin Lifecycle Management:

    • Install: Use --activate to auto-activate post-install:
      wp plugin install bbpress --activate
      
    • Update: Force reinstall to trigger updates:
      wp plugin install $(wp plugin list --field=name) --force
      
    • Cleanup: Delete inactive plugins:
      wp plugin delete $(wp plugin list --status=inactive --field=name)
      
  2. Dependency Handling:

    • Install plugins with dependencies:
      wp plugin install my-plugin --with-dependencies --activate
      
    • Isolate dependency installation:
      wp plugin install-dependencies my-plugin --activate
      
  3. Multisite Support:

    • Network-wide activation:
      wp plugin activate hello --network
      
    • Exclude plugins from bulk operations:
      wp plugin deactivate --all --exclude=hello,jetpack
      

Integration Tips

  • Custom Commands: Extend PluginCommand to add domain-specific logic (e.g., validate plugins against a whitelist).
  • Hooks: Use WordPress hooks (e.g., activated_plugin) to trigger post-install actions:
    add_action('activated_plugin', function($plugin) {
        // Custom logic after activation
    });
    
  • Output Parsing: Pipe CLI output to scripts for automation:
    wp plugin list --field=name --format=csv | xargs -I {} wp plugin get {} --field=version
    

Gotchas and Tips

Pitfalls

  1. Permission Issues:

    • Ensure WP-CLI runs with sufficient filesystem permissions (e.g., chown -R www-data:www-data wp-content).
    • Use --force cautiously; it bypasses safety checks (e.g., version conflicts).
  2. Multisite Quirks:

    • Network-wide commands (--network) require super-admin privileges.
    • Test in a staging environment first; bulk operations can disrupt sites.
  3. Caching:

    • Clear WP-CLI cache (wp cache flush) if commands fail unexpectedly:
      wp cache flush --group=plugins
      
  4. Plugin Conflicts:

    • Use --ignore-requirements sparingly; it may break functionality:
      wp plugin install my-plugin --ignore-requirements
      

Debugging

  • Verbose Output: Enable debug mode for troubleshooting:
    WP_CLI_DEBUG=1 wp plugin install my-plugin
    
  • Dry Runs: Test commands in a sandbox (e.g., Docker) before production:
    wp plugin list --status=active --format=json | jq '.[] | select(.name == "akismet")'
    

Extension Points

  1. Custom Fields:

    • Extend PluginCommand::getFields() to add metadata (e.g., custom plugin tags):
      protected function getFields() {
          return array_merge(parent::getFields(), ['custom_tag']);
      }
      
  2. Pre/Post Hooks:

    • Override PluginCommand::activate() to inject logic:
      protected function activate($plugins) {
          // Custom activation logic
          parent::activate($plugins);
      }
      
  3. Testing:

    • Mock HTTP requests in Behat for offline testing:
      Given HTTP requests to "https://downloads.wordpress.org" will respond with:
        """
        HTTP/1.1 200 OK
        Content-Type: application/octet-stream
        Content-Disposition: attachment; filename="plugin.zip"
        """
      
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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views