2018-03-28 13:33
浏览 124

全局PHP安装包:apt-get vs composer

I found there are two options to install PHP package globally in Linux (Ubuntu 16.04):

  1. Using composer:

    composer global require symfony/finder

    The package will be located at ~/.config/composer/vendor/

    enter image description here

  2. Using apt-get:

    apt-get install php-symfony-finder

    The package will be located at /usr/share/php/

    enter image description here

    This directory /usr/share/php/ is also in default PHPs include_path (I have PHP 7.2)

    enter image description here

There are several questions I have:

Why would I want to install package globally ?

I know it's useful to install php tools globally, like phpunit - It has binary file and it allows you to run tests everywhere, so you don't have to install it in every project. But what about symfony/finder for example ? What is particular use of this package installed globally ?

What is the difference between 1 and 2 option ?

Does it have any different use cases or different effects ?

图片转代码服务由CSDN问答提供 功能建议

我发现有两种方法可以在Linux(Ubuntu 16.04)中全局安装PHP包:

  1. 使用 composer

      composer global require symfony / finder 
      <  / pre> 

    包将位于〜/ .config / composer / vendor /

  2. 使用 apt-get

      apt-get 安装php-symfony-finder 

    该软件包将位于 / usr / share / php / \ n

    此目录 / usr / share / php / 也是默认的PHP include_path (我有PHP 7.2)

    < / a>


    < strong>为什么我要全局安装包?

    我知道全局安装php工具很有用,比如 phpunit - 它有二进制文件 它允许你在任何地方运行测试,因此你不必在每个项目中安装它。 但是,例如 symfony / finder 呢? 全局安装此软件包的具体用途是什么?



  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题