博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Install Composer on Ubuntu 14.04
阅读量:4042 次
发布时间:2019-05-24

本文共 1951 字,大约阅读时间需要 6 分钟。

Step 1 — Installing the Dependencie

First, update the package manager cache by running:

$sudo apt-get update

Now, let’s install the dependencies. We’ll need curl in order to download Composer and php5-cli for installing and running it. git is used by Composer for downloading project dependencies. Everything can be installed with the following command:

$sudo apt-get install curl php5-cli git

Step 2 — Downloading and Installing Composer

Composer installation is really simple and can be done with a single command:

$curl -sS | sudo php – –install-dir=/usr/local/bin –filename=composer

To test your installation, run:

$composer

Step 3 — Generating the composer.json File

Requiring a Package

$composer require cocur/slugify

OutputUsing version ^1.3 for cocur/slugify./composer.json has been createdLoading composer repositories with package informationUpdating dependencies (including require-dev)  - Installing cocur/slugify (v1.3)    Downloading: 100%         Writing lock fileGenerating autoload files

As you can see from the output, Composer automatically decided which version of the package should be used. If you check your project’s directory now, it will contain two new files: composer.json and composer.lock, and a vendor directory:

When installing a project that already contains a composer.json file, you need to run composer install in order to download the project’s dependencies.

Step 4 — Including the Autoload Script

Composer also provides an autoload script that you can include in your project to get autoloading for free. This makes it much easier to work with your dependencies and define your own namespaces.

The only thing you need to do is include the vendor/autoload.php file in your PHP scripts, before any class instantiation.

slugify('Hello World, this is a long sentence and I need to make a slug from it!');

Step 5 — Updating the Project Dependencies

composerupdate composer update vendor/package vendor2/package2


参考:

转载地址:http://cnadi.baihongyu.com/

你可能感兴趣的文章
转载一个webview开车指南以及实际项目中的使用
查看>>
android中对于非属性动画的整理
查看>>
一个简单的TabLayout的使用
查看>>
ReactNative使用Redux例子
查看>>
Promise的基本使用
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
查看>>
Returning a value from a function
查看>>
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
查看>>
coursesa课程 Python 3 programming The while Statement
查看>>
course_2_assessment_6
查看>>
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
查看>>
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
查看>>
在unity中建立最小的shader(Minimal Shader)
查看>>
1.3 Debugging of Shaders (调试着色器)
查看>>
关于phpcms中模块_tag.class.php中的pc_tag()方法的含义
查看>>
vsftp 配置具有匿名登录也有系统用户登录,系统用户有管理权限,匿名只有下载权限。
查看>>
linux安装usb wifi接收器
查看>>
补充自动屏蔽攻击ip
查看>>
多线程使用随机函数需要注意的一点
查看>>