|
| 1 | + |
| 2 | +deployer-typo3-database |
| 3 | +======================= |
| 4 | + |
| 5 | +[](https://packagist.org/packages/sourcebroker/deployer-typo3-database) |
| 6 | +[](https://packagist.org/packages/sourcebroker/deployer-typo3-database) |
| 7 | + |
| 8 | + |
| 9 | +## What does it do? |
| 10 | + |
| 11 | +This package provides settings to use package [sourcebroker/deployer-extended-database](https://github.com/sourcebroker/deployer-extended-database) with TYPO3 CMS. |
| 12 | +It allows to sync database between instances. |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +1. Install package with composer: |
| 17 | + |
| 18 | + ``` |
| 19 | + composer require sourcebroker/deployer-typo3-database |
| 20 | + ``` |
| 21 | + |
| 22 | +2. Put the following lines at the beginning of your `deploy.php`: |
| 23 | + |
| 24 | + ```php |
| 25 | + require_once(__DIR__ . '/vendor/autoload.php'); |
| 26 | + new \SourceBroker\DeployerLoader\Loader([ |
| 27 | + ['get' => 'sourcebroker/deployer-typo3-database'], |
| 28 | + ]); |
| 29 | + ``` |
| 30 | + |
| 31 | +3. On each instance create a `.env` (or `.env.local`) file which should be out of git and have at least `INSTANCE` with the same name as defined for `host()` in `deploy.php`. You can use this file also to store database credentials and any other settings that are different per instance. Example for `.env` file: |
| 32 | + |
| 33 | + ```bash |
| 34 | + TYPO3_CONTEXT='Production' |
| 35 | + INSTANCE='production' |
| 36 | + |
| 37 | + TYPO3__DB__Connections__Default__dbname='t3base13_production' |
| 38 | + TYPO3__DB__Connections__Default__host='127.0.0.1' |
| 39 | + TYPO3__DB__Connections__Default__password='password' |
| 40 | + TYPO3__DB__Connections__Default__port='3306' |
| 41 | + TYPO3__DB__Connections__Default__user='t3base13_production' |
| 42 | + ``` |
| 43 | + |
| 44 | + If you want Deployer to get database data from TYPO3 directly instead of reading from `.env` file then set: |
| 45 | + |
| 46 | + ```php |
| 47 | + set('driver_typo3cms', true); |
| 48 | + ``` |
| 49 | + |
| 50 | + As an alternative you can also not create any `.env` file but make sure that the env variable `INSTANCE` exists in the system at hosts defined in Deployer (and also at your local host). For example, at local ddev level you can define it in `.ddev/config.yaml`: |
| 51 | + |
| 52 | + ```yaml |
| 53 | + web_environment: |
| 54 | + - INSTANCE=local |
| 55 | + ``` |
| 56 | +
|
| 57 | +
|
| 58 | +## Synchronizing database |
| 59 | +
|
| 60 | +The command for synchronizing database from production database to local instance is: |
| 61 | +
|
| 62 | +```bash |
| 63 | +dep db:pull production |
| 64 | +``` |
| 65 | + |
| 66 | +The command for synchronizing database from production to staging is: |
| 67 | + |
| 68 | +```bash |
| 69 | +dep db:copy production --options=target:staging |
| 70 | +``` |
| 71 | + |
| 72 | + |
| 73 | +## Example of working configuration |
| 74 | + |
| 75 | +This is an example of working configuration for TYPO3 13: |
| 76 | + |
| 77 | +```php |
| 78 | +<?php |
| 79 | + |
| 80 | +namespace Deployer; |
| 81 | + |
| 82 | +require_once(__DIR__ . '/vendor/autoload.php'); |
| 83 | + |
| 84 | +new \SourceBroker\DeployerLoader\Loader([ |
| 85 | + ['get' => 'sourcebroker/deployer-typo3-database'], |
| 86 | +]); |
| 87 | + |
| 88 | +host('production') |
| 89 | + ->setHostname('vm-dev.example.com') |
| 90 | + ->setRemoteUser('deploy') |
| 91 | + ->set('bin/php', '/usr/bin/php8.4'); |
| 92 | + ->set('deploy_path', '~/t3base13/production'); |
| 93 | + |
| 94 | +host('staging') |
| 95 | + ->setHostname('vm-dev.example.com') |
| 96 | + ->setRemoteUser('deploy') |
| 97 | + ->set('bin/php', '/usr/bin/php8.4'); |
| 98 | + ->set('deploy_path', '~/t3base13/staging'); |
| 99 | +``` |
| 100 | + |
| 101 | + |
| 102 | +## Changelog |
| 103 | + |
| 104 | +See [CHANGELOG.rst](https://github.com/sourcebroker/deployer-typo3-database/blob/master/CHANGELOG.rst) |
| 105 | + |
0 commit comments