Symfony 2.3:无法说服Capifony安装使用Composer的供应商

时间:2013-09-29 22:21:51

标签: symfony symfony-2.3 capifony

我刚刚完成从Symfony2 2.0到2.3.4的升级。现在正在我的本地开发服务器上工作,我希望用Capifony部署它。

Symfony的一个重大变化是从/ bin / vendor转向Composer来管理依赖关系。

我已经更新了Capistrano,以便' cap -V'给出了Capistrano v2.15.5'

和Capifony以及' capifony -v'给出了capifony v2.4.0'

问题在于

cap deploy 

永远不会尝试与Composer做任何事情。它坚持尝试使用/ 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"

我的部署.rb'有:

set :use_composer, true

这是我的完整部署.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回应评论

驻留在项目根目录中的Capfile的内容是

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'

另外,为什么还有其他问题,例如使用Capifony时,下面显示更漂亮的打印效果。我的输出并没有像这样看:没有嘀嗒声,更加混乱

Capifony failed reinstalling vendors with Symfony2.1

好像Capistrano或Capifony都不是最新的,因此不会认识到使用Composer的指令 - 但为什么会这样呢?

提前致谢,

1 个答案:

答案 0 :(得分:3)

Capifony支持Symfony v1(使用bin /供应商)和Symfony v2 - composer。

虽然它应该认识到你正在使用基于Composer的系统,关注set :use_composer, true行,但我发现最好在项目根目录中明确地告诉它,关注Capfile中的一行。

require 'capifony_symfony2'

https://github.com/ruudk/capifony-tools也很有用,Capistrano有一个vendors_speedup.rb任务,它在编辑器安装/更新操作之前复制整个供应商目录。