# Content

# Usage

extensions:
	deployer: Contributte\Deployer\DI\DeployerExtension
1
2

# Configuration

Detailed configuration is described here ftp-deployment (opens new window).

parameters:
	deploy:
		protocol: ftp # ftp|ftps
		user: user1
		password: mysecretpwd
		scheme: example.com # example.com/www

deployer:
	config:
		mode: run
		logFile: %appDir%/log/deployer.log
		tempDir: %appDir%/temp
		colors: off

	# User specific variables
	userdata:

	# Plugins specification (see more in PLUGINS.md)
	plugins:

	# Web sections
	sections:
		web1:
			remote: %deploy.protocol%://%deploy.user%:%deploy.password%@%deploy.scheme%
			local: %wwwDir%
			testMode: false

			allowdelete: on
			passiveMode: on
			preprocess: off

			ignore:
				# Common
				- .git*
				- .idea*
				- .bowerrc
				- composer.*
				- bower.json
				- gulpfile.js
				- package.json

				# Application
				- /app/config/config.local.neon
				- /bin
				- /tests
				- /node_modules
				- /log/*
				- "!/log/.htaccess"
				- /temp/*
				- "!/temp/.htaccess"

				# Public
				- /www/*.scss
				- /www/*.less
				- /www/temp
				- /www/uploaded
				- /www/stats

			before:
				#- [@\TestBeforeListener, onBefore]
			after:
				#- [@\TestAfterListener, onAfter]

			purge:
				- temp/cache
				- temp/myfolder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

# More webs <=> more sections

deployer:
	section:
		example.com:
			...
		test.cz:
			...
1
2
3
4
5
6

# Listeners

You can register service which implement AfterListener or BeforeListener.

Example you can find here (opens new window).

Or in plugins section here.

# Deploy

See example scripts here (opens new window).

# Automatic

Config is automatic passed via extension.


$dm = $container->getByType('Contributte\Deployer\Manager');
$dm->deploy();
1
2
3

# Manual

You have to create your configuration by yourself.


$config = new Config();
$config->setLogFile(..);
$config->setMode(..);

$section = new Section();
$section->setName(..);
$config->addSection($section);
1
2
3
4
5
6
7
8

$dm = $container->getByType('Contributte\Deployer\Manager');
$dm->manualDeploy($config);
1
2
3

use Contributte\Deployer;

/** @var Deployer\Manager @inject */
public $dm;

public function actionDeploy()
{
	$this->dm->manulDeploy($config);
}
1
2
3
4
5
6
7
8
9
10

# Prepared deploy script (deploy.php (opens new window) & deploy (opens new window))

Place it by yourself (for example root/deploy.php). Be careful about local and tempDir, there depend on location.

require __DIR__ . '/vendor/autoload.php';


$configurator = new Nette\Configurator;
$configurator->setDebugMode(TRUE);
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()
	->addDirectory(__DIR__)
	->register();


$configurator->addConfig(__DIR__ . '/config/config.neon');


$container = $configurator->createContainer();


$dm = $container->getByType('Contributte\Deployer\Manager');
$dm->deploy();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# Plugins

# MaintenanceListener

This is prepared listener that help make maintenance mode easier.

Plugin has two sections rewrite and rename.

You have to register to before and to after also (!).

# Rewrite

Before: backup origin file, rename destination file to source file

After: revert rewriting

deployer:
	plugins:
		maintenance:
			rewrite:
				- [www/index.php, www/index.maintenance]
1
2
3
4
5

# Rename

Before: rename origin file to destination file

After: revert renaming

deployer:
	plugins:
		maintenance:
			rename:
				- [www/.maintenance.php, www/maintenance.php]
1
2
3
4
5

You can combine rewriting and renaming together.

# ComposerInstallListener

This is prepared listener that runs command:

composer install --no-dev --prefer-dist --optimize-autoloader -d $DIR
1

# Parameters

  • $DIR is section.local

# ComposerUpdateListener

This is prepared listener that runs command:

composer update --no-dev --prefer-dist --optimize-autoloader -d $DIR
1

# Parameters

  • $DIR is section.local