想在常规的PHP网站使用一些composer组件
一、在对应网站中点击:设置 》升级 composer版本

升级到最新版本 2.1.9
二、提示错误:指定目录中没有找到composer.json配置文件

在网站根据创建composer.json文件(或者可以复制别的项目过来修改):
代码:
- {
 -     "name": "wss/wss",
 -     "description": "the new wss.xxx.com.cn",
 -     "type": "project",
 -     "keywords": [
 -         "wss"
 -     ],
 -     "homepage": "http://wss.xxxx.com.cn/",
 -     "license": "Apache-2.0",
 -     "authors": [
 -         {
 -             "name": "xxxx",
 -             "email": "lxxxt@gmail.com"
 -         }      
 -     ],
 -     "require": {
 -         "php": ">=7.1.0",
 -     },
 -     "autoload": {
 -         "psr-0": {
 -             "": "extend/"
 -         }
 -     }
 - }
 
 
上面的参数按照实际的来修改
三、安装插件:
安装hashids/hashids作为例子,官网:GitHub - vinkla/hashids: A small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user.
composer require hashids/hashids 

php版本:选择自己使用的版本 点击执行

执行完成,在网站根据目录下查看

 
结果安装成功
四、使用插件
首先:在网站入口文件中引用:autoload.php

- require './vendor/autoload.php';
 - use Hashids\Hashids;
 -  
 - $hashids = new Hashids('hgg',5);
 -  
 - $id =$hashids->encode(1454545454545454);
 - var_dump($id);
 
 
输出结果 :
![]()

                

















