This is the LUYA recipe to deploy an application with Deployer, the Deployment Tool for PHP.
This is the recipe to deploy your LUYA Website with PHP Deployer.
Version 2.0 of LUYA Deployer uses latest PHP Deployer version which does not support the password() method. In order to use
password()install version ^1.0 of LUYA Deployer! See Version 1.0 Documentation
Add the deployer composer package to your project:
composer require luyadev/luya-deployer --dev
deploy.php file with the content of your host configuration(s) and store it in the root directory of your project:
<?php namespace Deployer; require 'vendor/luyadev/luya-deployer/luya.php'; // define your configuration here host('SSHHOST.COM') ->stage('prod') ->port(22) ->user('SSHUSER') ->set('deploy_path', '~/httpdocs'); set('repository', 'https://USER:PASSWORD@github.com/VENDOR/REPO.git');
To deploy to the above configured server just go into the console and run:
./vendor/bin/dep luya prod
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:
Those folders are located in your defined
deploy_path folder. So the
current/public_html should be the only directory visible by the web.
Several options and can be defined with
set(OPTION, VALUE). Its recommend to set the define the option for a given server:
host('luya.io') ->stage('prod') ->set(COMPOSER_IGNORE_PLATFORM_REQS, true) ->set('deploy_path', '~/httpdocs');
||false||Whether composer install should ignore platform requirements or not.|
||true||Whether composer global fxp plugin should be installed or not.|
||true||Whether the LUYA core commands like migrate, import should be run after deployment.|
In order to configure a branch to deploy use
password() method has been removed, authentication can either be done using SSH Keys or by entering the password while deployment. The
dep luya prod command will prompt for the users password unless he could not connect by SSH Key. By default the
~/.ssh/id_rsa will be taken to make a first attempt. You can configure ssh settings with the following methods:
->configFile('~/.ssh/config') ->identityFile('~/.ssh/id_rsa') ->forwardAgent(true) ->multiplexing(true)
Read the PHP Deployer Docs for more informations. As we can not cover everything about SSH Keys but a here is a very basic example setup. First you have to create an SSH key, then the Server you'd like to connect must have stored the public key
.pub file. So you should never publish the private key but the public key can be stored on the Server:
- Generate an SSH Key
ssh-keygen -t rsa -b 2048 -C "luyadeployer"
- When prompting for
Enter passphrase (empty for no passphrase):skip this step (at least when setting up an continuous deployment f.e.).
- Copy the content of
~/.ssh/id_rsa.pubwhich is the public key.
- Add the public key to
~/.ssh/authorized_keyson the Server or use
ssh-copy-id. Also Plesk f.e. has visual tools to do so Plesk SSH Keys Extension