关键词搜索

源码搜索 ×
×

宝塔 php composer 安装插件(不是TP框架安装)

发布2021-10-23浏览2140次

详情内容

想在常规的PHP网站使用一些composer组件

一、在对应网站中点击:设置 》升级 composer版本

升级到最新版本 2.1.9

二、提示错误:指定目录中没有找到composer.json配置文件

 在网站根据创建composer.json文件(或者可以复制别的项目过来修改):

代码:

  1. {
  2. "name": "wss/wss",
  3. "description": "the new wss.xxx.com.cn",
  4. "type": "project",
  5. "keywords": [
  6. "wss"
  7. ],
  8. "homepage": "http://wss.xxxx.com.cn/",
  9. "license": "Apache-2.0",
  10. "authors": [
  11. {
  12. "name": "xxxx",
  13. "email": "lxxxt@gmail.com"
  14. }
  15. ],
  16. "require": {
  17. "php": ">=7.1.0",
  18. },
  19. "autoload": {
  20. "psr-0": {
  21. "": "extend/"
  22. }
  23. }
  24. }

上面的参数按照实际的来修改

三、安装插件:

安装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

  1. require './vendor/autoload.php';
  2. use Hashids\Hashids;
  3. $hashids = new Hashids('hgg',5);
  4. $id =$hashids->encode(1454545454545454);
  5. var_dump($id);

输出结果 :

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载