0

I've just completed an upgrade from Symfony2 2.0 to 2.3.4. This is now working on my local dev server and I'm looking to deploy it with Capifony.

A big change with Symfony is away from /bin/vendor toward Composer for managing dependencies.

I've updated Capistrano so that 'cap -V' gives 'Capistrano v2.15.5'

and Capifony so that 'capifony -v' gives 'capifony v2.4.0'

The problem is that

cap deploy 

never attempts to run anything to do with Composer. It insists on trying to use /bin/vendor:

* 2013-09-29 23:16:58 executing `symfony:vendors:reinstall'
* executing "cd /vhosts/domains/mysite.com/public/releases/20130929221446 && php bin/vendors install --reinstall"

My 'deploy.rb' has:

set :use_composer, true

Here's my full deploy.rb

set :application, "mysite"
set :domain,      "#{application}.com"
set :deploy_to,   "/vhosts/domains/#{domain}/public"
set :app_path,    "app"

#ssh stuff 
ssh_options[:port] = 12345
ssh_options[:username] = "myuser" 
ssh_options[:forward_agent] = true

set :scm, :git
set :branch,      "master"
set :deploy_via,  :rsync_with_remote_cache
#set :deploy_via, :remote_cache

set :user, "admin" # SSH login user
set :port, 12345 # For Capistrano
#set :use_sudo, true # admin is sufficiently privileged

# Set logging to max for debugging
#logger.level = Logger::MAX_LEVEL

# Advised to add this to fix an error message
default_run_options[:pty] = true

set :repository, "/vhosts/domains/mysite.com/public/current" # Local means Vagrant

set :model_manager, "doctrine"
# Or: `propel`

# Server roles
role :web,        domain                         # Web server
#role :app,        domain                         # App server (could be different)
#role :db,         domain, :primary => true       # DB server (primary means primary DB)

set :keep_releases,  12

# Added 29Sep13 as advised by current capifony docs
set :shared_files,      ["app/config/parameters.yml"]

# directories that will be shared between all releases
set :shared_children,     [app_path + "/logs", "customer_uploads", "vendor"]

set :use_composer, true
set :update_vendors, true

# Share /vendor between deployments
#set :copy_vendors, true
# Run post-scripts from composer install
#set :composer_options,  "--no-dev --verbose --prefer-dist --optimize-autoloader"

# Below doesn't work with composer, is deprecated as only worked for bin/vendors
#set :vendors_mode, "reinstall" 

# Assets install (to web directory as files rather than symlinks). Don't uncomment, set to 'false'.
set :assets_install, false

# Regenerate Assetic assets (JS, CSS). Don't uncomment, set to 'false'.
set :dump_assetic_assets, false

# Whether to run cache warmup. Don't uncomment, set to 'false'.
set :cache_warmup, true

# Note this can fail (e.g. to find and download a necessary Git repo) and deployment still proceeds.

# Change ACL on the app/logs and app/cache directories
# Works without this and when enabled gives error if sudo set to false above.
after 'deploy', 'deploy:update_acl'

# Adam added to try and enforce keep_releases automatically
after "deploy", "deploy:cleanup"

# Custom task to set the ACL on the app/logs and app/cache directories
namespace :deploy do

  task :update_acl, :roles => :app do
    shared_dirs = [
      app_path + "/logs",
      app_path + "/cache"
    ]

    # add group write permissions
    #run "chmod -R g+w #{shared_dirs.join(' ')}"
    # Allow directories to be writable by webserver and this user
    run "cd #{latest_release} && setfacl -R -m u:www-data:rwx -m u:#{user}:rwx #{shared_dirs.join(' ')}"
    run "cd #{latest_release} && setfacl -dR -m u:www-data:rwx -m u:#{user}:rwx #{shared_dirs.join(' ')}"
  end

end

Edit1 30Sep13 14:04 UTC in response to comment

The contents of the Capfile that resides in my project root is

load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/bundles/*/*/recipes/*.rb'].each { |bundle| load(bundle) }
load Gem.find_files('symfony2.rb').last.to_s
load 'app/config/deploy'

Also, why do other questions e.g. below show prettier printing when using Capifony. The output on mine doesn't look at all like this: no ticks, much messier

Capifony failed reinstalling vendors with Symfony2.1

It's as if either Capistrano or Capifony isn't up-to-date and therefore doesn't recognise the instruction to use Composer - but why would that be?

Thanks in advance,

4

1 回答 1

3

Capifony has support for Symfony v1 (that uses bin/vendors) and Symfony v2 - composer based.

While it should recognise that you are using a Composer-based system, care of the set :use_composer, true line, I've found it's better to explicitly tell it, care of a line in Capfile, in the project root.

require 'capifony_symfony2'

The https://github.com/ruudk/capifony-tools can also be useful, it's got a vendors_speedup.rb task for Capistrano, which copies the entire vendor directory, before the composer install/update action.

于 2013-09-30T11:19:33.373 回答