参考网址:http://www.phpcomposer.com
1、linux 安装Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
下载csv压缩包:
composer config repo.packagist composer https://packagist.phpcomposer.com
composer require league/csv
composer update nothing
composer install
composer安装成功后会在当前目录创建vendor目录,所有安装插件都会放在vendor/league下
2、window 安装 Composer
参考网址:https://getcomposer.org/download/
下载 Composer-Setup.exe 进行安装
a、使用下载插件的方法
vendor安装目录存放于/home/share/
测试案例:
<?php require_once '/home/share/vendor/autoload.php'; use LeagueCsvReader; $reader = Reader::createFromPath('test.csv'); foreach ($reader as $index => $row) { //do something meaningful here with $row !! //$row is an array where each item represent a CSV data cell //$index is the CSV row index } echo $reader; ?>