|
| 1 | +# Capistrano::Symfony |
| 2 | + |
| 3 | +Symfony 2 (standard edition) specific tasks for Capistrano v3 |
| 4 | +(inspired by [capifony][2]) |
| 5 | + |
| 6 | +It leverages the following capistrano tasks to deploy a Symfony app |
| 7 | + |
| 8 | +* https://github.com/capistrano/composer |
| 9 | +* https://github.com/capistrano/file-permissions |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +``` |
| 14 | +# Gemfile |
| 15 | +gem 'capistrano', '~> 3.1' |
| 16 | +gem 'capistrano-symfony', '~> 0.1' |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +Require capistrano-symfony in your cap file |
| 22 | + |
| 23 | +``` |
| 24 | +# Capfile |
| 25 | +require 'capistrano/symfony' |
| 26 | +``` |
| 27 | + |
| 28 | +### Settings |
| 29 | + |
| 30 | +capistrano-symfony exposes the following settings (displayed with defaults): |
| 31 | + |
| 32 | +```ruby |
| 33 | +# Symfony environment |
| 34 | +set :symfony_env_prod, "prod" |
| 35 | + |
| 36 | +# Symfony application path |
| 37 | +set :app_path, "app" |
| 38 | + |
| 39 | +# Symfony web path |
| 40 | +set :web_path, "web" |
| 41 | + |
| 42 | +# Symfony log path |
| 43 | +set :log_path, fetch(:app_path) + "/logs" |
| 44 | + |
| 45 | +# Symfony cache path |
| 46 | +set :cache_path, fetch(:app_path) + "/cache" |
| 47 | + |
| 48 | +# Symfony config file path |
| 49 | +set :app_config_path, fetch(:app_path) + "/config" |
| 50 | + |
| 51 | +# Controllers to clear |
| 52 | +set :controllers_to_clear, ["app_*.php"] |
| 53 | + |
| 54 | +# Files that need to remain the same between deploys |
| 55 | +set :linked_files, [] |
| 56 | + |
| 57 | +# Dirs that need to remain the same between deploys (shared dirs) |
| 58 | +set :linked_dirs, [fetch(:log_path), fetch(:web_path) + "/uploads"] |
| 59 | + |
| 60 | +# Dirs that need to be writable by the HTTP Server (i.e. cache, log dirs) |
| 61 | +set :file_permissions_paths, [fetch(:log_path), fetch(:cache_path)] |
| 62 | + |
| 63 | +# Name used by the Web Server (i.e. www-data for Apache) |
| 64 | +set :webserver_user, "www-data" |
| 65 | + |
| 66 | +# Method used to set permissions (:chmod, :acl, or :chown) |
| 67 | +set :permission_method, false |
| 68 | + |
| 69 | +# Execute set permissions |
| 70 | +set :use_set_permissions, false |
| 71 | + |
| 72 | +set :composer_install_flags, "--no-dev --no-scripts --verbose --prefer-dist --optimize-autoloader --no-progress" |
| 73 | + |
| 74 | +set :symfony_console_path, fetch(:app_path) + "/console" |
| 75 | +set :symfony_console_flags, "--no-debug" |
| 76 | + |
| 77 | +# Assets install |
| 78 | +set :assets_install_path, fetch(:web_path) |
| 79 | +``` |
| 80 | + |
| 81 | +### Flow |
| 82 | + |
| 83 | +capistrano-symfony hooks into the [flow][1] offered by capistrano. It adds |
| 84 | +to that flow like so |
| 85 | + |
| 86 | +``` |
| 87 | +deploy |
| 88 | + deploy:starting |
| 89 | + [before] |
| 90 | + deploy:ensure_stage |
| 91 | + deploy:set_shared_assets |
| 92 | + deploy:check |
| 93 | + deploy:started |
| 94 | + deploy:updating |
| 95 | + git:create_release |
| 96 | + deploy:symlink:shared |
| 97 | + deploy:create_cache_dir |
| 98 | + deploy:set_permissions:(acl|chmod|chgrp) # optional |
| 99 | + deploy:updated |
| 100 | + deploy:build_bootstrap |
| 101 | + symfony:cache:warmup |
| 102 | + [after] |
| 103 | + deploy:clear_controllers |
| 104 | + deploy:assets:install |
| 105 | + deploy:publishing |
| 106 | + deploy:symlink:release |
| 107 | + deploy:restart |
| 108 | + deploy:published |
| 109 | + deploy:finishing |
| 110 | + deploy:cleanup |
| 111 | + deploy:finished |
| 112 | + deploy:log_revision |
| 113 | +``` |
| 114 | + |
| 115 | +### Using the Symfony console |
| 116 | + |
| 117 | +A task wrapping the symfony console is provided, making it easy to create tasks |
| 118 | +that call console methods. |
| 119 | + |
| 120 | +For example if you have installed the [DoctrineMigrationsBundle][3] in your |
| 121 | +project you may want to run migrations during a deploy. |
| 122 | + |
| 123 | +```ruby |
| 124 | +namespace :deploy do |
| 125 | + task :migrate do |
| 126 | + invoke 'symfony:command', 'doctrine:migrations:migrate', '--no-interaction' |
| 127 | + end |
| 128 | +end |
| 129 | +``` |
| 130 | + |
| 131 | +[1]: http://capistranorb.com/documentation/getting-started/flow/ |
| 132 | +[2]: http://capifony.org/ |
| 133 | +[3]: http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html |
| 134 | + |
| 135 | +## Contributing |
| 136 | + |
| 137 | +1. Fork it |
| 138 | +2. Create your feature branch (`git checkout -b my-new-feature`) |
| 139 | +3. Commit your changes (`git commit -am 'Add some feature'`) |
| 140 | +4. Push to the branch (`git push origin my-new-feature`) |
| 141 | +5. Create new Pull Request |
0 commit comments