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

Easy Deploy Bundle Laravel Package

aritti/easy-deploy-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation:

    composer require aritti/easy-deploy-bundle
    

    Add the bundle to config/bundles.php:

    return [
        // ...
        Aritti\EasyDeployBundle\EasyDeployBundle::class => ['all' => true],
    ];
    
  2. Configure a Deployer: Create a deployer class (e.g., config/deploy.php) extending DefaultDeployer or CustomDeployer:

    use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;
    
    return new class extends DefaultDeployer {
        public function configure() {
            return $this->getConfigBuilder()
                ->server('user@hostname', '/path/to/deploy/dir')
                ->repository('git@github.com:user/repo.git')
            ;
        }
    };
    
  3. First Deployment: Run the deploy command:

    php bin/console easy-deploy:deploy
    

First Use Case: Zero-Downtime Symfony Deployment

Use the default deployer for a standard Symfony app with:

  • Git repository
  • SSH access to the server
  • Webroot and cache directories configured

Example workflow:

# Warm up cache locally
php bin/console cache:warmup

# Deploy
php bin/console easy-deploy:deploy

# Verify
php bin/console easy-deploy:verify

Implementation Patterns

Core Workflows

  1. Standard Deployment Cycle:

    # Pre-deploy checks
    php bin/console easy-deploy:check
    
    # Deploy
    php bin/console easy-deploy:deploy
    
    # Post-deploy verification
    php bin/console easy-deploy:verify
    
  2. Rollback:

    php bin/console easy-deploy:rollback
    
  3. Multi-Server Deployment:

    return new class extends DefaultDeployer {
        public function configure() {
            return $this->getConfigBuilder()
                ->server('user@web1.example.com', '/var/www/app')
                ->server('user@web2.example.com', '/var/www/app')
                ->repository('git@github.com:user/repo.git')
            ;
        }
    };
    

Integration Tips

  1. CI/CD Pipeline Integration:

    # Example GitHub Actions workflow
    deploy:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2
        - uses: shivammathur/setup-php@v2
          with:
            php-version: '7.4'
        - run: composer install
        - run: php bin/console easy-deploy:deploy
    
  2. Custom Hooks: Extend deployer to add pre/post hooks:

    public function beforeStartingDeploy() {
        $this->runLocal('composer install --no-dev --optimize-autoloader');
    }
    
    public function afterFinishingDeploy() {
        $this->runRemote('sudo systemctl restart php-fpm');
    }
    
  3. Environment-Specific Deployers:

    // config/deploy/production.php
    return new class extends DefaultDeployer {
        public function configure() {
            return $this->getConfigBuilder()
                ->server('prod@example.com', '/var/www/prod')
                ->repository('git@github.com:user/repo.git')
                ->useSshAgentForwarding(true)
            ;
        }
    };
    
  4. Database Migrations:

    public function deploy() {
        $this->runRemote('php bin/console doctrine:migrations:migrate --no-interaction');
        parent::deploy();
    }
    

Gotchas and Tips

Common Pitfalls

  1. SSH Agent Forwarding Issues:

    • Verify with ssh -T git@github.com on both local and remote servers
    • Check ~/.ssh/config for ForwardAgent no settings
    • Solution: Either enable forwarding or use deploy keys
  2. Permission Problems:

    • Ensure the deploy user has write access to the deploy directory
    • Common fix: chown -R user:group /path/to/deploy/dir
  3. Git Authentication Failures:

    • For HTTPS repos: Use deployKey config option
    • For SSH: Verify ~/.ssh/known_hosts has the server's fingerprint
  4. Composer Cache Issues:

    • Clear remote composer cache before deploy:
      public function beforeStartingDeploy() {
          $this->runRemote('rm -rf vendor composer.lock');
      }
      

Debugging Tips

  1. Verbose Mode:

    php bin/console easy-deploy:deploy --verbose
    
  2. Dry Run:

    php bin/console easy-deploy:deploy --dry-run
    
  3. SSH Debugging:

    ssh -vvv user@host  # Test SSH connection manually
    

Configuration Quirks

  1. Server Configuration:

    • The deploy directory must exist on the remote server
    • Use absolute paths for consistency
  2. Repository Handling:

    • For private repos, configure deploy keys or use SSH agent forwarding
    • Submodules require additional configuration:
      ->repository('git@github.com:user/repo.git', ['--recurse-submodules'])
      
  3. Environment Variables:

    • Pass environment variables during deploy:
      ->environment(['APP_ENV=prod', 'APP_DEBUG=0'])
      

Extension Points

  1. Custom Commands: Create console commands extending EasyDeployCommand:

    use EasyCorp\Bundle\EasyDeployBundle\Command\EasyDeployCommand;
    
    class CustomDeployCommand extends EasyDeployCommand {
        protected function configure() {
            $this->setName('app:custom-deploy');
        }
    
        protected function execute(InputInterface $input, OutputInterface $output) {
            // Custom logic
        }
    }
    
  2. Event Listeners:

    use EasyCorp\Bundle\EasyDeployBundle\Event\DeployEvent;
    
    class MyDeployListener {
        public function onDeploy(DeployEvent $event) {
            // Pre/post deploy logic
        }
    }
    
  3. Custom Deployer Methods: Override core methods:

    public function updateCode() {
        $this->runRemote('git clone --depth 1 git@github.com:user/repo.git /tmp/repo');
        $this->runRemote('rsync -avz /tmp/repo/ /var/www/app/');
    }
    

Performance Tips

  1. Use Rsync:

    public function deploy() {
        $this->runLocal('rsync -avz --delete ./ user@host:/var/www/app/');
    }
    
  2. Shallow Clone:

    ->repository('git@github.com:user/repo.git', ['--depth=1'])
    
  3. Parallel Deployments:

    ->server('user@web1.example.com', '/var/www/app')
    ->server('user@web2.example.com', '/var/www/app')
    // Runs in parallel by default
    
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