LUYA Website deployment tool.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


LUYA Deployer

LUYA Total Downloads Latest Stable Version Join the chat at

This is the recipe to deploy your LUYA Website with deployer.


Add the deployer composer package to your project:

composer require luyadev/luya-deployer:~1.0.0 --dev

Create a deploy.php file with the content of your server configuration(s) and store it in the root directory of your project:

require 'vendor/luyadev/luya-deployer/luya.php';

// define your configuration here
server('prod', 'SSHHOST.COM', 22)
    ->password('SSHPASS') // You can use identity key, ssh config, or username/password to auth on the server.
    ->env('deploy_path', '/var/www/vhosts/path/httpdocs'); // Define the base path to deploy your project to.

set('repository', '');

To deploy to the above configured server just go into the console and run:

./vendor/bin/dep luya prod

If you have defined other servers like prep, dev etc you can just changed the server in the command. Lets say you have defined also a dev server:

./vendor/bin/dep luya dev

In order to configure a branch to deploy use env('branch', 'myCheckoutBranch');

Set your vhost entry directory

In order to run your website, you have to modify the root directory of your website to current/public_html folder. Deployer will create the following folders:

  • releases
  • current
  • shared

Those folders are located in your defined deploy_path folder.



variable description example
installFxpPlugin Whether fxp plugin should be installed or not set('installFxpPlugin', false) disable auto installing of fxp composer asset plugin (global require scope).
adminCoreCommands Sometimes you want to disable the default core commands of the admin module (migrate & import command). Thisi mostly the case when using a luya core application without admin and cms modules. set('adminCoreCommands', false)
keepDeployer Sometimes you want to leave the deployer.php file on the server (which will be default deleted from the server after deployment) in order enable this option set('keepDeployer', true)
requireConfig As LUYA creates a env.php file which contains the config which should be picked, by default it uses the name of the server name. So if you define server('prod', ...) then env-prod.php config will be loaded in env.php. set('requireConfig', 'custom_config'); Now the env.php file created by deployer on the server will look like this <?php return require 'custom_config.php'; ?>

Add custom commands

You might want to execute a custom LUYA task, which will be executed after the basic LUYA tasks are finished. To do this, you can use the beforeCommands and afterCommands variable with an array list of commands. If you want to run a command even before migrat command use beforeCoreCommands.

  • beforeCommands: Will be excuted after the migration has been applied but before the import command.
  • afterCommands: Will be executed after the import command.
set('afterCommands', [
    './vendor/bin/luya <mymodule>/<controller/<action>',

Command execution lifecycle:

  1. run beforeCoreCommands.
  2. if adminCoreCommands is enabled: migration
  3. run beforeCommands
  4. if adminCoreCommands is enabled: import, health
  5. run afterCommands

Create a custom task

Example of an additional task using a task from LUYA deployer recipe on specfic conditions:

task('customtask', array(

after('deploy:luya', 'customtask');

Where customtask can be a group of other tasks or a task with a functions (which could be grouped to). See the official Deployer documentation.

Another practical example is using a remote executed shell command in a custom task. For this we are using another LUYA module to automatically export a remote database and import it to the local database. This example will export the prod database of a project and import it, but only for the prep environment. Note the switched off interactive flag to override the security questions, because we are unable to obtain any user input via deployer tasks:

task('deploy:importProdDb', function() {
    run('./vendor/bin/luya exporter/database/remote-replace-local "mysql:host=localhost;dbname=prod_database" "USER" "PASSWORD" --interactive=0');

after('deploy:luya', 'deploy:importProdDb');

Additional Providers