Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit 2cc7f93

Browse files
DepkaCZMilan Felix Šulc
authored andcommitted
Contributte acquisition (#2)
* Renamed namespaces. updated composer.json * Updated readme files * Fixed typo in readme path * Added files according to contributte standard * Composer update, readme update * Fixed declaration of log method * Codefixer + fixed tests * Fixed config.php * Ignore typehint string error * ConfigFactory, Section sniff fixes * Codesniffer errors fixed * Fixed phpstan errors down to 7 * Last phpstan error remains * Ingored constructor error * Banners plus maintainers * StdOutLogger constructor comment * Code style * Composer and readme fixed via PR * Implemented requested changes * Fixed few method return types according to annotations
1 parent 3331b45 commit 2cc7f93

27 files changed

+1460
-1483
lines changed

.docs/README.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# Deployer Extension
2+
3+
## Content
4+
5+
- [Usage - how to register](#usage)
6+
- [Configuration - how to configure](#configuration)
7+
- [Listeners](#listeners)
8+
- [Deploy - how to deploy](#deploy)
9+
- [Plugins](#plugins)
10+
11+
## Usage
12+
```yaml
13+
extensions:
14+
deployer: Contributte\Deployer\DI\DeployerExtension
15+
```
16+
17+
## Configuration
18+
19+
Detailed configuration is described here [ftp-deployment](https://github.com/dg/ftp-deployment).
20+
21+
```yaml
22+
parameters:
23+
deploy:
24+
protocol: ftp # ftp|ftps
25+
user: user1
26+
password: mysecretpwd
27+
scheme: example.com # example.com/www
28+
29+
deployer:
30+
config:
31+
mode: run
32+
logFile: %appDir%/log/deployer.log
33+
tempDir: %appDir%/temp
34+
colors: off
35+
36+
# User specific variables
37+
userdata:
38+
39+
# Plugins specification (see more in PLUGINS.md)
40+
plugins:
41+
42+
# Web sections
43+
sections:
44+
web1:
45+
remote: %deploy.protocol%://%deploy.user%:%deploy.password%@%deploy.scheme%
46+
local: %wwwDir%
47+
testMode: false
48+
49+
allowdelete: on
50+
passiveMode: on
51+
preprocess: off
52+
53+
ignore:
54+
# Common
55+
- .git*
56+
- .idea*
57+
- .bowerrc
58+
- composer.*
59+
- bower.json
60+
- gulpfile.js
61+
- package.json
62+
63+
# Application
64+
- /app/config/config.local.neon
65+
- /bin
66+
- /tests
67+
- /node_modules
68+
- /log/*
69+
- "!/log/.htaccess"
70+
- /temp/*
71+
- "!/temp/.htaccess"
72+
73+
# Public
74+
- /www/*.scss
75+
- /www/*.less
76+
- /www/temp
77+
- /www/uploaded
78+
- /www/stats
79+
80+
before:
81+
#- [@\TestBeforeListener, onBefore]
82+
after:
83+
#- [@\TestAfterListener, onAfter]
84+
85+
purge:
86+
- temp/cache
87+
- temp/myfolder
88+
```
89+
90+
#### More webs <=> more sections
91+
92+
```yaml
93+
deployer:
94+
section:
95+
example.com:
96+
...
97+
test.cz:
98+
...
99+
```
100+
101+
## Listeners
102+
103+
You can register service which implement `AfterListener` or `BeforeListener`.
104+
105+
Example you can [find here](https://github.com/minetro/deployer-extension/tree/master/examples).
106+
107+
Or in plugins section [here](#plugins).
108+
109+
## Deploy
110+
111+
See example [scripts here](https://github.com/minetro/deployer-extension/tree/master/examples).
112+
113+
### Automatic
114+
115+
Config is automatic passed via extension.
116+
117+
```php
118+
# Create Deploy Manager
119+
$dm = $container->getByType('Minetro\Deployer\Manager');
120+
$dm->deploy();
121+
```
122+
123+
### Manual
124+
125+
You have to create your configuration by yourself.
126+
127+
```php
128+
# Create config
129+
$config = new Config();
130+
$config->setLogFile(..);
131+
$config->setMode(..);
132+
133+
$section = new Section();
134+
$section->setName(..);
135+
$config->addSection($section);
136+
```
137+
138+
```php
139+
# Create Deploy Manager
140+
$dm = $container->getByType('Minetro\Deployer\Manager');
141+
$dm->manualDeploy($config);
142+
```
143+
144+
```php
145+
# Inject Deploy Manager
146+
use Contributte\Deployer;
147+
148+
/** @var Deployer\Manager @inject */
149+
public $dm;
150+
151+
public function actionDeploy()
152+
{
153+
$this->dm->manulDeploy($config);
154+
}
155+
```
156+
157+
### Prepared deploy script ([deploy.php](https://github.com/minetro/deployer-extension/tree/master/examples/deploy.php) & [deploy](https://github.com/minetro/deployer-extension/tree/master/examples/deploy))
158+
159+
Place it by yourself (for example root/deploy.php). Be careful about `local` and `tempDir`, there depend on location.
160+
161+
```php
162+
require __DIR__ . '/vendor/autoload.php';
163+
164+
# Configurator
165+
$configurator = new Nette\Configurator;
166+
$configurator->setDebugMode(TRUE);
167+
$configurator->enableDebugger(__DIR__ . '/../log');
168+
$configurator->setTempDirectory(__DIR__ . '/../temp');
169+
$configurator->createRobotLoader()
170+
->addDirectory(__DIR__)
171+
->register();
172+
173+
# Configs
174+
$configurator->addConfig(__DIR__ . '/config/config.neon');
175+
176+
# Create DI Container
177+
$container = $configurator->createContainer();
178+
179+
# Create Deploy Manager
180+
$dm = $container->getByType('Minetro\Deployer\Manager');
181+
$dm->deploy();
182+
```
183+
184+
## Plugins
185+
186+
## `MaintenanceListener`
187+
188+
This is prepared listener that help make maintenance mode easier.
189+
190+
Plugin has two sections **rewrite** and **rename**.
191+
192+
You have to register to `before` and to `after` also (!).
193+
194+
### Rewrite
195+
196+
Before: *backup origin file, rename destination file to source file*
197+
198+
After: *revert rewriting*
199+
200+
```yaml
201+
deployer:
202+
plugins:
203+
204+
maintenance:
205+
rewrite:
206+
- [www/index.php, www/index.maintenance]
207+
```
208+
209+
### Rename
210+
211+
Before: *rename origin file to destination file*
212+
213+
After: *revert renaming*
214+
215+
```yaml
216+
deployer:
217+
plugins:
218+
219+
maintenance:
220+
rename:
221+
- [www/.maintenance.php, www/maintenance.php]
222+
```
223+
224+
You can combine rewriting and renaming together.
225+
226+
## `ComposerInstallListener`
227+
228+
This is prepared listener that runs command:
229+
230+
```sh
231+
composer install --no-dev --prefer-dist --optimize-autoloader -d $DIR
232+
```
233+
234+
### Parameters
235+
236+
- `$DIR` is **section.local**
237+
238+
## `ComposerUpdateListener`
239+
240+
This is prepared listener that runs command:
241+
242+
```sh
243+
composer update --no-dev --prefer-dist --optimize-autoloader -d $DIR
244+
```
245+
246+
### Parameters
247+
248+
- `$DIR` is **section.local**

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = tab
11+
indent_size = tab
12+
tab_width = 4
13+
14+
[*.md]
15+
indent_style = space
16+
indent_size = 4
17+
18+
[{composer.json,package.json,.travis.yml}]
19+
indent_style = space
20+
indent_size = 2

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# IDE
22
/.idea
33

4-
# Folders
4+
# Composer
55
/vendor
6-
7-
# Files
86
/composer.lock
7+
8+
# Tests
9+
/temp/
910
/tests/*.log
1011
/tests/tmp
12+
/tests/coverage.html
13+
/coverage.xml

.travis.yml

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,65 @@
11
language: php
2+
23
php:
3-
- 5.5
4-
- 5.6
5-
- 7.0
6-
- hhvm
4+
- 7.1
5+
- 7.2
76

8-
matrix:
9-
allow_failures:
10-
- php: hhvm-nightly
7+
before_install:
8+
# turn off XDebug
9+
- phpenv config-rm xdebug.ini || return 0
1110

12-
include:
13-
- php: 5.6
14-
env: COMPOSER_FLAG=--prefer-lowest
15-
- php: 5.6
16-
env: COMPOSER_FLAG=--prefer-stable
17-
- php: 7.0
18-
env: COMPOSER_FLAG=--prefer-lowest
19-
- php: 7.0
20-
env: COMPOSER_FLAG=--prefer-stable
11+
install:
12+
# Composer
13+
- travis_retry composer install --no-progress --prefer-dist
2114

22-
sudo: false
15+
script:
16+
# Nette/Tester
17+
- composer run-script tester
18+
19+
jobs:
20+
include:
21+
- env: title="Lowest Dependencies 7.1"
22+
php: 7.1
23+
install:
24+
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
25+
script:
26+
- composer run-script tester
2327

24-
before_script:
25-
# Update Composer
26-
- travis_retry composer self-update
28+
- env: title="Lowest Dependencies 7.2"
29+
php: 7.2
30+
install:
31+
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
32+
script:
33+
- composer run-script tester
2734

28-
# Install Nette Tester
29-
- travis_retry composer update --no-interaction --prefer-source $COMPOSER_FLAG
35+
- stage: Quality Assurance
36+
php: 7.2
37+
script:
38+
- composer run-script qa
3039

31-
# Coveralls
32-
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then cat ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini >> ./tests/php-unix.ini; fi
33-
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then NTESTER_FLAGS="--coverage ./coverage.xml --coverage-src ./src"; else TESTER_FLAGS=""; fi
40+
- stage: Test Coverage
41+
php: 7.2
42+
script:
43+
- composer run-script coverage
44+
after_script:
45+
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar
46+
- php coveralls.phar --verbose --config tests/.coveralls.yml
3447

35-
script:
36-
- vendor/bin/tester tests/cases -s -p php -c tests/php-unix.ini $NTESTER_FLAGS
48+
- stage: Phpstan
49+
php: 7.2
50+
script:
51+
- composer run-script phpstan-install
52+
- composer run-script phpstan
3753

38-
after_script:
39-
# Coveralls
40-
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then composer require satooshi/php-coveralls; fi
41-
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then php vendor/bin/coveralls -c tests/.coveralls.yml -v; fi
54+
allow_failures:
55+
- stage: Test Coverage
4256

4357
after_failure:
44-
# Print *.actual content
45-
- 'for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done'
58+
# Print *.actual content
59+
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
60+
61+
sudo: false
62+
63+
cache:
64+
directories:
65+
- $HOME/.composer/cache

0 commit comments

Comments
 (0)