“PHP作曲家”与“Ruby Gems and Bundler”相比, [英] "PHP Composer" compared with "Ruby Gems and Bundler"

查看:143
本文介绍了“PHP作曲家”与“Ruby Gems and Bundler”相比,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(首先,这个问题不是哪个更好的问题,我只是想知道它们是如何相似的,而且在功能上有所不同。)



I 'm php 开发者,目前正在学习 ruby​​
在这些日子里,许多php开发人员都鼓励使用 Composer 来进行依赖管理。在提出问题之前,我想首先验证我的知识。根据我的理解,


  • 作曲家
    / code>是一个用于php库(或包)的依赖管理工具。
  • 作曲家 (所谓的本地)。我的意思是为project1安装的php库不能重新用于project2,而无需再为project2安装。



我注意到 Ruby 也有很好的依赖管理工具 RubyGems的
据我所知,


  • RubyGems 是一个包
  • Gem 是一个以标准格式打包的Ruby程序或库,用于共享。 (Rails也是一个宝石。)
  • Gem 可以通过类似命令来安装 gem install sinatra

  • 但是,也有所谓的 Bundler ,这也是捆绑宝石的宝石 当命令 bundle install 运行时(在特定的ruby项目目录下),Gemfile中列出的所有gem都会被安装对于这个ruby项目。


    所以,我的问题在这里。


    1. Composer 类似于是否 RubyGems Bundler
    2. 运行 gem install sinatra 时,是否安装在系统级别上?

    3. 在运行 bundle install 时,Gems是安装在本地(仅在此项目上)还是系统级别?

    4. 如果我需要两个版本的 gem (例如 sinatra ),我应该如何处理?

    (对不起,我的长问题。 1)作曲家更类似于捆绑。
    Composer将项目中的所有内容都包含进来,捆绑器将所有内容都带到系统中,并在项目环境中链接它们。 Bundler正在使用宝石。


    <2>是的。 gem install会在系统范围内(或者如果你使用类似rbenv或rvm的用户)执行某些操作。



    3)参见1. system wide,根据Gemfile当你通过bundle exec来运行时,我建议使用一个Gemfile,把你感兴趣的版本放在那里,然后让bundler去做其余的事情(它会在回到安装多个版本并选择正确的一个)。一定要运行bundle exec。
    如果您使用rvm,您也可以选择使用rvm gemset,但这很难处理,而且在尝试部署时您将遇到非常糟糕的时间。


    (As first, this question is not "which is better" question. I just want to know how they are similar and differ in functionality perspective.)

    I'm php developer and currently learning ruby. In these days, many php developers are encouraged to use Composer for dependency management. Before asking questions, I would like to validate my knowledge first.

    According to my understanding,

    • Composer is a dependency management tool for php libraries (or packages).
    • Composer installed php library per project basis (so-called locally). I mean php library installed for project1 cannot be reused for project2 without install again for project2.

    I've noticed that Ruby also has very good dependency management tool "RubyGems". According to my knowledge,

    • "RubyGems" is a package manager for "Gems".
    • "Gem" is a Ruby program or library packaged in a standard format for sharing. (Rails is also a gem.)
    • Gem can be installed by command like that gem install sinatra.
    • But, there is also so-called "Bundler" which is also a gem for bundling gems for an application.
    • When command bundle install runs (under specific ruby project directory), all the gems listed in the Gemfile are installed for this ruby project.

    So, my questions are here.

    1. Composer is similar to whether RubyGems or Bundler ?
    2. When run gem install sinatra, is it installed on system-wide level ?
    3. When run bundle install, the Gems are installed whether locally (on this project only) or system-wide level ?
    4. If I need two versions of one gem (for e.g. sinatra) for different projects, how should I handle ?

    (Sorry for my long question. If my understandings are something wrong, sorry again and please point out the right one.)

    解决方案

    1) Composer is more similar to bundler. Composer brings everything in your project, bundler brings everything to your system and "links" them in the context of your project. Bundler is working with gems in the back.

    2) yes. gem install does things system-wide (or per user if you use something like rbenv or rvm)

    3) see 1. system wide and are correctly picked according to the Gemfile when you run things through bundle exec

    4) I recommend using a Gemfile, putting the version you're interested in there and letting bundler do the rest (it will in the back install multiple versions and pick the right one). Be sure to run "bundle exec" though. You also have the option of using an rvm gemset if you're into rvm but that's harder to handle and you will have a really bad time when attempting to deploy.

    这篇关于“PHP作曲家”与“Ruby Gems and Bundler”相比,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