定制 emileperron/universal-identifier 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

emileperron/universal-identifier

Composer 安装命令:

composer require emileperron/universal-identifier

包简介

Provides an universal_identifier function, which generates a unique sha256 identifier for a provided object or array.

README 文档

README

Generate unique identifiers for your PHP primitives, arrays and objects

This tiny composer package provides a universal_identifier() global function, which can be used to generate sha256 identifiers for values and arrays/objects.

These identifiers can be used to easily compare configurations both in code and in database queries, without having to manually sort and compare every items and sub-items inside an array or an object.

Getting started

To get started, simply require the package via Composer:

composer require emileperron/universal-identifier

Once that's done, you can start using the universal_identifier function in your project. Here's a very brief overview of the library's usage and functionalities:

Usage with primitives:

<?php
// This will output the string's identifier: "de719c460cc38eddfb39fe286882a042be247e5d091fd8e4aed01daf9d3a5513"
echo universal_identifier("my string");

// Same thing goes for all primitives;
echo universal_identifier(150); // "7d3c18bc20c238917421291209ad0d17c83be19e4c214abcf09160af2949f591"
echo universal_identifier(0.55f); // "1c3d577cd8a09945100ac46c061835db1691907bc40f01931d5083ec7fb69def"
// etc...

Usage with arrays:

<?php
$yourArray = [
	"foo" => "bar",
	"foos" => [
		"bar1", 
		"bar2"
	],
	"anotherKey" => "value",
];

// This will output the array's identifier: "7ef0675c80dd9ae9f9fed4a786f8c0641d14a646cc580de1690f62a803e54f89"
echo universal_identifier($yourArray);

// Even if you change the order of the array's keys, the identifier will remain the same (this does not apply to numerically-indexed arrays, where the order actually matters).
// Ex.:
ksort($yourArray);
// This will still output the same identifier: "7ef0675c80dd9ae9f9fed4a786f8c0641d14a646cc580de1690f62a803e54f89"
echo universal_identifier($yourArray);

Contributing

Feel free to submit pull requests on the GitHub repository if you want to add functionalities or suggest improvements to this library. I will look them over and merge them as soon as possible.

You can also submit issues if you run into problems but don't have time to implement a fix.

Supporting

Finally, if you use the library and would like to support me, here are the ways you can do that:

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固