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

Core Command Laravel Package

wp-cli/core-command

WP-CLI package providing the wp core command set to download, install, update, and manage WordPress core. Includes update checking via the Version Check API with flags for major/minor comparisons, forced checks, and flexible output formats.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • WordPress-Centric: The package is tightly coupled with WordPress core operations (installation, updates, multisite conversion) and is designed for WP-CLI, a CLI toolchain for WordPress. This makes it incompatible with Laravel/PHP ecosystems unless integrated as a subsystem (e.g., via Symfony Process or exec calls).
  • Command-Driven: The package exposes imperative CLI commands (e.g., wp core install), which are not natively consumable by Laravel’s dependency-injection or service-container patterns. A Laravel wrapper would need to abstract these commands into a service layer.
  • Stateful Operations: Many commands (e.g., wp core update) interact with filesystems, databases, and HTTP APIs, requiring careful handling of environment variables, permissions, and error recovery in a Laravel context.

Integration Feasibility

  • Laravel Compatibility:
    • Low: The package is not a Laravel package (no composer.json extra.laravel metadata, no Facade/ServiceProvider patterns).
    • Workarounds:
      • Use Symfony Process (\Symfony\Component\Process\Process) to shell out to wp-cli.
      • Build a Laravel Artisan command wrapper that delegates to wp-cli under the hood.
      • Embed the package as a Composer dependency and expose its logic via a custom service (highly invasive, requires refactoring).
  • Database Abstraction:
    • WordPress uses its own database schema (e.g., wp_options, wp_posts), which may conflict with Laravel’s migrations or Eloquent models. A Laravel integration would need to isolate WordPress DB operations (e.g., via a separate connection or schema).

Technical Risk

  • Security:
    • Commands like wp core install create admin users with arbitrary passwords and write to disk. Laravel’s security layer (e.g., CSRF, auth) would need to validate inputs before delegating to wp-cli.
    • Shell injection risks if using exec() or shell_exec() without proper escaping.
  • Environment Dependencies:
    • Requires WordPress files, a database, and PHP CLI tools to be pre-configured. Laravel’s homogeneous environment (e.g., shared hosting) may not support this.
    • Locale/language settings must align between Laravel and WordPress.
  • Testing Complexity:
    • WordPress operations are non-deterministic (e.g., updates, emails). Laravel’s PHPUnit would need mocking layers for filesystem/HTTP/database interactions.
    • Behat tests in the package are WP-CLI-specific; adapting them for Laravel would require significant effort.

Key Questions

  1. Why integrate wp-cli/core-command into Laravel?

    • Is the goal to manage WordPress sites from Laravel (e.g., a SaaS platform) or embed WordPress in Laravel (e.g., a hybrid CMS)?
    • Could a headless WordPress API (REST/GraphQL) or Laravel-specific packages (e.g., spatie/laravel-wordpress) achieve the same result with lower risk?
  2. Environment Assumptions:

    • Will Laravel run in a shared hosting (no CLI access) or dedicated server (full wp-cli support)?
    • Are database credentials (MySQL, etc.) dynamically configurable or hardcoded?
  3. Performance:

    • Will this be used for bulk operations (e.g., multisite updates)? If so, parallelization (e.g., Symfony Process pools) or queue workers (Laravel Queues) would be needed.
  4. Maintenance:

    • Who will update wp-cli when WordPress releases a new version? Will Laravel apps vendor-lock to a specific wp-cli version?
    • How will breaking changes (e.g., new WordPress DB schema) be handled?
  5. Alternatives:

    • Could WordPress REST API + Laravel HTTP clients replace CLI operations?
    • Are there Laravel-native WordPress packages (e.g., laravel-wordpress, wp-vip/goose) that avoid wp-cli entirely?

Integration Approach

