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

Drush Laravel Package

20steps/drush

Laravel package that integrates Drush to manage Drupal sites from your app. Run common Drush commands, automate site maintenance, and script deployments via PHP with a simple interface for executing Drush and handling output/errors.

View on GitHub
Deep Wiki
Context7

Forked drush6 for Bricks/Drulap7 integration

Frequently asked questions about Drush
Can I use this package to run Drush commands directly from Laravel controllers or commands?
Yes, the package provides a simple interface to execute Drush commands via PHP. You can call Drush from Laravel controllers, Artisan commands, or even queues. For example, use `shell_exec()` or a custom service wrapper to run commands like `drush cc all` or `drush sql:dump`. Ensure your Laravel environment has Drush installed in the vendor bin directory.
What Laravel versions does this package support, and does it work with PHP 8.x?
This package is a fork of Drush6, which primarily supports PHP 5.x. If you’re using Laravel 8+ (PHP 8.x), you’ll need to either polyfill PHP 5.x dependencies or switch to a newer Drush version (like Drush 10/11) that supports PHP 8.x. Check the package’s `composer.json` for constraints or use a Docker setup to isolate PHP versions.
How do I handle authentication when running Drush commands from Laravel?
Drush commands often rely on Drupal’s kernel or session context, which Laravel doesn’t natively support. You’ll need to mock Drupal’s environment, such as setting up a Drupal kernel instance or passing authentication tokens (e.g., Drupal’s session cookie or API tokens) via command-line arguments. For example, use `drush user:login username --password=password` if your Drupal site allows it.
Will this package work if my Laravel app and Drupal site are on separate servers?
No, this package assumes Drush is installed on the same server as your Drupal site. If Laravel and Drupal are decoupled, you’ll need to use SSH or remote execution (e.g., `ssh2_exec()`) to run Drush commands on the Drupal server. Alternatively, consider using Drupal’s REST API or GraphQL endpoints for remote interactions, which may be more reliable than CLI-based workflows.
Are there any known conflicts with Laravel’s dependencies, like Symfony components?
Yes, Drush6 relies on older Symfony 2.x components, which may conflict with Laravel’s Symfony 5.x+ dependencies. To mitigate this, use Composer’s `replace` directive in your `composer.json` to force specific versions or isolate Drush in a separate vendor directory. Testing in a clean environment (e.g., Docker) is recommended to catch conflicts early.
Can I use this package to automate Drupal deployments from Laravel?
Absolutely. You can chain Drush commands (e.g., `drush updb`, `drush cc all`, `drush cr`) in Laravel’s Artisan commands or queues to automate deployments. For example, create a Laravel command that runs a series of Drush commands sequentially. However, ensure your deployment workflow includes error handling, rollback logic, and environment parity (e.g., staging vs. production).
What happens if a Drush command fails during execution? How can I handle errors?
The package returns the command’s output and exit code, which you can check in Laravel to handle failures. For example, use `exec()` or `shell_exec()` and inspect the return value. Implement retry logic for transient failures (e.g., network issues) or fall back to alternative methods like Drupal’s API. Log errors for debugging and notify administrators if critical commands fail.
Is this package suitable for production use, or should I consider alternatives like Drupal’s REST API?
This package is viable for production if your workflow heavily relies on Drush and you’ve tested it thoroughly in a staging environment. However, for modern Laravel-Drupal integrations, consider using Drupal’s REST API or GraphQL endpoints via Guzzle or Laravel HTTP clients. APIs are more maintainable, scalable, and avoid the overhead of CLI processes. Use Drush only for tasks where CLI is mandatory (e.g., legacy modules or complex Drupal-specific operations).
How do I test Drush commands in my Laravel application before deploying to production?
Set up a Docker container or local environment that mirrors your production setup, including the same PHP version, Drupal core, and modules. Write PHPUnit tests that mock Drush command execution (e.g., using `Mockery` or `PHPUnit’s` process mocking) or test real commands in a controlled staging environment. Validate outputs, error handling, and edge cases like network timeouts or missing dependencies.
Are there alternatives to this package for integrating Laravel with Drupal?
Yes. If you’re looking to avoid Drush, consider these alternatives: 1) **Drupal REST API**: Use Laravel HTTP clients (e.g., Guzzle) to interact with Drupal’s REST endpoints. 2) **GraphQL**: Drupal’s GraphQL module provides a flexible way to query data. 3) **Laravel-Drupal Sync Packages**: Packages like `drupal/console` (for Drupal 8/9) or `spatie/laravel-drupal` (if available) may offer better integration. 4) **Shared Database**: If both systems use the same database, you can query Drupal tables directly from Laravel. Choose based on your architecture and long-term maintenance needs.
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.
bugban/symfony
beyonder-capi/workflow-extensions-bundle
beyonder-capi/job-queue-bundle
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin