PHP code example of bamboguirassy / laravel-deploy-supervisor

1. Go to this page and download the library: Download bamboguirassy/laravel-deploy-supervisor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bamboguirassy / laravel-deploy-supervisor example snippets


'environments' => [
    'production' => [
        'supervisor-deploy' => [
            'connection' => 'redis',
            'queue' => ['deploy'],
            'balance' => 'simple',
            'maxProcesses' => 1,
            'tries' => 1,
            // Un déploiement peut prendre plusieurs minutes — laisser de
            // la marge par rapport à `config('deploy-supervisor.timeout')`.
            'timeout' => 960,
        ],
        // ... vos autres supervisors (default, notifications, etc.)
    ],
],

   Gate::define('manage-deploy-supervisor', fn ($user) => $user->is_admin);
   

   // App\Support\DeclencheParFormatter.php
   class DeclencheParFormatter
   {
       public function __invoke($user): array
       {
           return ['uid' => $user->uid, 'nom_complet' => $user->nom_complet];
       }
   }

   // config/deploy-supervisor.php
   'declenche_par_formatter' => \App\Support\DeclencheParFormatter::class,
   
bash
php artisan vendor:publish --tag=deploy-supervisor-config
php artisan vendor:publish --tag=deploy-supervisor-migrations
php artisan migrate
bash
composer update bamboguirassy/laravel-deploy-supervisor
php artisan vendor:publish --tag=deploy-supervisor-config --force
php artisan config:clear && php artisan config:cache
bash
php artisan queue:work redis --queue=deploy --timeout=960 --tries=1
env
DEPLOY_SUPERVISOR_TABLE=deploy_supervisor_deploiements
DEPLOY_SUPERVISOR_USER_MODEL=App\Models\User
DEPLOY_SUPERVISOR_GATE=manage-deploy-supervisor

# false pour désactiver complètement les routes du package (voir Sécurité)
DEPLOY_SUPERVISOR_ROUTES=true
DEPLOY_SUPERVISOR_ROUTE_PREFIX=api/deploiement

DEPLOY_SUPERVISOR_CHANNEL=deploy-supervisor
DEPLOY_SUPERVISOR_QUEUE=deploy
DEPLOY_SUPERVISOR_GIT_BRANCH=main
DEPLOY_SUPERVISOR_TIMEOUT=900

# Optionnel — authentification git du pipeline (remote HTTPS uniquement) :
# utile si le worker de queue n'a pas accès à l'agent SSH / au credential
# helper de l'utilisateur ayant cloné le dépôt manuellement.
DEPLOY_SUPERVISOR_GIT_USERNAME=
DEPLOY_SUPERVISOR_GIT_TOKEN=

POST   /api/deploiement                Déclenche un déploiement
POST   /api/deploiement/search         Historique paginé
GET    /api/deploiement/environnements Liste des environnements (déduite de config('deploy-supervisor.targets'))
GET    /api/deploiement/{uid}          Détail complet (avec sortie console)
DELETE /api/deploiement/{uid}          Supprime un déploiement (sauf en_cours)
bash
# Déploie toutes les cibles configurées, en file d'attente
php artisan deploy-supervisor:run

# Une seule cible
php artisan deploy-supervisor:run --cible=backend

# Synchrone — attend la fin dans ce process (secours si le worker de queue est down)
php artisan deploy-supervisor:run --sync
bash
php artisan deploy-supervisor:webhook-secret
bash
php artisan deploy-supervisor:webhook-url

# Limiter l'affichage à une seule cible
php artisan deploy-supervisor:webhook-url backend