Installation
composer require alpixel/deployer-recipes
Ensure your project uses Deployer (v4+ recommended) as the base deployment tool.
First Use Case: Basic Recipe Integration
Add the package to your deploy.php:
require 'vendor/alpixel/deployer-recipes/recipes.php';
Use a pre-built recipe (e.g., Laravel, Symfony) as a starting point:
use Alpixel\DeployerRecipes\Recipes\LaravelRecipe;
$recipe = new LaravelRecipe();
$recipe->deploy();
Where to Look First
vendor/alpixel/deployer-recipes/src/Recipes/ for available recipes.vendor/alpixel/deployer-recipes/README.md for quick-start examples.Recipe-Based Deployment Extend or override default recipes:
$recipe = new LaravelRecipe();
$recipe->set('shared_files', ['app/.env']);
$recipe->set('shared_dirs', ['storage']);
$recipe->deploy();
Custom Recipe Creation
Build a new recipe by extending Alpixel\DeployerRecipes\BaseRecipe:
namespace App\Recipes;
use Alpixel\DeployerRecipes\BaseRecipe;
class CustomRecipe extends BaseRecipe {
public function deploy() {
$this->task('deploy:custom')->run();
}
}
Integration with Deployer Tasks Chain recipes with Deployer’s native tasks:
task('deploy', [
'deploy:prepare',
function() {
$recipe = new LaravelRecipe();
$recipe->deploy();
},
'deploy:cleanup'
]);
Environment-Specific Configs
Use Deployer’s set() to override recipe defaults per environment:
host('prod.example.com')
->set('recipe', new LaravelRecipe())
->set('recipe->deploy_path', '/var/www/prod');
Shared Assets
Leverage shared_files/shared_dirs for persistent files (e.g., .env, node_modules):
$recipe->set('shared_files', ['app/.env.local']);
Post-Deploy Hooks Attach custom tasks after recipe execution:
$recipe->after('deploy', function() {
run('php artisan cache:clear');
});
PHP Version Mismatch The package requires PHP ≥5.5.0, but Deployer v4+ works best with PHP ≥7.2. Test locally with your target PHP version.
Recipe Overrides Not Persisting
Ensure set() is called before deploy():
// ❌ Won't work
$recipe->deploy();
$recipe->set('shared_dirs', ['storage']);
// ✅ Correct
$recipe->set('shared_dirs', ['storage']);
$recipe->deploy();
Missing Dependencies
Some recipes (e.g., Laravel) assume tools like composer, npm, or php artisan are available. Add them to your deploy.php:
set('bin/composer', function() {
return __DIR__ . '/vendor/bin/composer';
});
-v to debug recipe execution:
deploy -v
vendor/alpixel/deployer-recipes/src/Recipes/ for hardcoded paths or tasks that may fail silently.Custom Tasks in Recipes
Override methods like deploy(), rollback(), or warmup() in your extended recipe.
Dynamic Recipe Selection
Use Deployer’s get() to switch recipes per environment:
$recipe = get('recipe') ?: new LaravelRecipe();
$recipe->before('deploy', function() {
if (!test("[ -f composer.json ]")) {
throw new \RuntimeException("composer.json not found!");
}
});
deploy_path). Override them explicitly if needed:
set('deploy_path', '/custom/path');
How can I help you explore Laravel packages today?