### Complete Example with Configuration and Tasks Source: https://deployer.org/docs/8.x/contrib/supervisord-monitor A full example demonstrating application setup, repository configuration, Supervisord connection details, host definitions, and custom tasks including a production-specific supervisord restart task. ```php 'https://youruri.xyz/supervisor', 'basic_auth_user' => 'username', 'basic_auth_password' => 'password', 'process_name' => 'process01', ]); host('staging.myproject.com') ->set('branch', 'develop') ->set('labels', ['stage' => 'staging']); host('myproject.com') ->set('branch', 'main') ->set('labels', ['stage' => 'production']); Tasks task('build', function () { run('cd {{release_path}} && build'); }); task('deploy', [ 'build', 'supervisord', ]); task('supervisord', ['supervisord-monitor:restart']) ->select('stage=production'); ``` -------------------------------- ### Installation and Setup Source: https://deployer.org/docs/8.x/contrib/ms-teams Instructions on how to install and set up the MS Teams recipe in your deploy.php file. ```APIDOC ## Installing Ms-teams Recipe Require ms-teams recipe in your `deploy.php` file: ### Setup: 1. Open MS Teams. 2. Navigate to Teams section. 3. Select existing or create new team. 4. Select existing or create new channel. 5. Hover over channel to get three dots, click, in menu select "Connectors". 6. Search for and configure "Incoming Webhook". 7. Confirm/create and copy your Webhook URL. 8. Setup deploy.php Add in header: ```php require 'contrib/ms-teams.php'; set('teams_webhook', 'https://outlook.office.com/webhook/...'); ``` Add in content: ```php before('deploy', 'teams:notify'); after('deploy:success', 'teams:notify:success'); after('deploy:failed', 'teams:notify:failure'); ``` 9.) Sip your coffee ``` -------------------------------- ### Full Deployment Example Source: https://deployer.org/docs/8.x/contrib/cpanel A complete configuration example showing how to integrate cPanel tasks into a deployment workflow. ```php load(); // this is used just so an .env file can be used for credentials require 'cpanel.php'; Project name set('application', 'myproject.com'); Project repository set('repository', 'git@github.com:myorg/myproject.com'); set('cpanel', [ 'host' => getenv('CPANEL_HOST'), 'port' => getenv('CPANEL_PORT'), 'username' => getenv('CPANEL_USERNAME'), 'auth_type' => getenv('CPANEL_AUTH_TYPE'), 'token' => getenv('CPANEL_TOKEN'), 'user' => getenv('CPANEL_USER'), 'db_user' => getenv('CPANEL_DB_USER'), 'db_user_privileges' => getenv('CPANEL_DB_PRIVILEGES'), 'timeout' => 500, 'allowInStage' => ['staging', 'beta', 'alpha'], 'create_domain_format' => '%s-%s-%s', 'create_domain_values' => ['staging', 'master', get('application')], 'subdomain_prefix' => substr(md5(get('application')), 0,4) . '-', 'subdomain_suffix' => getenv('SUDOMAIN_SUFFIX'), 'create_db_format' => '%s_%s-%s-%s', 'create_db_values' => ['apps', 'staging','master', get('application')], ]); host('myproject.com') ->stage('staging') ->set('cpanel_createdb', vsprintf(get('cpanel')['create_db_format'], get('cpanel')['create_db_values'])) ->set('branch', 'dev-branch') ->set('deploy_path', '~/staging/' . vsprintf(get('cpanel')['create_domain_format'], get('cpanel')['create_domain_values'])) ->set('addondir', 'staging/' . vsprintf(get('cpanel')['create_domain_format'], get('cpanel')['create_domain_values'])); Tasks task('build', function () { run('cd {{release_path}} && build'); }); after('deploy:prepare', 'cpanel:createaddondomain'); after('deploy:prepare', 'cpanel:createdb'); ``` -------------------------------- ### deploy:setup Task Source: https://deployer.org/docs/8.x/recipe/deploy/setup Documentation for the deploy:setup task used to prepare a host for deployment. ```APIDOC ## deploy:setup ### Description Prepares the host for deployment. ### Usage ```php require 'recipe/deploy/setup.php'; ``` ``` -------------------------------- ### Include Setup Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/setup Include this PHP file to use the deploy:setup task. This task prepares the host for deployment. ```php require 'recipe/deploy/setup.php'; ``` -------------------------------- ### Dotenv Example File Configuration Source: https://deployer.org/docs/8.x/recipe/spiral Specify the example file for environment variables. Defaults to '.env.sample'. ```php '.env.sample' ``` -------------------------------- ### Example Usage of Phinx Configuration Source: https://deployer.org/docs/8.x/contrib/phinx Examples demonstrating how to set Phinx configuration options and paths within Deployer scripts. ```APIDOC ## Example of Usage ```php // Define Phinx environment variables $phinx_env_vars = [ 'environment' => 'development', 'configuration' => './migration/.phinx.yml', 'target' => '20120103083322', 'remove-all' => '', ]; // Set the Phinx path set('phinx_path', '/usr/local/phinx/bin/phinx'); // Set the Phinx configuration set('phinx', $phinx_env_vars); // Run Phinx migrate after cleanup task after('cleanup', 'phinx:migrate'); // Or set it for a specific server host('dev') ->user('user') ->set('deploy_path', '/var/www') ->set('phinx', $phinx_env_vars) ->set('phinx_path', ''); ``` ``` -------------------------------- ### Install Deployer Globally Source: https://deployer.org/docs/8.x/installation Commands to install Deployer globally using Composer or Phive. ```bash composer global require deployer/deployer ``` ```bash phive install deployer ``` -------------------------------- ### Install Deployer Locally Source: https://deployer.org/docs/8.x/installation Install Deployer as a project dependency for CI/CD pipelines. ```bash composer require --dev deployer/deployer ``` -------------------------------- ### Run Task Command Source: https://deployer.org/docs/8.x/hosts Example output when running a task on a defined host. ```bash $ dep test [example.org] The example.org is example.org ``` -------------------------------- ### Install Bash Completion for Deployer Source: https://deployer.org/docs/8.x/cli Install the completion script for Deployer to enable autocompletion for tasks, options, host names, and configs in bash. Requires bash-completion. ```bash brew install bash-completion ``` ```bash dep completion bash > /usr/local/etc/bash_completion.d/deployer ``` -------------------------------- ### Default .env.example Filename Source: https://deployer.org/docs/8.x/recipe/deploy/env Specifies the default filename for the environment example file. ```text '.env.example' ``` -------------------------------- ### Provision Server with Deployer Source: https://deployer.org/docs/8.x/getting-started Execute this command to provision your server using Deployer's built-in recipes. It automates the setup of your VPS. ```bash dep provision ``` -------------------------------- ### Define .env Configuration Source: https://deployer.org/docs/8.x/contrib/cpanel Example environment variables required for the cPanel recipe. ```text CPANEL_HOST=xxx.xxx.xxx.xxx CPANEL_PORT=2087 CPANEL_USERNAME=root CPANEL_TOKEN=xxxx CPANEL_USER=xxx CPANEL_AUTH_TYPE=hash CPANEL_DB_USER=db_user CPANEL_DB_PRIVILEGES="ALL PRIVILEGES" SUDOMAIN_SUFFIX=.mymaindomain.com ``` -------------------------------- ### Dynamic Configuration Execution Example Source: https://deployer.org/docs/8.x/basics Demonstrates how a dynamic configuration value, like 'whoami', is resolved and displayed. The output shows the result of the 'whoami' command. ```bash $ dep my_task all ``` -------------------------------- ### Configure Phinx Usage Source: https://deployer.org/docs/8.x/contrib/phinx Example showing how to set Phinx environment variables and paths globally or per-host. ```php $phinx_env_vars = [ 'environment' => 'development', 'configuration' => './migration/.phinx.yml', 'target' => '20120103083322', 'remove-all' => '', ]; set('phinx_path', '/usr/local/phinx/bin/phinx'); set('phinx', $phinx_env_vars); after('cleanup', 'phinx:migrate'); or set it for a specific server host('dev') ->user('user') ->set('deploy_path', '/var/www') ->set('phinx', $phinx_env_vars) ->set('phinx_path', ''); ``` -------------------------------- ### Deployment release table output Source: https://deployer.org/docs/8.x/getting-started Example output format showing date, release ID, author, target, and commit hash. ```text +---------------------+--------- deployer.org -------+--------+-----------+ | Date (UTC) | Release | Author | Target | Commit | +---------------------+-------------+----------------+--------+-----------+ | 2021-11-05 14:00:22 | 1 (current) | Anton Medvedev | HEAD | 943ded2be | +---------------------+-------------+----------------+--------+-----------+ ``` -------------------------------- ### Composer Action Configuration Source: https://deployer.org/docs/8.x/recipe/deploy/vendors Sets the Composer action to perform. Defaults to 'install'. ```php 'install' ``` -------------------------------- ### Composer Recipe Setup Source: https://deployer.org/docs/8.x/recipe/composer This snippet shows how to include the Composer Recipe in your project. ```APIDOC ## Composer Recipe ### Description Includes the Composer Recipe for managing project dependencies. ### Source ```php require 'recipe/composer.php'; ``` ### Requires * common ``` -------------------------------- ### Install Ntfy Recipe Source: https://deployer.org/docs/8.x/contrib/ntfy Include the ntfy recipe in your deploy.php file to enable notification functionality. ```php require 'contrib/ntfy.php'; ``` ```php require 'contrib/ntfy.php'; set('ntfy_topic', 'ntfy.sh/mytopic'); ``` -------------------------------- ### magento:cron:install Source: https://deployer.org/docs/8.x/recipe/magento2 Installs cron in crontab. ```APIDOC ## magento:cron:install ### Description Install cron in crontab. ### Method Not specified (likely a script command) ### Endpoint Not specified ### Usage Example ``` after('magento:upgrade', 'magento:cron:install'); ``` ``` -------------------------------- ### Example YAML Deployment Recipe Source: https://deployer.org/docs/8.x/yaml This YAML defines a deployment recipe including repository configuration, hosts, and tasks. It demonstrates importing a PHP recipe and defining a failed deployment hook. ```yaml import: - recipe/laravel.php config: repository: "git@github.com:example/example.com.git" remote_user: deployer hosts: example.com: deploy_path: "~/example" tasks: build: - cd: "{{release_path}}" - run: "npm run build" after: deploy:failed: deploy:unlock ``` -------------------------------- ### Add Npm Install Task Source: https://deployer.org/docs/8.x/contrib/npm Add the 'npm:install' task to run after 'deploy:update_code'. This ensures npm packages are installed after the code is updated. ```php after('deploy:update_code', 'npm:install'); ``` -------------------------------- ### Composer Options Configuration Source: https://deployer.org/docs/8.x/recipe/typo3 Default composer install flags for production environments. ```php ' --no-dev --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader' ``` -------------------------------- ### Nginx Configuration for Deployer Source: https://deployer.org/docs/8.x/getting-started Example Nginx configuration to serve your project from the 'current' directory, which is a symlink to the latest release. ```nginx root /home/deployer/example/current/public; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } ``` -------------------------------- ### Npm Recipe Configuration and Usage Source: https://deployer.org/docs/8.x/contrib/npm Details on how to configure the npm binary path and integrate the npm:install task into deployment workflows. ```APIDOC ## Npm Recipe Configuration ### Description Configure the npm binary path for the deployment process. ### Parameters - **bin/npm** (string) - Optional - The path to the npm binary. If not provided, it is automatically detected using `which('npm')`. ## Task: npm:install ### Description Installs npm packages using the `npm ci` command, which is optimized for automated environments like continuous integration and deployment. ### Usage ```php after('deploy:update_code', 'npm:install'); ``` ``` -------------------------------- ### Install MS Teams Recipe Source: https://deployer.org/docs/8.x/contrib/ms-teams Include the recipe in your deploy.php file to enable MS Teams functionality. ```php require 'contrib/ms-teams.php'; ``` -------------------------------- ### Deploy Vendors Task Source: https://deployer.org/docs/8.x/recipe/deploy/vendors Installs project vendors using Composer. ```php deploy:vendors ``` -------------------------------- ### Notify on deployment start Source: https://deployer.org/docs/8.x/contrib/cimonitor Trigger notification only at the beginning of the deployment. ```php before('deploy', 'cimonitor:notify'); ``` -------------------------------- ### Yarn Recipe Configuration and Usage Source: https://deployer.org/docs/8.x/contrib/yarn Details on configuring the Yarn binary path and integrating the yarn:install task into the deployment workflow. ```APIDOC ## Yarn Recipe Configuration ### Description Configure the Yarn binary path used by the deployment process. ### Configuration Parameters - **bin/yarn** (string) - Optional - Path to the Yarn binary. Defaults to the result of `which('yarn')`. ## yarn:install Task ### Description Installs Yarn packages. If a `{{previous_release}}` exists, `node_modules` will be copied from it before installing dependencies to optimize the process. ### Usage ```php after('deploy:update_code', 'yarn:install'); ``` ``` -------------------------------- ### Get input interface Source: https://deployer.org/docs/8.x/api Returns the current input interface instance. ```php input(): InputInterface ``` -------------------------------- ### Crontab Recipe Usage Source: https://deployer.org/docs/8.x/contrib/crontab Example of how to include and configure the Crontab Recipe in your deployment script. ```APIDOC ## Crontab Recipe Usage ### Description This section demonstrates how to include the crontab recipe and add cron jobs. ### Method N/A (Configuration Example) ### Endpoint N/A ### Parameters #### Query Parameters N/A #### Request Body N/A ### Request Example ```php require 'contrib/crontab.php'; after('deploy:success', 'crontab:sync'); add('crontab:jobs', [ '* * * * * cd {{current_path}} && {{bin/php}} artisan schedule:run >> /dev/null 2>&1', ]); ``` ### Response N/A ``` -------------------------------- ### Provision Node.js Packages Source: https://deployer.org/docs/8.x/recipe/provision/nodejs This task installs npm packages. It is automatically executed as part of the deployment process when the Nodejs recipe is included. ```php echo 'Installs npm packages.' ``` -------------------------------- ### Configure Deployment Hooks Source: https://deployer.org/docs/8.x/contrib/discord Hooks to notify Discord about deployment start, success, or failure. ```php before('deploy', 'discord:notify'); ``` ```php after('deploy:success', 'discord:notify:success'); ``` ```php after('deploy:failed', 'discord:notify:failure'); ``` -------------------------------- ### Cached Dynamic Configuration Example Source: https://deployer.org/docs/8.x/basics Illustrates the caching behavior of dynamic configurations. The 'current_date' is fetched once and reused, even after a 'sleep' command. ```php set('current_date', function () { return run('date'); }); task('my_task', function () { writeln('What time is it? {{current_date}}'); run('sleep 5'); writeln('What time is it? {{current_date}}'); }); ``` -------------------------------- ### CakePHP Deployment Recipe Source: https://deployer.org/docs/8.x/recipe/cakephp Example of how to include the CakePHP recipe in your Deployer configuration. ```APIDOC ## Include CakePHP Recipe ### Description This snippet shows how to include the CakePHP recipe in your Deployer file to enable CakePHP-specific deployment tasks. ### Method Include ### Endpoint N/A ### Request Example ```php require 'recipe/cakephp.php'; ``` ### Response N/A ``` -------------------------------- ### Dynamic Configuration Syntax with Overrides Source: https://deployer.org/docs/8.x/basics Define new configuration options using dynamic syntax to reference values passed via the `-o` option. Use `get()` for original values and a function for overridden ones. ```php set('dir_name', 'test'); set('uses_original_dir_name', '/path/to/' . get('dir_name')); set('uses_overridden_dir_name', function () { return '/path/to/' . get('dir_name'); }); task('my_task', function () { writeln('Path: {{uses_original_dir_name}}'); writeln('Path: {{uses_overridden_dir_name}}'); }); ``` -------------------------------- ### Add Yammer Notification Hook Source: https://deployer.org/docs/8.x/contrib/yammer Add a hook to trigger Yammer notifications before a deployment starts. This is a common setup for initial deployment alerts. ```ruby before('deploy', 'yammer:notify'); ``` -------------------------------- ### Add Yarn Install Task to Deployment Source: https://deployer.org/docs/8.x/contrib/yarn Hook the 'yarn:install' task into the 'deploy:update_code' stage of your deployment. This ensures that Yarn dependencies are installed after the code is updated on the server. ```php after('deploy:update_code', 'yarn:install'); ``` -------------------------------- ### Magento asset deployment configuration Source: https://deployer.org/docs/8.x/recipe/magento2 For correct artifact deployment, `system/dev/js`, `system/dev/css`, and `system/dev/template` must be set in `app/etc/config.php`. Example shows settings for merging and minifying files. ```php 'system' => [ 'default' => [ 'dev' => [ 'js' => [ 'merge_files' => '1', 'minify_files' => '1' ], 'css' => [ 'merge_files' => '1', 'minify_files' => '1' ], 'template' => [ 'minify_html' => '1' ] ] ] ] ``` -------------------------------- ### Initialize via Phar Source: https://deployer.org/docs/8.x/installation Initialize Deployer using the downloaded Phar file. ```bash php deployer.phar init ``` -------------------------------- ### Initialize Deployer Source: https://deployer.org/docs/8.x/installation Create the deploy.php configuration file in your project. ```bash dep init ``` -------------------------------- ### Configure Local Alias and Initialization Source: https://deployer.org/docs/8.x/installation Set up a shell alias for the local vendor binary and initialize the project. ```bash alias dep='vendor/bin/dep' ``` ```bash vendor/bin/dep init ``` -------------------------------- ### Install Magento Cron Jobs Source: https://deployer.org/docs/8.x/recipe/magento2 This task installs cron jobs into the crontab. It is typically run after a Magento upgrade. Add this to your deployer scripts. ```php after('magento:upgrade', 'magento:cron:install'); ``` -------------------------------- ### Include Info Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/info Load the info recipe into your deployment configuration. ```php require 'recipe/deploy/info.php'; ``` -------------------------------- ### Access Host Configuration in Task Source: https://deployer.org/docs/8.x/basics Retrieve host-specific configuration values within a task using currentHost()->get() or the get() helper function. ```php task('my_task', function () { $myConfig = currentHost()->get('my_config'); writeln("my_config: " . $myConfig); }); ``` ```php task('my_task', function () { $myConfig = get('my_config'); writeln("my_config: " . $myConfig); }); ``` -------------------------------- ### Simple Deployer Recipe Source: https://deployer.org/docs/8.x/basics A basic Deployer recipe defining a single host and a task that runs the 'whoami' command. Ensure you have the Deployer namespace imported. ```php namespace Deployer; host('deployer.org'); task('my_task', function () { run('whoami'); }); ``` -------------------------------- ### Accessing Environment and Labels from YAML Source: https://deployer.org/docs/8.x/selector Retrieve configuration values using get('env') and label values using get('labels') within a task, as defined in the YAML recipe. ```php task('info', function () { writeln('env:' . get('env')['environment'] . ' labels.env:' . get('labels')['env']); }); ``` -------------------------------- ### Deploy Project with Deployer Source: https://deployer.org/docs/8.x/getting-started Run this command to deploy your project to the configured server. Deployer handles the release process. ```bash dep deploy ``` -------------------------------- ### Deploy Vendors Task Source: https://deployer.org/docs/8.x/recipe/deploy/vendors Task for installing Composer vendors. ```APIDOC ## Tasks ### deploy:vendors **Source:** Installs vendors. ``` -------------------------------- ### Get Current Host Source: https://deployer.org/docs/8.x/api Retrieves the current host object. ```APIDOC ## currentHost() ### Description Returns current host. ### Endpoint currentHost(): Host ``` -------------------------------- ### Include User Recipe Source: https://deployer.org/docs/8.x/recipe/provision/user Load the user provisioning functionality into your project. ```php require 'recipe/provision/user.php'; ``` -------------------------------- ### Get output interface Source: https://deployer.org/docs/8.x/api Returns the current output interface instance. ```php output(): OutputInterface ``` -------------------------------- ### Include Supervisord-monitor Recipe Source: https://deployer.org/docs/8.x/contrib/supervisord-monitor Include the supervisord-monitor.php file to enable its functionality. ```php require 'contrib/supervisord-monitor.php'; ``` -------------------------------- ### Add Deployment Hook Source: https://deployer.org/docs/8.x/contrib/discord Trigger a Discord notification before the deployment starts. ```php before('deploy', 'discord:notify'); ``` -------------------------------- ### Display Execution Plan Source: https://deployer.org/docs/8.x/cli Use the '--plan' option with the 'dep deploy' command to output a table showing the order of task execution on different hosts. ```bash $ dep deploy --plan all ``` -------------------------------- ### Provision Server with Sudo Source: https://deployer.org/docs/8.x/getting-started If your remote user has sudo privileges to become root, use this option during provisioning. ```bash dep provision -o become=root ``` -------------------------------- ### Include Provision Recipe Source: https://deployer.org/docs/8.x/recipe/provision Load the provision recipe into your project configuration. ```php require 'recipe/provision.php'; ``` -------------------------------- ### Set up Deployer CLI Alias Source: https://deployer.org/docs/8.x/cli Add this alias to your .bashrc file for convenient access to the Deployer CLI. ```bash alias dep='vendor/bin/dep' ``` -------------------------------- ### Include Clear Paths Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/clear_paths Import the clear_paths recipe into your deployment configuration. ```php require 'recipe/deploy/clear_paths.php'; ``` -------------------------------- ### Include Databases Recipe Source: https://deployer.org/docs/8.x/recipe/provision/databases Include the Databases Recipe to enable database provisioning tasks. This is typically the first step when setting up database-related functionality. ```php require 'recipe/provision/databases.php'; ``` -------------------------------- ### Get current timestamp Source: https://deployer.org/docs/8.x/api Returns the current UTC timestamp in ISO8601 format. ```php timestamp(): string ``` -------------------------------- ### Get remote environment variables Source: https://deployer.org/docs/8.x/api Retrieves remote environment variables as an array. ```php remoteEnv(): array ``` ```php $remotePath = remoteEnv()['PATH']; run('echo $PATH', env: ['PATH' => "/home/user/bin:$remotePath"]); ``` -------------------------------- ### Retrieve Contao Version Source: https://deployer.org/docs/8.x/recipe/contao Determine the installed Contao version by parsing the console output. ```php $result = run('{{bin/console}} --version'); preg_match_all('/(\d+\.?)+/', $result, $matches); return $matches[0][0] ?? 'n/a'; ``` -------------------------------- ### Define a Host Source: https://deployer.org/docs/8.x/hosts Basic syntax for defining a host in Deployer. ```php host('example.org'); ``` -------------------------------- ### Get configuration value Source: https://deployer.org/docs/8.x/api Retrieves a configuration value by name, optionally providing a default. ```php get(string $name, $default = null) ``` -------------------------------- ### Get current host Source: https://deployer.org/docs/8.x/api The `currentHost()` function returns the `Host` instance of the currently executing host. ```php currentHost(): Host ``` -------------------------------- ### Include Phinx Recipe Source: https://deployer.org/docs/8.x/contrib/phinx Load the Phinx recipe into your Deployer configuration. ```php require 'contrib/phinx.php'; ``` -------------------------------- ### RoadRunner Console Commands Source: https://deployer.org/docs/8.x/recipe/spiral Control the RoadRunner server, including starting, stopping, and resetting workers. ```bash roadrunner:serve ``` ```bash roadrunner:stop ``` ```bash roadrunner:reset ``` -------------------------------- ### Include Copy Dirs Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/copy_dirs Load the copy_dirs recipe into your deployment configuration. ```php require 'recipe/deploy/copy_dirs.php'; ``` -------------------------------- ### Include Discord Recipe Source: https://deployer.org/docs/8.x/contrib/discord Load the Discord recipe into your project. ```php require 'contrib/discord.php'; ``` -------------------------------- ### Get Selected Hosts Source: https://deployer.org/docs/8.x/api Retrieves an array of hosts that were selected by the user via the command line interface. ```APIDOC ## selectedHosts() ### Description Returns array of hosts selected by user via CLI. ### Endpoint selectedHosts(): array ``` -------------------------------- ### Yii2 Deployment Steps Source: https://deployer.org/docs/8.x/recipe/yii Detailed breakdown of the steps within the `deploy:prepare` task for Yii2 projects. ```APIDOC The deploy task of **Yii2** consists of: * deploy:prepare – Prepares a new release * deploy:info – Displays info about deployment * deploy:setup – Prepares host for deploy * deploy:lock – Locks deploy * deploy:release – Prepares release * deploy:update_code – Updates code * deploy:env – Configure .env file * deploy:shared – Creates symlinks for shared files and dirs * deploy:writable – Makes writable dirs * deploy:vendors – Installs vendors * deploy:migrate – Runs Yii2 migrations for your project * deploy:publish * deploy:symlink – Creates symlink to release * deploy:unlock – Unlocks deploy * deploy:cleanup – Cleanup old releases * deploy:success – Deploys your project ``` -------------------------------- ### Rsync Usage Source: https://deployer.org/docs/8.x/contrib/rsync Instructions on how to use the rsync task and rsync:warmup task. ```APIDOC ## Usage ### `rsync` task Set `rsync_src` to a locally cloned repository and rsync to `rsync_dest`. Then, set this task instead of `deploy:update_code` in your `deploy` task if your hosting provider does not allow git. ### `rsync:warmup` task If your deploy task looks like this: ```php task('deploy', [ 'deploy:prepare', 'deploy:release', 'rsync', 'deploy:vendors', 'deploy:symlink', ])->desc('Deploy your project'); ``` And your `rsync_dest` is set to `{{release_path}}`, then you could add this task to run before the `rsync` task or after `deploy:release`, whichever is more convenient. ``` -------------------------------- ### Get selected hosts Source: https://deployer.org/docs/8.x/api The `selectedHosts()` function returns an array of hosts that were selected by the user via the command-line interface. ```php selectedHosts(): array ``` -------------------------------- ### Import configuration and tasks Source: https://deployer.org/docs/8.x/UPGRADE Use the import directive to load recipes, configurations, and host definitions. ```yaml import: recipe/common.php config: application: deployer shared_dirs: - uploads - storage/logs/ - storage/db shared_files: - .env - config/test.yaml keep_releases: 3 http_user: false hosts: prod: local: true tasks: deploy: - deploy:prepare - deploy:vendors - deploy:publish deploy:vendors: - run: "cd {{release_path}} && echo {{bin/composer}} {{composer_options}} 2>&1" ``` -------------------------------- ### Running a Task with an 'env=prod' Selector Source: https://deployer.org/docs/8.x/selector Execute the 'info' task on all hosts that have the 'env: prod' label. This demonstrates basic label-based selection. ```bash $ dep info env=prod ``` -------------------------------- ### Get Crontab Executable Path Source: https://deployer.org/docs/8.x/contrib/crontab Determine the path to the crontab executable. This is used to locate the crontab command on the system. ```php return which('crontab'); ``` -------------------------------- ### Register Deployment Notification Tasks Source: https://deployer.org/docs/8.x/contrib/ms-teams Hook the notification tasks into the deployment lifecycle to receive updates on start, success, or failure. ```php before('deploy', 'teams:notify'); after('deploy:success', 'teams:notify:success'); after('deploy:failed', 'teams:notify:failure'); ``` ```php before('deploy', 'teams:notify'); ``` ```php after('deploy:success', 'teams:notify:success'); ``` ```php after('deploy:failed', 'teams:notify:failure'); ``` -------------------------------- ### Configure ISPManager Databases Source: https://deployer.org/docs/8.x/contrib/ispmanager Set the default database server and host configuration. ```php [ 'servers' => [], 'hosts' => [], 'dblist' => [], ] ``` -------------------------------- ### Include Workplace Recipe Source: https://deployer.org/docs/8.x/contrib/workplace Load the workplace recipe file into your deployment configuration. ```php require 'contrib/workplace.php'; ``` -------------------------------- ### Provision Server with Custom User Source: https://deployer.org/docs/8.x/getting-started Use this option to specify a different root user for the provisioning process if it's not 'root'. ```bash dep provision -o provision_user=your-user ``` -------------------------------- ### Include cPanel Recipe Source: https://deployer.org/docs/8.x/contrib/cpanel Load the cPanel recipe into your Deployer project. ```php require 'contrib/cpanel.php'; ``` -------------------------------- ### Include Rabbit Recipe Source: https://deployer.org/docs/8.x/contrib/rabbit Load the RabbitMQ recipe into your deployment configuration. ```php require 'contrib/rabbit.php'; ``` ```php deploy.php require 'recipe/rabbit.php'; ``` -------------------------------- ### Include Rsync Recipe Source: https://deployer.org/docs/8.x/contrib/rsync Load the rsync contribution script into your project. ```php require 'contrib/rsync.php'; ``` -------------------------------- ### Get Release Revision Source: https://deployer.org/docs/8.x/recipe/deploy/release Retrieves the current release revision, typically a Git hash, from the REVISION file within the release path. ```php return run('cat {{release_path}}/REVISION'); ``` -------------------------------- ### Add Telegram Notification Task to Deploy Source: https://deployer.org/docs/8.x/contrib/telegram Add the 'telegram:notify' task to be executed before the 'deploy' task to send a notification at the start of a deployment. ```php before('deploy', 'telegram:notify'); ``` -------------------------------- ### Configure Virtual Host Settings Source: https://deployer.org/docs/8.x/contrib/ispmanager Define default virtual host configuration parameters. ```php [ 'name' => '{{domain}}', 'php_enable' => 'on', 'aliases' => 'www.{{domain}}', 'home' => 'www/{{domain}}', 'owner' => get('ispmanager_owner'), 'email' => 'webmaster@{{domain}}', 'charset' => 'off', 'dirindex' => 'index.php uploaded.html', 'ssi' => 'on', 'php' => 'on', 'php_mode' => 'php_mode_mod', 'basedir' => 'on', 'php_apache_version' => 'native', 'cgi' => 'off', 'log_access' => 'on', 'log_error' => 'on', ] ``` -------------------------------- ### Provisioning Tasks Source: https://deployer.org/docs/8.x/recipe/provision/databases Available tasks for provisioning various database systems. ```APIDOC ## Tasks ### provision:databases - Description: Provision databases. ### provision:mysql - Description: Provision MySQL. ### provision:mariadb - Description: Provision MariaDB. ### provision:postgresql - Description: Provision PostgreSQL. ``` -------------------------------- ### Default Drupal Site Configuration Source: https://deployer.org/docs/8.x/recipe/drupal8 Set the default Drupal site name. Change this value if your Drupal installation uses a different site name. ```php 'default' ``` -------------------------------- ### Set Current Path Source: https://deployer.org/docs/8.x/recipe/common Define the path to the current release. Defaults to the deploy path followed by 'current'. ```php set('current_path', '/var/public_html'); ``` ```php '{{deploy_path}}/current' ``` -------------------------------- ### TYPO3 Deployment Tasks Source: https://deployer.org/docs/8.x/recipe/typo3 A list of available tasks for managing TYPO3 deployments, including cache management, extension setup, and folder structure fixes. ```APIDOC ## TYPO3 Deployment Tasks ### Description These tasks are part of the TYPO3 recipe for Deployer to manage application lifecycle and maintenance. ### Available Commands - `typo3:cache:flush` - Clear all TYPO3 caches - `typo3:cache:warmup` - Cache warmup for system caches - `typo3:language:update` - Update the language files of all activated extensions - `typo3:extension:setup` - Set up all extensions - `typo3:install:fixfolderstructure` - Automatically create required files and folders for TYPO3 ### Usage Example `vendor/bin/dep typo3:cache:flush` ``` -------------------------------- ### Include Writable Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/writable Import the writable recipe functionality into your deployment script. ```php require 'recipe/deploy/writable.php'; ``` -------------------------------- ### Magento DI compilation configuration Source: https://deployer.org/docs/8.x/recipe/magento2 To ensure correct operation with artifact deployment, the `MAGE_MODE` must be set correctly in `app/etc/config.php`. Example shown for production mode. ```php 'MAGE_MODE' => 'production' ``` -------------------------------- ### Configure Log Files Source: https://deployer.org/docs/8.x/recipe/codeigniter4 Sets the pattern for log files. ```php 'writable/logs/*.log' ``` -------------------------------- ### Change working directory Source: https://deployer.org/docs/8.x/api The `cd()` function changes the current working directory for subsequent commands. The example shows changing to `~/myapp` and then running `ls` in that directory. ```php cd('~/myapp'); run('ls'); // Will run `ls` in ~/myapp. ``` -------------------------------- ### Get Release or Current Path Source: https://deployer.org/docs/8.x/recipe/deploy/release Returns the release path during a deployment. If a release path does not exist (e.g., not currently deploying), it falls back to the current path. ```php $releaseExists = test('[ -h {{deploy_path}}/release ]'); return $releaseExists ? get('release_path') : get('current_path'); ``` -------------------------------- ### Get Npm Binary Path Source: https://deployer.org/docs/8.x/contrib/npm This code snippet determines the path to the npm binary. It's used for configuration if the npm binary is not in the system's PATH. ```php return which('npm'); ``` -------------------------------- ### Bitbucket Pipelines for Staging Deployment Source: https://deployer.org/docs/8.x/ci-cd This Bitbucket pipeline deploys to a staging environment on the `develop` branch. It includes steps for Composer and NPM installation, followed by the Deployer deployment. ```yaml pipelines: branches: develop: - stage: # this is the target deployment name and it will inherit the environment from it deployment: staging name: Deploy Staging steps: - step: name: Composer Install image: composer/composer:2.2 caches: - composer script: - composer install --quiet artifacts: # we need to save all these files so that they can be picked up in the actual deployment - vendor/** - step: name: NPM Install image: node:22-bullseye-slim caches: - node script: - npm install --silent artifacts: # we need to save all these files so that they can be picked up in the actual deployment - public/build/** - step: name: Deployer Deploy timeout: 6m # if it takes longer than this, error out # @see https://hub.docker.com/r/deployphp/deployer/tags?name=v7.5 image: deployphp/deployer:v7.5.8 script: # pass $DEVELOP and $STAGING variables from the "staging" deployment environment - php /bin/deployer.phar deploy --branch=$DEVELOP stage=$STAGING ``` -------------------------------- ### Provision Tasks Source: https://deployer.org/docs/8.x/recipe/provision List of available tasks for server provisioning and verification. ```APIDOC ## Tasks ### provision - **Description**: Main group task to provision the server. Executes: check, configure, update, upgrade, install, ssh, firewall, user, php, node, databases, composer, server, website, and verify. ### provision:check - **Description**: Checks pre-required state. ### provision:configure - **Description**: Collects required params. ### provision:update - **Description**: Adds repositories and updates system. ### provision:upgrade - **Description**: Upgrades all packages. ### provision:install - **Description**: Installs packages. ### provision:ssh - **Description**: Configures the SSH service. ### provision:firewall - **Description**: Setups a firewall. ### provision:verify - **Description**: Verifies that the provision was successful. ``` -------------------------------- ### Include Rollback Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/rollback Load the rollback functionality into your deployment configuration. ```php require 'recipe/deploy/rollback.php'; ``` -------------------------------- ### Composer Binary Path Source: https://deployer.org/docs/8.x/recipe/deploy/vendors Determines the Composer binary path. If not found, it attempts to install the latest Composer version to `.dep/composer.phar`. For a specific version, download the phar and place it at `.dep/composer.phar`. -------------------------------- ### Include Flow Framework Recipe Source: https://deployer.org/docs/8.x/recipe/flow_framework Include the Flow Framework recipe for Deployer. This is typically the first step in your deploy.php file. ```php require 'recipe/flow_framework.php'; ``` -------------------------------- ### Enable Autocomplete Source: https://deployer.org/docs/8.x/installation Generate shell completion files for Bash, Zsh, and Fish. ```bash dep completion bash > /etc/bash_completion.d/deployer ``` ```bash dep completion zsh > ~/.zsh/completion/_deployer ``` ```bash dep completion fish > ~/.config/fish/completions/deployer.fish ``` -------------------------------- ### Configuration Options Source: https://deployer.org/docs/8.x/recipe/common Details on available configuration settings for the deployer. ```APIDOC ## Configuration ### user **Description:** Name of the current user running the deployment. If not set, it attempts to automatically get the Git user name or falls back to the `whoami` command output. **Autogenerated:** The value is autogenerated on access. ### keep_releases **Description:** Number of releases to preserve in the releases folder. **Default value:** `10` ### repository **Description:** The repository to deploy. ### default_timeout **Description:** Default timeout for `run()` and `runLocally()` functions. Set to `null` to disable timeout. **Default value:** `300` ### env **Description:** Remote environment variables. **Example:** ```php set('env', [ 'KEY' => 'something', ]); ``` It is possible to override it per `run()` call: ```php run('echo $KEY', env: ['KEY' => 'over']); ``` ### dotenv **Description:** Path to the `.env` file which will be used as environment variables for each command per `run()`. **Example:** ```php set('dotenv', '{{release_or_current_path}}/.env'); ``` **Default value:** `false` ### deploy_path **Description:** The deploy path. Can be set for a bunch of hosts once as: **Example:** ```php set('deploy_path', '~/{{alias}}'); ``` **Required:** Throws an exception if not set. ### current_path **Description:** Returns the current release path. Defaults to `deploy_path/current`. **Example:** ```php set('current_path', '/var/public_html'); ``` **Default value:** `'{{deploy_path}}/current'` ### bin/php **Description:** Path to the `php` binary. **Default value:** ```php if (currentHost()->hasOwn('php_version')) { return '/usr/bin/php{{php_version}}'; } return which('php'); ``` ### bin/git **Description:** Path to the `git` binary. **Default value:** ```php return which('git'); ``` ### use_relative_symlink **Description:** Determines if the `bin/symlink` should use the `--relative` option. Detects automatically. **Default value:** ```php return commandSupportsOption('ln', '--relative'); ``` ### bin/symlink **Description:** Path to the `ln` binary, with predefined options `-nfs`. **Default value:** ```php return get('use_relative_symlink') ? 'ln -nfs --relative' : 'ln -nfs'; ``` ### sudo_askpass **Description:** Path to a file that will store a temporary script with the sudo password. Defaults to `.dep/sudo_pass`. This script is temporary and will be deleted after the sudo command is executed. **Autogenerated:** The value is autogenerated on access. ``` -------------------------------- ### Define Build Task in deploy.php Source: https://deployer.org/docs/8.x/getting-started Add a custom build task to your deploy.php file to automate steps like installing dependencies and running build scripts. This task is then hooked into the deployment process. ```php task('build', function () { cd('{{release_path}}'); run('npm install'); run('npm run prod'); }); after('deploy:update_code', 'build'); ``` -------------------------------- ### Set Git Repository Source: https://deployer.org/docs/8.x/recipe/shopware Configure the Git repository for your Shopware project in your _deploy.php_ file. ```php set('repository', 'git@github.com:shopware/production.git'); ``` -------------------------------- ### Include Pimcore Recipe Source: https://deployer.org/docs/8.x/recipe/pimcore Load the Pimcore recipe into your Deployer configuration file. ```php require 'recipe/pimcore.php'; ``` -------------------------------- ### Include Shopware Recipe Source: https://deployer.org/docs/8.x/recipe/shopware Include the Shopware deployment recipe in your deploy.php file. ```php require 'recipe/shopware.php'; ``` -------------------------------- ### run() Source: https://deployer.org/docs/8.x/api Executes a given command on a remote host. ```APIDOC ## run() ### Description Executes a given command on a remote host. ### Parameters - **$command** (string) - Required - Command to run on remote host. - **$cwd** (string|null) - Optional - Sets the process working directory. - **$env** (array|null) - Optional - Array of environment variables. - **$secret** (string|null) - Optional - Placeholder %secret% replacement, hidden from logs. - **$nothrow** (bool|null) - Optional - Don't throw an exception on non-zero exit code. - **$forceOutput** (bool|null) - Optional - Print command output in real-time. - **$timeout** (int|null) - Optional - Max runtime in seconds. - **$idleTimeout** (int|null) - Optional - Max time since last output in seconds. ### Response - **return** (string) - The output of the command. ``` -------------------------------- ### Prepare Artifact for Deployment Source: https://deployer.org/docs/8.x/recipe/magento2 Prepares an artifact on the target server. This is a group task that orchestrates several other deployment-related tasks. ```php deploy:info deploy:setup deploy:lock deploy:release artifact:upload artifact:extract deploy:additional-shared deploy:shared deploy:writable ``` -------------------------------- ### Include PHP Recipe Source: https://deployer.org/docs/8.x/recipe/provision/php Include the PHP provision recipe in your configuration file. ```php require 'recipe/provision/php.php'; ``` -------------------------------- ### Execute a Task with a Selector Source: https://deployer.org/docs/8.x/basics Use the Deployer CLI to execute a specific task on a given selector of hosts. The first argument is the task, and the second is the host selector. ```bash $ dep deploy deployer.org ``` -------------------------------- ### Include WordPress Recipe Source: https://deployer.org/docs/8.x/recipe/wordpress Load the WordPress recipe to enable project-specific deployment tasks. ```php require 'recipe/wordpress.php'; ``` -------------------------------- ### artifact:prepare Source: https://deployer.org/docs/8.x/recipe/magento2 Prepares an artifact on the target server by executing a series of deployment tasks. ```APIDOC ## artifact:prepare ### Description Prepares an artifact on the target server. This task is a group task which contains several sub-tasks. ### Method Not specified (likely a script command) ### Endpoint Not specified ### Sub-tasks - deploy:info - deploy:setup - deploy:lock - deploy:release - artifact:upload - artifact:extract - deploy:additional-shared - deploy:shared - deploy:writable ``` -------------------------------- ### Include Lock Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/lock Import the lock functionality into your deployment configuration. ```php require 'recipe/deploy/lock.php'; ``` -------------------------------- ### Prompt for Database Name Source: https://deployer.org/docs/8.x/recipe/provision/databases Prompts the user for the database name, with 'prod' as the default value. Use this configuration to set the name of the database to be provisioned. ```php return ask(' DB name: ', 'prod'); ``` -------------------------------- ### Rsync Usage Configuration Source: https://deployer.org/docs/8.x/recipe/typo3 Toggle for using rsync instead of Git for deployment. ```php false ``` -------------------------------- ### Include Push Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/push Include the push recipe in your deployment configuration to enable the push task. ```php require 'recipe/deploy/push.php'; ``` -------------------------------- ### System and Environment Methods Source: https://deployer.org/docs/8.x/api Methods for system command interaction and environment management. ```APIDOC ## commandExist() ### Description Check if a command exists. ## commandSupportsOption() ### Description Check if a command supports a specific option. ## which() ### Description Locates a command path. ## remoteEnv() ### Description Returns remote environment variables as an array. ## timestamp() ### Description Returns current timestamp in UTC timezone in ISO8601 format. ## fetch() ### Description Performs an HTTP request. ``` -------------------------------- ### Migrations Component Console Commands Source: https://deployer.org/docs/8.x/recipe/spiral Initialize, replay, rollback, and check the status of migrations using console commands. ```bash migrate:init ``` ```bash migrate:replay ``` ```bash migrate:rollback ``` ```bash migrate:status ``` -------------------------------- ### Include ISPManager Recipe Source: https://deployer.org/docs/8.x/contrib/ispmanager Load the ISPManager recipe into the project. ```php require 'contrib/ispmanager.php'; ``` -------------------------------- ### Configure Cachetool Web Adapter Arguments Source: https://deployer.org/docs/8.x/contrib/cachetool Configure arguments for the Cachetool web adapter, used when direct socket access is not possible. Specify the web path and URL. ```php set('cachetool_args', '--web --web-path=./public --web-url=https://{{hostname}}'); ``` -------------------------------- ### Filter Hosts by Labels Source: https://deployer.org/docs/8.x/hosts Use label selectors to target specific hosts during deployment. ```bash $ dep deploy stage=prod&role=web,role=special ``` ```php set('default_selector', "stage=prod&role=web,role=special"); ``` -------------------------------- ### Set Deploy Path Source: https://deployer.org/docs/8.x/recipe/common Define the base deployment path. This is a required configuration. ```php set('deploy_path', '~/{{alias}}'); ``` -------------------------------- ### Configure Host in deploy.php Source: https://deployer.org/docs/8.x/getting-started Define your host with essential parameters like the remote SSH user and the deployment path. This configuration is part of your deploy.php recipe. ```php host('example.org') ->set('remote_user', 'deployer') ->set('deploy_path', '~/example'); ``` -------------------------------- ### Run Task on All Hosts with Verbosity Source: https://deployer.org/docs/8.x/basics Execute a task on all defined hosts and view detailed output. The 'all' selector targets every host in the recipe. ```bash $ dep my_task -v all ``` -------------------------------- ### Execute a Task from Recipe Source: https://deployer.org/docs/8.x/basics Execute the 'my_task' defined in your recipe. By default, only task names are shown. ```bash $ dep my_task ``` -------------------------------- ### Configure Domain Source: https://deployer.org/docs/8.x/recipe/provision/website Prompts the user for the domain name, defaulting to the current hostname. ```php return ask(' Domain: ', get('hostname')); ``` -------------------------------- ### Create Symlink to Release Source: https://deployer.org/docs/8.x/recipe/deploy/symlink The `deploy:symlink` task creates the necessary symbolic link to the current release. ```bash echo "Creating symlink to release." ``` -------------------------------- ### Configure Multiple Cachetool Sockets Source: https://deployer.org/docs/8.x/contrib/cachetool Provide an array of unix socket paths for Cachetool to use. This allows for multiple fallback options. ```php set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock']); ``` -------------------------------- ### Include Cleanup Recipe Source: https://deployer.org/docs/8.x/recipe/deploy/cleanup Include the cleanup recipe to enable the deploy:cleanup task. This is typically done at the beginning of your Deployer configuration file. ```php require 'recipe/deploy/cleanup.php'; ``` -------------------------------- ### Configuration Methods Source: https://deployer.org/docs/8.x/api Methods for managing configuration options. ```APIDOC ## parse() ### Description Parse set values. ## set() ### Description Setup configuration option. ## add() ### Description Merge new config params to existing config array. ## get() ### Description Get configuration value. ## has() ### Description Check if there is such configuration option. ``` -------------------------------- ### View deployment releases Source: https://deployer.org/docs/8.x/getting-started Executes the releases task to list all deployment history on the target host. ```bash dep releases ```