PHP code example of tombroucke / otomaties-deployer
1. Go to this page and download the library: Download tombroucke/otomaties-deployer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tombroucke / otomaties-deployer example snippets
namespace Deployer;
use function Otomaties\Deployer\runWpQuery;
;
(\Dotenv\Dotenv::createImmutable(__DIR__))
->load();
collect([
'functions.php',
'recipes/auth.php',
'recipes/bedrock.php',
'recipes/combell.php',
'recipes/composer.php',
'recipes/database.php',
'recipes/htaccess.php',
'recipes/opcode.php',
'recipes/otomaties.php',
'recipes/sage.php',
'recipes/wordfence.php',
'recipes/wp.php',
])
->map(fn ($file) => __DIR__ . '/vendor/tombroucke/otomaties-deployer/' . $file)
->filter(fn ($file) => file_exists($file))
->each(fn ($file) => 'https://staging.example.com')
->set('basic_auth_user', env('BASIC_AUTH_USER'))
->set('basic_auth_pass', env('BASIC_AUTH_PASS'))
->set('remote_user', 'examplecom')
->set('branch', 'staging')
->set('deploy_path', '/data/sites/web/examplecom/app/staging');
/** Check if everything is set for sage */
before('deploy:prepare', 'sage:check');
/** Install theme dependencies */
before('deploy:vendors', 'sage:vendors');
/** Upload auth.json */
before('deploy:vendors', 'composer:upload_auth_json');
/** Remove auth.json */
after('deploy:vendors', 'composer:remove_auth_json');
/** Push theme assets */
after('deploy:update_code', 'sage:compile_and_upload_assets');
/** Write revision to file */
after('deploy:update_code', 'otomaties:write_revision_to_file');
/** Reload Combell */
after('deploy:symlink', 'combell:reloadPHP');
/** Clear OPcode cache */
after('deploy:symlink', 'combell:reset_opcode_cache');
/** Install languages */
after('deploy:symlink', 'wp:install_languages');
/** Optimize the site */
after('deploy:symlink', 'otomaties:custom:optimize');
/** Remove unused themes */
after('deploy:cleanup', 'wp:remove_unused_themes');
/** Unlock deploy */
after('deploy:failed', 'deploy:unlock');
/** Optimize the site */
desc('Optimize the site');
task('otomaties:custom:optimize', function () {
runWpQuery([
'wp core update-db',
// 'wp wc update',
'wp acorn optimize',
'wp cfcache purge_cache',
]);
});
/** Update dropin */
after('deploy:symlink', 'wp:runcloud-hub:update-dropin');
task('wp:runcloud-hub:update-dropin', function () {
runWpQuery('wp runcloud-hub update-dropin');
});
/** Purge all caches */
after('deploy:symlink', 'wp:runcloud-hub:purgeall');
task('wp:runcloud-hub:purgeall', function () {
runWpQuery('wp runcloud-hub purgeall');
});
set('cachetool_args', '--web=SymfonyHttpClient --web-path={{deploy_path}}/current/web --web-url={{url}}');
/** Flush object cache */
after('deploy:symlink', 'wp:cache:flush');
task('wp:cache:flush', function () {
runWpQuery('wp cache flush');
});
/** Update WooCommerce tables */
after('deploy:symlink', 'wp:wc:update');
task('wp:wc:update', function () {
runWpQuery('wp wc update');
});
host('production')
->set('github_deploy_key_manual', true);
/** Wordfence */
set('wordfence/config', get('wordfence/config')
->merge([
'alertEmails' => '[email protected] ',
'max_login_failures' => '3',
'max_forgot_password' => '3',
])
);