Install Composer on Ubuntu 14.04
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
Output
Using version ^1.3 for cocur/slugify
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing cocur/slugify (v1.3)
Downloading: 100%
Writing lock file
Generating 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.
<?php
require __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 updatecomposer update vendor/package vendor2/package2
參考:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04
相關文章
- How To Install Vagrant IN Ubuntu14.04Ubuntu
- ubuntu 14.04 install docker latest dockerUbuntuDocker
- install redis and used in golang on ubuntu 14.04RedisGolangUbuntu
- ubuntu14.04 and ros indigo install kinect driver--16UbuntuROSGo
- Ubuntu14.04搭建LAMPUbuntuLAMP
- Ubuntu14.04搭建LNMPUbuntuLNMP
- Flask 安裝 Ubuntu 14.04FlaskUbuntu
- 在 Ubuntu 14.04 上安裝 Ubuntu Tweak 0.8.8Ubuntu
- ubuntu install fontsUbuntu
- Ubuntu 14.04 下安裝 OpenCVUbuntuOpenCV
- Docker proxy setting ubuntu 14.04DockerUbuntu
- Ubuntu14.04安裝JDKUbuntuJDK
- Ubuntu 14.04 LTS 安裝DockerUbuntuDocker
- Ubuntu 14.04 安裝 JDK 7.0UbuntuJDK
- 在 Ubuntu 安裝 ComposerUbuntu
- Install Chisel Tools on UbuntuUbuntu
- ubuntu for DP tools installUbuntu
- ubuntu14.04下navicat破解方法Ubuntu
- Ubuntu14.04下安裝genymotionUbuntu
- Ubuntu 14.04下NFS安裝配置UbuntuNFS
- Ubuntu 14.04環境變數修改Ubuntu變數
- ubuntu14.04 升級gcc的方法UbuntuGC
- Ubuntu14.04下Dipy包安裝Ubuntu
- Ubuntu14.04安裝postgresql9.4UbuntuSQL
- ubuntu 14.04 安裝cuda 7.5/CUDA 8.0Ubuntu
- 五個 Ubuntu 14.04 最佳圖示集Ubuntu
- ubuntu14.04 建立ftp伺服器UbuntuFTP伺服器
- ubuntu14.04配置開發環境Ubuntu開發環境
- Ubuntu14.04 LTS下安裝jdkUbuntuJDK
- Ubuntu14.04安裝Pycharm4.5.3UbuntuPyCharm
- 在Ubuntu14.04上快速部署OpenStackUbuntu
- Ubuntu 18.04 install albertUbuntu
- Node JS Install - Ubuntu systemJSUbuntu
- Install qemu-arm for UbuntuUbuntu
- 【Composer 包分享】 hirak/prestissimo 為 Composer install/update 開啟多程式下載REST
- Ubuntu 每日技巧- 自動備份Ubuntu 14.04到Box雲存Ubuntu
- composer install的時候需要賬號密碼密碼
- Ubuntu14.04 安裝搜狗輸入法Ubuntu