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

Symfony Deployer Bundle Laravel Package

drenso/symfony-deployer-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Install the Bundle Add the package via Composer:

    composer require drenso/symfony-deployer-bundle
    

    Enable the bundle in config/bundles.php:

    return [
        // ...
        Drenso\DeployerBundle\DrensoDeployerBundle::class => ['all' => true],
    ];
    
  2. Generate a Script Create a new deployer script:

    bin/console drenso:deployer:generate
    

    This generates a YAML file at config/deployer/scripts.yml with a default always script.

  3. First Use Case Define a simple pre-deployment script (e.g., clearing cache):

    # config/deployer/scripts.yml
    pre:
        always:
            - name: "Clear Symfony cache"
              command: "php bin/console cache:clear"
    

    Run it during deployment:

    bin/console drenso:deployer:pre
    

Implementation Patterns

Workflows

  1. Structured Deployment Hooks Organize scripts into pre and post hooks with always (runs every deployment) or once (runs only once, then skips):

    pre:
        always:
            - name: "Backup database"
              command: "mysqldump -u user -p db_name > backup.sql"
        once:
            - name: "Run migrations"
              command: "php bin/console doctrine:migrations:migrate"
    
  2. Conditional Execution Skip scripts based on conditions (e.g., environment, file existence):

    pre:
        always:
            - name: "Optimize assets"
              command: "npm run build"
              skipIf: "!app.env == 'prod'"
    
  3. Integration with Deployment Tools Use the bundle alongside tools like Deployer or Ansible by embedding its commands in your workflow:

    # In your Deployer recipe
    task('deploy:pre', function () {
        run('cd {{release_path}} && ./bin/console drenso:deployer:pre');
    });
    

Integration Tips

  • Environment Awareness: Use skipIf to avoid running scripts in non-production environments.
  • Logging: Redirect script output to logs for debugging:
    pre:
        always:
            - name: "Log environment"
              command: "php bin/console about | tee -a deploy.log"
    
  • Custom Scripts: Store reusable scripts in config/deployer/scripts/ and reference them via YAML includes.

Gotchas and Tips

Pitfalls

  1. YAML Syntax Errors

    • The bundle relies on YAML for configuration. Validate syntax with:
      bin/console debug:config drenso_deployer
      
    • Use tools like YAML Lint to catch errors early.
  2. once Scripts Not Skipping

    • If a once script runs unexpectedly, check if the skipIf condition is misconfigured or if the script was manually reset (e.g., via drenso:deployer:reset).
  3. Command Execution Failures

    • Scripts fail silently if the command exits non-zero. Add ignoreErrors: false to enforce failure handling:
      pre:
          always:
              - name: "Critical step"
                command: "php bin/console cache:warmup"
                ignoreErrors: false
      

Debugging

  • Dry Runs: Test scripts locally before deployment:
    bin/console drenso:deployer:pre --dry-run
    
  • Verbose Output: Enable debug mode for detailed logs:
    bin/console drenso:deployer:pre -vvv
    

Extension Points

  1. Custom Command Types Extend the bundle by adding new command types (e.g., daily, weekly) via a custom service:

    # config/services.yaml
    Drenso\DeployerBundle\Command\ScriptCommandInterface: '@custom.deployer.command'
    
  2. Dynamic Scripts Load scripts dynamically from a database or API by overriding the ScriptLoader service.

  3. Parallel Execution Use Symfony’s Parallel component to run independent scripts concurrently (requires custom implementation).

Config Quirks

  • File Permissions: Ensure config/deployer/scripts.yml is writable by the web server.
  • Caching: Clear the cache after modifying scripts:
    bin/console cache:clear
    
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle