如需安装依赖请在应用目录中运行 composer require xxx/xxx
具体使用方法详见 https://www.runoob.com/w3cnote/composer-install-and-usage.html
举个例子
结巴分词:https://github.com/fukuball/jieba-php
依赖安装(在/class/composer 目录中执行 ):
composer require fukuball/jieba-php
代码调用:
<?php
if(!defined('ClassCms')) {exit();}
use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;
class test {
function fenci(){
ini_set('memory_limit', '1024M');
Jieba::init();
Finalseg::init();
//Jieba::loadUserDict('doc.txt');
$seg_list = Jieba::cut("怜香惜玉也得要看对象啊!");
var_dump($seg_list);
$seg_list = Jieba::cut("我来到北京清华大学", true);
var_dump($seg_list); #全模式
$seg_list = Jieba::cut("我来到北京清华大学", false);
var_dump($seg_list); #默認精確模式
$seg_list = Jieba::cut("他来到了网易杭研大厦");
var_dump($seg_list);
$seg_list = Jieba::cutForSearch("小明硕士毕业于中国科学院计算所,后在日本京都大学深造"); #搜索引擎模式
var_dump($seg_list);
}
}