Skip to content

Commit f7a02db

Browse files
committed
Merge pull request #50 from capistrano/next
1.0.0.rc1 - Symfony 3 directory structure
2 parents af6068b + a11ff12 commit f7a02db

File tree

9 files changed

+223
-160
lines changed

9 files changed

+223
-160
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Capistrano Symfony 1.x Changelog
2+
3+
4+
## `1.0.0.rc1`
5+
6+
https://github.com/capistrano/symfony/compare/0.4.0...1.0.0.rc1
7+
8+
* Use file permissions gem v1
9+
* Symfony 3 directory structure is on by default
10+
* Remove `use_set_permission` variable
11+
* Remove `web/uploads` as a default linked directory
12+
* Remove support for Assetic (see: https://github.com/symfony/symfony-standard/pull/860)
13+
* Support SensioLabsDistributionBundle 5 (#49)
14+
* Support Symfony 3 directory structure (#31)
15+
* `build_bootstrap_path` is now a DSL method
16+
* `symfony_console` is now a DSL method (use instead of `invoke "symfony:console"`)
17+
* Paths DSL file has been moved to `lib/capistrano/dsl/symfony.rb`
18+
* Deprecated `symfony:command` task has been removed
19+
* `webserver_user` variable has been removed (#40)
20+
* Various typo fixes
21+
22+
### Contributors
23+
24+
Thanks to everyone who has filed an issue or submitted a fix
25+
26+
* @kriswallsmith
27+
* @zaerl
28+
* @sandermarechal
29+
* @pborreli
30+
* @wideawake
31+
* @issei-m
32+
* @alafon

README.md

Lines changed: 81 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Capistrano::Symfony
22

3-
Symfony 2 (standard edition) specific tasks for Capistrano v3
4-
(inspired by [capifony][2])
3+
Symfony 2 (standard edition) specific tasks for Capistrano v3 (inspired by [capifony][2]).
54

65
It leverages the following capistrano tasks to deploy a Symfony app
76

@@ -12,8 +11,8 @@ It leverages the following capistrano tasks to deploy a Symfony app
1211

1312
```
1413
# Gemfile
15-
gem 'capistrano', '~> 3.1'
16-
gem 'capistrano-symfony', '~> 0.1', :github => 'capistrano/symfony'
14+
gem 'capistrano', '~> 3.4'
15+
gem 'capistrano-symfony', '~> 1.0.0.rc1'
1716
```
1817

1918
## Usage
@@ -25,79 +24,74 @@ Require capistrano-symfony in your cap file
2524
require 'capistrano/symfony'
2625
```
2726

27+
2828
### Settings
2929

30-
capistrano-symfony exposes the following settings (displayed with defaults):
30+
If you are using an un-modified symfony-standard edition, version 3 then you do not need to change/add anything to your `deploy.rb` other than what is required from Capistrano.
31+
32+
We do however expose the following settings (shown with default evaluated values) that can be modified to suit your project. Please refer to `lib/capistrano/symfony/defaults.rb` to see exactly how the defaults are set up.
33+
3134

3235
```ruby
33-
# Symfony environment
36+
# Symfony console commands will use this environment for execution
3437
set :symfony_env, "prod"
3538

36-
# Symfony application path
37-
set :app_path, "app"
38-
39-
# Symfony web path
40-
set :web_path, "web"
39+
# Set this to 2 for the old directory structure
40+
set :symfony_directory_structure, 3
41+
# Set this to 4 if using the older SensioDistributionBundle
42+
set :sensio_distribution_version, 5
4143

42-
# Symfony log path
43-
set :log_path, fetch(:app_path) + "/logs"
44+
# symfony-standard edition directories
45+
set :app_path, "app"
46+
set :web_path, "web"
47+
set :var_path, "var"
48+
set :bin_path, "bin"
4449

45-
# Symfony cache path
46-
set :cache_path, fetch(:app_path) + "/cache"
50+
# The next 3 settings are lazily evaluated from the above values, so take care
51+
# when modifying them
52+
set :app_config_path, "app/config"
53+
set :log_path, "var/logs"
54+
set :cache_path, "var/cache"
4755

48-
# Symfony config file path
49-
set :app_config_path, fetch(:app_path) + "/config"
56+
set :symfony_console_path, "bin/console"
57+
set :symfony_console_flags, "--no-debug"
5058

51-
# Controllers to clear
59+
# Remove app_dev.php during deployment, other files in web/ can be specified here
5260
set :controllers_to_clear, ["app_*.php"]
5361

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 :file_permissions_users, ['www-data']
65-
66-
# Name used by the Web Server (i.e. www-data for Apache)
67-
set :webserver_user, "www-data"
68-
69-
# Method used to set permissions (:chmod, :acl, or :chgrp)
70-
set :permission_method, false
71-
72-
# Execute set permissions
73-
set :use_set_permissions, false
74-
75-
# Symfony console path
76-
set :symfony_console_path, fetch(:app_path) + "/console"
62+
# asset management
63+
set :assets_install_path, "web"
64+
set :assets_install_flags, '--symlink'
7765

78-
# Symfony console flags
79-
set :symfony_console_flags, "--no-debug"
66+
# Share files/directories between releases
67+
set :linked_files, []
68+
set :linked_dirs, ["var/logs"]
8069

81-
# Assets install path
82-
set :assets_install_path, fetch(:web_path)
70+
# Set correct permissions between releases, this is turned off by default
71+
set :file_permissions_paths, ["var"]
72+
set :permission_method, false
73+
```
8374

84-
# Assets install flags
85-
set :assets_install_flags, '--symlink'
75+
#### Using this plugin with the old Symfony 2 directory structure and SensioDistributionBundle <= 4
8676

87-
# Assetic dump flags
88-
set :assetic_dump_flags, ''
77+
Add the following to `deploy.rb` to use the old directory structure
8978

90-
fetch(:default_env).merge!(symfony_env: fetch(:symfony_env))
79+
```
80+
# deploy.rb
81+
set :symfony_directory_structure, 2
82+
set :sensio_distribution_version, 4
9183
```
9284

85+
If you are upgrading this gem and have modified `linked_dirs` or "advanced" variables such as `log_path` then you will need to update those accordingly
86+
9387
### Flow
9488

9589
capistrano-symfony hooks into the [flow][1] offered by capistrano. It adds to that flow like so
9690

97-
* ```symfony:create_cache_dir```
98-
* ```symfony:set_permissions```
99-
* ```symfony:cache:warmup```
100-
* ```symfony:clear_controllers```
91+
* `symfony:create_cache_dir`
92+
* `symfony:set_permissions`
93+
* `symfony:cache:warmup`
94+
* `symfony:clear_controllers`
10195

10296
```
10397
deploy
@@ -125,16 +119,38 @@ deploy
125119
|__ deploy:log_revision
126120
```
127121

122+
### File permissions
123+
124+
Set the `permission_method` variable to one of `:chmod`, `:acl`, or `:chgrp` in your `deploy.rb` to handle the common scenario of a web user and the deploy user being different.
125+
126+
Both will need access to the files/directories such as `var/cache` and `web/uploads` (if you handle uploads). Set `file_permissions_users` to your webserver user
127+
128+
Example:
129+
130+
```
131+
# deploy.rb
132+
133+
set :permission_method, :acl
134+
set :file_permissions_users, ["nginx"]
135+
set :file_permissions_paths, ["var", "web/uploads"]
136+
```
137+
138+
Please note that `:acl` requires that `setfacl` be available on your deployment target
139+
140+
See [the symfony documentation](http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup) and [the file permission capistrano plugin](https://github.com/capistrano/file-permissions) for reference
141+
128142
### Integrated common tasks
129143

130-
The folowing common tasks are already integrated:
131-
* ```symfony:assets:install```
132-
* ```symfony:assetic:dump```
144+
The following common tasks are available:
145+
146+
* `symfony:assets:install`
147+
* `symfony:build_bootstrap` - useful if you disable composer
148+
149+
So you can use them with hooks in your project's `deploy.rb` like this:
133150

134-
So you can use them with hooks like this:
135151
```ruby
136-
after 'deploy:updated', 'symfony:assets:install'
137-
after 'deploy:updated', 'symfony:assetic:dump'
152+
after 'deploy:updated', 'symfony:assets:install'
153+
before 'deploy:updated', 'symfony:build_bootstrap'
138154
```
139155

140156
### Using the Symfony console
@@ -148,17 +164,19 @@ project you may want to run migrations during a deploy.
148164
```ruby
149165
namespace :deploy do
150166
task :migrate do
151-
invoke 'symfony:console', 'doctrine:migrations:migrate', '--no-interaction'
167+
symfony_console('doctrine:migrations:migrate', '--no-interaction')
152168
end
153169
end
154170
```
155171

156-
You can also apply role filter on your commands by passing a fourth parameter.
172+
If you want to execute a command on a host with a given role you can use the Capistrano `on` DSL, additionally using `within` from Capistrano will change the directory
157173

158174
```ruby
159175
namespace :deploy do
160176
task :migrate do
161-
invoke 'symfony:console', 'doctrine:migrations:migrate', '--no-interaction', 'db'
177+
on roles(:db) do
178+
symfony_console('doctrine:migrations:migrate', '--no-interaction')
179+
end
162180
end
163181
end
164182
```

capistrano-symfony.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
44

55
Gem::Specification.new do |gem|
66
gem.name = "capistrano-symfony"
7-
gem.version = '0.4.0'
7+
gem.version = '1.0.0.rc1'
88
gem.authors = ["Peter Mitchell"]
99
gem.email = ["pete@peterjmit.com"]
1010
gem.description = %q{Symfony specific Capistrano tasks}
11-
gem.summary = %q{Capistrano Symfony - Easy deployment of Symfony 2 apps with Ruby over SSH}
11+
gem.summary = %q{Capistrano Symfony - Easy deployment of Symfony 2 & 3 apps with Ruby over SSH}
1212
gem.homepage = "http://github.com/capistrano/capistrano-symfony"
1313

1414
gem.files = `git ls-files`.split($/)
@@ -31,5 +31,5 @@ eos
3131

3232
gem.add_dependency 'capistrano', '~> 3.1'
3333
gem.add_dependency 'capistrano-composer', '~> 0.0.3'
34-
gem.add_dependency 'capistrano-file-permissions', '~> 0.1.0'
34+
gem.add_dependency 'capistrano-file-permissions', '~> 1.0'
3535
end

lib/capistrano/dsl/symfony.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module Capistrano
2+
module DSL
3+
module Symfony
4+
5+
def symfony_app_path
6+
release_path.join(fetch(:app_path))
7+
end
8+
9+
def symfony_web_path
10+
release_path.join(fetch(:web_path))
11+
end
12+
13+
def symfony_bin_path
14+
release_path.join(fetch(:bin_path))
15+
end
16+
17+
def symfony_var_path
18+
release_path.join(fetch(:var_path))
19+
end
20+
21+
def symfony_log_path
22+
release_path.join(fetch(:log_path))
23+
end
24+
25+
def symfony_cache_path
26+
release_path.join(fetch(:cache_path))
27+
end
28+
29+
def symfony_config_path
30+
release_path.join(fetch(:app_config_path))
31+
end
32+
33+
def symfony_console_path
34+
release_path.join(fetch(:symfony_console_path))
35+
end
36+
37+
def symfony_vendor_path
38+
release_path.join('vendor')
39+
end
40+
41+
def build_bootstrap_path
42+
bootstrap_path = symfony_vendor_path.join("sensio/distribution-bundle")
43+
44+
if fetch(:sensio_distribution_version).to_i <= 4
45+
bootstrap_path = bootstrap_path.join("Sensio/Bundle/DistributionBundle")
46+
end
47+
48+
bootstrap_path.join("Resources/bin/build_bootstrap.php")
49+
end
50+
51+
def symfony_console(command, params = '')
52+
execute :php, symfony_console_path, command, params, fetch(:symfony_console_flags)
53+
end
54+
55+
end
56+
end
57+
end

lib/capistrano/symfony.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
require "capistrano/dsl/symfony"
2+
self.extend Capistrano::DSL::Symfony
3+
4+
SSHKit::Backend::Netssh.send(:include, Capistrano::DSL::Symfony)
5+
16
require "capistrano/file-permissions"
27
require "capistrano/composer"
3-
require "capistrano/symfony/dsl"
48
require "capistrano/symfony/symfony"
59

610
# Core tasks for deploying symfony

0 commit comments

Comments
 (0)