承接 ajaxray/short-code 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ajaxray/short-code

Composer 安装命令:

composer require ajaxray/short-code

包简介

ShortCode generator for PHP. Create short, reversible or random, hash like codes.

README 文档

README

SensioLabsInsight Build Status Coverage Status Latest Stable Version Total Downloads License

ShortCode generator for PHP. Create short, hash like codes. Codes can be random or reversible. Output format is customizable (see the list below).
You can generate random string code of your desired character length, e.g. 4, 6, 8 ... up to 20.
Also, you can generate reversible codes from numbers. It's useful when you'll need to trace the original number from a reference code string.

Can be used for generating small reference codes, tiny URLs or any other purpose.

Installation

Install the latest version with

$ composer require ajaxray/short-code

Supported Output and Conversion Formats

  • ShortCode\Code::FORMAT_ALNUM : (Default) Alphanumaric characters. includes 0-9, a-z and A-Z
  • ShortCode\Code::FORMAT_ALNUM_CAPITAL : Alphanumaric characters. includes 0-9 and A-Z
  • ShortCode\Code::FORMAT_ALNUM_SMALL : Alphanumaric characters. includes 0-9 and a-z
  • ShortCode\Code::FORMAT_CHAR_CAPITAL : Capital letter characters. includes only A-Z
  • ShortCode\Code::FORMAT_CHAR_SMALL : Small letter characters. includes only a-z
  • ShortCode\Code::FORMAT_NUMBER : Numbers. includes only 0-9. Can be used for random number generation

Generating Random Code

<?php
ShortCode\Random::get(); 
// Something like (8 chars by default) : aWg2m5Q3

ShortCode\Random::get(6); 
// 6 character length. e.g. r43Nx2

ShortCode\Random::get(8, ShortCode\Code::FORMAT_ALNUM_SMALL); 
// 8 characters with alnum (small letter only). e.g. f43nbg3e2

Generating Reversible Code from numbers

<?php
ShortCode\Reversible::convert(46345223); 
// Output: 38svB

ShortCode\Reversible::revert('38svB');
// Output: 46345223

// If you specify a format for converting, remember to use the same format for reverting
ShortCode\Reversible::convert(46345223, ShortCode\Code::FORMAT_ALNUM_CAPITAL);
// Output: RLC7B

ShortCode\Reversible::revert('RLC7B', ShortCode\Code::FORMAT_ALNUM_CAPITAL);
// Output: 46345223

Reversible code with having a minimum length

You can create code with a minimum output length. You have to mention the length for both, converting and reverting functions.

<?php
// Creating alphanumeric code with minimum 6 character and reverting
ShortCode\Reversible::convert(9876, \ShortCode\Code::FORMAT_ALNUM, 6); 
// Output: 1002zi
ShortCode\Reversible::revert('1002zi', \ShortCode\Code::FORMAT_ALNUM, 6);
// Output: 9876

// Creating small letter only code with minimum 6 character and reverting
ShortCode\Reversible::convert(9876, \ShortCode\Code::FORMAT_CHAR_SMALL, 6);
// Output: baardm
ShortCode\Reversible::revert('baardm', \ShortCode\Code::FORMAT_CHAR_SMALL, 6);
// Output: 9876

Please note that, using this method, you can only ensure the minimum character length. This length may exceed for larger numbers.

Dependency

This library has dependency on BCMath PHP extension. Please check the installation page in case you don't have it configured.

Also it can be installed on linux based os with something similar to -

// FOr php 5.x
sudo apt-get install php-bcmath
// For php 7
sudo apt-get install php7.0-bcmath

"This is the Book about which there is no doubt, a guidance for those conscious of Allah" - Al-Quran

ajaxray/short-code 适用场景与选型建议

ajaxray/short-code 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 83.17k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2015 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「code」 「convert」 「hash」 「random」 「psr-3」 「revert」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ajaxray/short-code 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ajaxray/short-code 我们能提供哪些服务?
定制开发 / 二次开发

基于 ajaxray/short-code 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 29
  • Watchers: 3
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-23