lameco / deployer-tasks
Common tasks for Deployer
Installs: 400
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 9
pkg:composer/lameco/deployer-tasks
Requires
- php: ^8.4
- deployer/deployer: ^7.0
Requires (Dev)
- rector/rector: ^2.2
- symplify/easy-coding-standard: ^13.0
- dev-main
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1
- 1.0
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-development
- dev-feature/issues
- dev-copilot/fix-nvm-logic-in-build-assets
- dev-copilot/fix-image-file-permissions
- dev-copilot/fix-30
- dev-feature/assets-build-flags
- dev-copilot/fix-21
- dev-copilot/fix-18
- dev-copilot/fix-20
- dev-copilot/fix-19
This package is auto-updated.
Last update: 2025-12-23 14:56:01 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:verify_deploy_branch
Ensures the local branch matches the deployment branch.
- Compares the current local git branch with the branch configured on the host (or
--branchwhen provided). - Stops the deployment if the branches do not match, preventing asset builds from mismatching the deployed code.
- If deploying to a
staging*host without a branch configured, andoriginhasrelease/*branches, deployment is halted until a release branch is selected.
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.
- Loads nvm in a non-interactive bash shell and runs each command with
nvm use, so manualnvm useis not required. - 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:verify_deploy_branchruns 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. lameco:build_assetsexpects nvm in$NVM_DIR(or~/.nvm) and usesbash -lcto load it.- Supervisor and PHP-FPM restarts are configurable and can be disabled per project.
- For staging hosts, configure a deployment branch (or pass
--branch) ifrelease/*branches exist to avoid ambiguous deployments.
License
This package is open-sourced software licensed under the MIT license.