Install Composer on Ubuntu 14.04
来源:互联网 发布:杨氏模量测定实验数据 编辑:程序博客网 时间:2024/06/01 07:25
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 https://getcomposer.org/installer | 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.
<?phprequire __DIR__ . '/vendor/autoload.php';use Cocur\Slugify\Slugify;$slugify = new Slugify();echo $slugify->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
参考:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04
- Install Composer on Ubuntu 14.04
- install composer on ubuntu
- Install Composer on CentOS
- (Ubuntu) Install PHP Composer
- install qt on ubuntu 14.04
- Install jdk8 on Ubuntu 14.04
- install ndnSIM on Ubuntu 14.04
- Apache2 Install on Ubuntu 14.04
- install docker on Ubuntu 14.04
- PHP Composer: installation on ubuntu
- Install CUDA 6.5 on Ubuntu 14.04 LTS
- Install CUDA 6.0 on Ubuntu 14.04 LTS
- How to install clang on Ubuntu 14.04
- install openvswitch 2.3.2 on ubuntu 14.04
- Install Nginx on Ubuntu 14.04 LTS
- Install Arduino IDE on Ubuntu 14.04
- install opencv 3.1 on ubuntu 14.04+Eclipse
- GPShell install on Ubuntu trusty 14.04
- 正则表达式验证密码:数字+英文的组合
- Spring Boot 系列(九)数据层-集成Spring-data-jpa
- 守破离——编程的三种境界
- spring配置多个mysql数据库
- MySql高性能笔记
- Install Composer on Ubuntu 14.04
- 树莓派系统的备份
- UI布局之LinearLayout线性布局
- Android日志系统驱动程序Logger源代码分析
- 格列佛游记思维导图
- docker容器中springboot 差八小时解决办法
- 单例模式应用场景
- Docker 自修笔记(五)—— 示例学习
- 最大间距