Stack Fit

  • Laravel + WP-CLI:

    • Best for: Developers managing WordPress sites from Laravel (e.g., a dashboard for multiple WordPress installs).
    • Tools Needed:
      • Symfony Process (symfony/process) for shell delegation.
      • Laravel Artisan to wrap wp-cli commands as custom commands.
      • Laravel Config to manage WordPress site credentials (DB, paths, URLs).
      • Laravel Queues for async operations (e.g., bulk updates).
    • Avoid for: Embedding WordPress inside Laravel (use a subdirectory install or Docker container instead).
  • Compatibility:

    • PHP Version: Laravel 10+ requires PHP 8.1+. wp-cli/core-command supports PHP 7.4+ (check for 8.1+ compatibility).
    • Composer: No conflicts expected, but dependency versioning must align (e.g., wp-cli/wp-cli version).
    • Filesystem: WordPress requires write permissions to its root directory (e.g., /var/www/wordpress). Laravel’s storage paths must be separate.

Migration Path

  1. Phase 1: Proof of Concept

    • Install wp-cli globally or via Composer (wp-cli/wp-cli).
    • Test basic commands (e.g., wp core version) using Symfony Process:
      use Symfony\Component\Process\Process;
      use Symfony\Component\Process\Exception\ProcessFailedException;
      
      $process = new Process(['wp', 'core', 'version']);
      $process->run();
      if (!$process->isSuccessful()) {
          throw new ProcessFailedException($process);
      }
      echo $process->getOutput();
      
    • Validate error handling (e.g., missing WordPress files, DB connection issues).
  2. Phase 2: Laravel Wrapper

    • Create a Laravel Service Provider to register wp-cli commands as Laravel services:
      // app/Providers/WpCliServiceProvider.php
      namespace App\Providers;
      use Illuminate\Support\ServiceProvider;
      use Symfony\Component\Process\Process;
      
      class WpCliServiceProvider extends ServiceProvider
      {
          public function register()
          {
              $this->app->singleton('wp-cli', function ($app) {
                  return new class {
                      public function version(string $wpPath): string
                      {
                          $process = new Process(['wp', 'core', 'version'], $wpPath);
                          $process->run();
                          return $process->getOutput();
                      }
                  };
              });
          }
      }
      
    • Build Artisan commands to expose wp-cli functionality:
      // app/Console/Commands/InstallWordPress.php
      namespace App\Console\Commands;
      use Illuminate\Console\Command;
      use Symfony\Component\Process\Process;
      
      class InstallWordPress extends Command
      {
          protected $signature = 'wp:install {url} {title} {admin_user} {admin_email}';
          public function handle()
          {
              $process = new Process([
                  'wp', 'core', 'install',
                  '--url=' . $this->argument('url'),
                  '--title=' . $this->argument('title'),
                  '--admin_user=' . $this->argument('admin_user'),
                  '--admin_email=' . $this->argument('admin_email'),
              ]);
              $process->run();
              $this->output->write($process->getOutput());
          }
      }
      
  3. Phase 3: Environment Abstraction

    • Store WordPress site configurations in Laravel’s database or config files:
      // config/wp_sites.php
      return [
          'site1' => [
              'path' => '/var/www/site1',
              'db' => [
                  'host' => 'localhost',
                  'name' => 'site1_db',
              ],
          ],
      ];
      
    • Use Laravel’s env() for dynamic paths/credentials.
  4. Phase 4: Async Operations

    • For long-running tasks (e.g., wp core update), use Laravel Queues:
      // app/Jobs/UpdateWordPress.php
      namespace App\Jobs;
      use Illuminate\Bus\Queueable;
      use Illuminate\Contracts\Queue\ShouldQueue;
      use Symfony\Component\Process\Process;
      
      class UpdateWordPress implements ShouldQueue
      {
          use Queueable;
          public function handle()
          {
              $process = new Process(['wp', 'core', 'update']);
              $process->run();
              // Log output or dispatch a notification.
          }
      }
      

Sequencing

| Step | Task | Dependencies | Risk | |------|------|------------

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.
datacore/hub-sdk
alengo/sulu-http-cache-bundle
croct/coding-standard
croct/plug-php
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php
trappistes/laravel-custom-fields