bestit / shopware-mage-tasks
Common tasks to deploy a shopware project using MagePHP
Installs: 14 733
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 7
Forks: 5
Open Issues: 10
Requires
- php: ^8.0
- andres-montanez/magallanes: ^3.0 || ^4.0
- league/flysystem: ^1.0
Requires (Dev)
- best-it/php_codesniffer: ^3.4 || ^4.0.0-RC1
- league/flysystem-memory: ^1.0
- mikey179/vfsstream: ^1.6.6
- phpunit/phpunit: ^9.0
- vlucas/phpdotenv: ^3.3
Suggests
- b3nl/sw-migrations: This library is needed if you want to use the task shopware/migrate
- dev-master
- 1.0.0-RC1
- 0.10.0
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.12
- 0.3.11
- 0.3.10
- 0.3.9
- 0.3.8
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- dev-feature/cleanup-structure
- dev-feature/add-config-values-for-showare-6-deployments
- dev-feature/tar-prepare-subfolder-task
- dev-globbified-setenvparameterstask
- dev-feature/DEVHEAD-53-migration-shop-path
- dev-bugfix/set-env-task-defaults
- dev-bugfix/+42-set-env-task-failing
- dev-develop
This package is auto-updated.
Last update: 2024-11-29 05:39:11 UTC
README
This package includes common tasks to deploy a shopware project using MagePHP.
.mage.yml example
magephp: php_executable: /usr/bin/php # Leave this empty if you want to use the globally installed php executable. custom_tasks: - BestIt\Mage\Tasks\Deploy\DeployTask - BestIt\Mage\Tasks\Deploy\Tar\PrepareSubfolderTask # replaces the original deploy/tar/prepare task - BestIt\Mage\Tasks\Env\CreateEnvFileTask - BestIt\Mage\Tasks\Env\SetEnvParametersTask - BestIt\Mage\Tasks\Env\RecursiveSetEnvParametersTask - BestIt\Mage\Tasks\Misc\CopyTask - BestIt\Mage\Tasks\Misc\DenyRobotsTxtTask - BestIt\Mage\Tasks\Misc\SubComposerInstallTask - BestIt\Mage\Tasks\Opcode\BuildCleaner - BestIt\Mage\Tasks\Opcode\CleanReset - BestIt\Mage\Tasks\Release\PrepareTask - BestIt\Mage\Tasks\Release\SwPrepareTask - BestIt\Mage\Tasks\Shopware\ApplyMigrationsTask - BestIt\Mage\Tasks\Shopware\CommandTask - BestIt\Mage\Tasks\Shopware\UpdateLegacyPluginsTask - BestIt\Mage\Tasks\Shopware\UpdatePluginsTask environments: prod: user: apache host_path: /var/www/html releases: 4 # Add php_executable in environment options to overwrite the global configuration above php_executable: /usr/bin/env/path/to/php # Add console_script_path in environment options to overwrite the default ./bin/console console_script_path: ./bin/console hosts: - production_server1 pre-deploy: - env/create-env-file: file: '.env' whitelist: - foo - bar # Prefix - env/set-env-parameters: { file: 'configs/config_prod.php', prefix: 'ENV_', placeholderWrapper: '__' } # Iterates over all module sub directories, looking for parameter.xml..dist files and creates parameter.xmls from them. - env/recursive-set-env-parameters: { directory: 'custom/plugins/PluginName/Module', fileName: 'parameter.xml.dist', prefix: 'ENV_', encodeForXml: true, deleteTargets: true } - misc/deny-robots-txt: { folder: 'OPTIONAL_LOCAL_FOLDER' } - opcode/build-cleaner: { doc_root: 'RELATIVE_DOC_ROOT for saving the cleaner script.' } on-deploy: - composer/sub-install: flags: '--no-dev' globs: - '/var/www/parent/*/composer.json' - '/custom/*/*/composer.json' # Skips default prepare task which is not needed. - deploy/release/prepare # Creates new release directory and copies all content of current into the created directory. - prepare/sw-structure: { timeout: 500 } # Creates a new symlink. - fs/link: { from: '../../media', to: 'media' } - fs/link: { from: '../../files', to: 'files' } # Pushes file(s) to server(s). # If strict is true, it will actually do a sync (i.e. delete files that do not exist locally anymore). # Otherwise it would just upload&overwrite without touching files that do not exist locally anymore. - deploy: { from: 'configs/config_prod.php', to: './config.php' } - deploy: { from: 'scripts/remote/', to: './scripts/', strict: true, timeout: 500 } - deploy: { from: 'libraries/', to: './engine/Library/', strict: false } - deploy: { from: 'legacy_plugins/Community/', to: 'engine/Shopware/Plugins/Community/', strict: false } - deploy: { from: 'legacy_plugins/Local/', to: 'engine/Shopware/Plugins/Local/', strict: true } - deploy: { from: 'plugins/', to: 'custom/plugins/', strict: true } - deploy: { from: 'licenses/', to: 'licenses/', strict: true } # Execute "raw" command on remote host. - exec: { cmd: './var/cache/clear_cache.sh', desc: 'Clear shopware cache.' } # Updates all (>=5.2 system) plugins on server(s). # Single remote command for executing updates is activated, default false. # Plugin refresh before update command is activated, default true. - shopware/update-plugins: { single_remote_command: true, plugin_refresh: true } # Updates all (legacy) plugins on server(s). "Sources" are the Community/Local folders. - shopware/update-legacy-plugins: { sync_sources_folders: true, single_remote_command: false } # Executes all SQL migrations on server(s). Both parameters are optional. - shopware/migrate: { table_suffix: 'bestit', migration_dir: 'sql' } # Executes remote the shopware commands # If ignoreReturnValue is true all return values of the command will be ignored. # The usage of this option should be considered carefully because with this options no differentiation # between an successful command call and an error command call is possible. # This option is necessary because specific shopware commands like plugin install will indicate an # if the plugin is already installed # Installs an activate an plugin - shopware/command: { cmd: 'sw:plugin:install --activate Cron', ignoreReturnValue: true } # Warms up the shopware theme cache on server(s). - shopware/command: { cmd: 'sw:theme:cache:generate' } post-deploy: - opcode/build-cleaner: doc_root: 'RELATIVE_DOC_ROOT for saving the cleaner script.' urls: - $APPSERVER_URL_1 - $APPSERVER_URL_2 - $APPSERVER_URL_3
Installation
Step 1: Composer
Run:
composer require bestit/shopware-mage-tasks --dev
Step 2: .mage.yml
Create a .mage.yml file in your project root directory and define your desired tasks as per the example above. For more information about what you can do check out the documentation.
Step 3: Initial folder structure on the deploy target
Before the first deployment with mage, you need to set up the folder structure manually, because the original mage deploy/release/prepare-task is skipped and replaced by the prepare/sw-structure-task which performs an ordinary file copy from CURRENT to the newly created REALEASE:
- host_path on SERVER
- current -> release/initial (Symlink)
- release
- initial
- bin
- configs
- custom
- engine
- files -> ../../files (Symlink)
- media -> ../../media (Symlink)
- recovery
- scripts
- themes
- var
- vendor
- web
...
- media
- files
Step 4: That's it!
You just need to run the deployment script:
vendor/bin/mage deploy <environment>
License
This software is open-sourced under the MIT license.