lameco / deployer-tasks
Common tasks for Deployer
Installs: 286
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 12
pkg:composer/lameco/deployer-tasks
Requires
- php: ^8.4
- deployer/deployer: ^7.0
This package is auto-updated.
Last update: 2025-10-07 06:55:15 UTC
README
A collection of common tasks for Deployer to streamline deployment workflows.
Requirements
- PHP 8.4 or higher
- Deployer 7.0 or higher
Installation
composer require lameco/deployer-tasks --dev
Available Tasks
lameco:load
Loads project configuration for use in custom tasks.
- Detects project type (
symfony,kunstmaan,craftcms,laravel) by checking for key files and composer packages. - Sets
lameco_project_type,lameco_dump_dir, andlameco_public_diraccordingly. - These variables are used in default directory settings and can be overridden in your
deploy.php.
lameco:stage_prompt
Prompts to deploy all hosts with the same stage if applicable.
- If a host has a
stageset, and there are other hosts with the samestage, you will be prompted to deploy to all hosts with that stage. This helps prevent accidental partial deployments and ensures consistency across environments.
lameco:db_download
Downloads the remote database and imports it locally.
- Reads the remote
.envfile to extract DB credentials (supports Symfony, Craft CMS, Laravel formats, andDATABASE_URL). - Creates a compressed database dump on the remote server.
- Downloads the dump to a local directory (as determined by
lameco_dump_dir). - Reads the local
.envfor local DB credentials. - Drops and recreates the local database, then imports the dump.
- Cleans up dump files both remotely and locally.
lameco:db_credentials
Displays remote database credentials.
- Reads the remote
.envfile. - Extracts and prints the remote DB username and password.
lameco:download
Downloads directories from remote to local.
- Downloads each directory in
lameco_download_dirsfrom{{deploy_path}}/sharedon the remote to the same path locally. - By default, downloads
['{{lameco_public_dir}}/uploads']. - For Craft CMS projects, also downloads the
translationsdirectory by default.
lameco:upload
Uploads directories from local to remote.
- Uploads each directory in
lameco_upload_dirsfrom local to{{deploy_path}}/sharedon the remote. - By default, uploads
['{{lameco_public_dir}}/uploads']. - For Craft CMS projects, also uploads the
translationsdirectory by default.
lameco:build_assets
Builds local assets.
- Loads Node.js version from
.nvmrc. - Installs the correct Node.js version using nvm if not already installed.
- Enables Corepack if supported by Node.js version (Node 14.19+, 16.9+, or >16).
- Installs dependencies with yarn.
- Builds assets with yarn.
- Appends any flags set in
lameco_assets_build_flagsto the yarn build command.
lameco:upload_assets
Uploads built assets to remote.
- Uploads each directory in
lameco_assets_dirsfrom local to{{release_path}}on the remote. - Uploads each file in
lameco_assets_filesfrom local to{{release_path}}on the remote. - Default: uploads
['{{lameco_public_dir}}/dist']for directories, empty array for files.
lameco:restart_php
Restarts php-fpm service.
- Restarts the service specified by
lameco_php_config(default:php-fpm-{{http_user}}.service) on the remote server. - Skips if
lameco_restart_phpis false.
lameco:restart_supervisor
Restarts supervisor.
- Restarts each supervisor config in
lameco_supervisor_configsusingsupervisorctl. - Skips if
lameco_restart_supervisoris false.
crontab:sync
Synchronizes crontab jobs for the project.
- Automatically sets up crontab jobs based on project type and detected plugins (e.g., Craft CMS with Blitz or Formie).
- Jobs are defined in the
crontab:jobsconfiguration, which is dynamically generated for Craft CMS projects.
lameco:update_htpasswd
Updates .htpasswd file for staging environments.
- Automatically checks if the current hostname contains "staging".
- If it's a staging environment, creates or updates the
.htpasswdfile at/projects/{{http_user}}/.local/nginx/.htpasswd. - Sets the username to
lamecoand uses thehttp_uservalue as the password, hashed with bcrypt. - Uses
mkpasswd -m bcryptto generate the password hash as recommended by Rootnet. - Skips the update if the
.htpasswdfile is already up-to-date.
Parameters
lameco_project_type: Project type (auto-detected:symfony,kunstmaan,craftcms,laravel)lameco_dump_dir: Directory for database dumps (auto-set by project type)lameco_public_dir: Public directory (auto-set by project type)lameco_download_dirs: Directories to download from remote (default:['{{lameco_public_dir}}/uploads'], plustranslationsfor Craft CMS)lameco_upload_dirs: Directories to upload to remote (default:['{{lameco_public_dir}}/uploads'], plustranslationsfor Craft CMS)lameco_assets_dirs: Asset directories to upload (default:['{{lameco_public_dir}}/dist'])lameco_assets_files: Asset files to upload (default:[])lameco_assets_build_flags: Extra flags to append to the yarn build command (default:[])lameco_restart_php: Enable/disable PHP-FPM restart (default: true)lameco_php_config: PHP-FPM systemd service name (default:php-fpm-{{http_user}}.service)lameco_restart_supervisor: Enable/disable supervisor restart (default: true)lameco_supervisor_configs: Supervisor config files (default:[get('http_user') . '.conf'])http_user: User running PHP-FPM or supervisor
Task Dependencies
lameco:loadruns beforedeploylameco:stage_promptruns beforedeploylameco:db_download,lameco:db_credentials,lameco:download, andlameco:uploaddepend onlameco:loadlameco:build_assetsruns beforedeploy:symlinklameco:upload_assetsruns afterlameco:build_assetslameco:restart_phpandlameco:restart_supervisorrun afterdeploy:cleanupcrontab:syncandlameco:update_htpasswdrun afterdeploy:success
Usage
Include the tasks in your deploy.php file:
require 'vendor/lameco/deployer-tasks/src/tasks.php'; // Override or extend parameters if needed set('lameco_assets_dirs', ['public/build']); add('lameco_supervisor_configs', ['app.conf', 'queue.conf']); set('lameco_php_config', 'php-fpm-customuser.service');
Notes
- Project type detection is automatic and supports Symfony, Kunstmaan, Craft CMS, and Laravel.
- Database credential extraction supports
.envformats for Symfony (DATABASE_URL), Craft CMS (CRAFT_DB_*), and Laravel (DB_*). - Asset build and upload tasks expect a working Node.js/yarn setup and
.nvmrcfile. - Supervisor and PHP-FPM restarts are configurable and can be disabled per project.
License
This package is open-sourced software licensed under the MIT license.