{"id":18029793,"url":"https://github.com/ajaxray/short-code","last_synced_at":"2025-03-27T03:31:13.137Z","repository":{"id":39498580,"uuid":"44774874","full_name":"ajaxray/short-code","owner":"ajaxray","description":"ShortCode generator for PHP. Create short, reversible or random, hash like codes. ","archived":false,"fork":false,"pushed_at":"2021-11-13T13:27:36.000Z","size":39,"stargazers_count":29,"open_issues_count":3,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-15T07:19:36.997Z","etag":null,"topics":["hash","php","php-library","shortcode"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajaxray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-22T21:40:48.000Z","updated_at":"2023-10-18T15:29:25.000Z","dependencies_parsed_at":"2022-08-21T07:50:35.949Z","dependency_job_id":null,"html_url":"https://github.com/ajaxray/short-code","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaxray%2Fshort-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaxray%2Fshort-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaxray%2Fshort-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaxray%2Fshort-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajaxray","download_url":"https://codeload.github.com/ajaxray/short-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245778561,"owners_count":20670682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hash","php","php-library","shortcode"],"created_at":"2024-10-30T09:11:30.700Z","updated_at":"2025-03-27T03:31:12.669Z","avatar_url":"https://github.com/ajaxray.png","language":"PHP","readme":"# ShortCode\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/8254062e-538a-4667-aa56-920e293bef5a/small.png)](https://insight.sensiolabs.com/projects/8254062e-538a-4667-aa56-920e293bef5a)\n[![Build Status](https://travis-ci.org/ajaxray/short-code.svg?branch=master)](https://travis-ci.org/ajaxray/short-code)\n[![Coverage Status](https://coveralls.io/repos/ajaxray/short-code/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/ajaxray/short-code?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/ajaxray/short-code/v/stable)](https://packagist.org/packages/ajaxray/short-code) \n[![Total Downloads](https://poser.pugx.org/ajaxray/short-code/downloads)](https://packagist.org/packages/ajaxray/short-code)\n[![License](https://poser.pugx.org/ajaxray/short-code/license)](https://packagist.org/packages/ajaxray/short-code)\n\nShortCode generator for PHP. Create short, hash like codes. Codes can be random or reversible. Output format is customizable (see the list below).      \nYou can generate random string code of your desired character length, e.g. 4, 6, 8 ... up to 20.   \nAlso, you can generate reversible codes from numbers. It's useful when you'll need to trace the original number from a reference code string.    \n\nCan be used for generating small reference codes, tiny URLs or any other purpose.  \n\n## Installation\n\nInstall the latest version with\n\n```\n$ composer require ajaxray/short-code\n```\n\n## Supported Output and Conversion Formats\n\n- `ShortCode\\Code::FORMAT_ALNUM` : (Default) Alphanumaric characters. includes 0-9, a-z and A-Z\n- `ShortCode\\Code::FORMAT_ALNUM_CAPITAL` : Alphanumaric characters. includes 0-9 and A-Z\n- `ShortCode\\Code::FORMAT_ALNUM_SMALL` : Alphanumaric characters. includes 0-9 and a-z\n- `ShortCode\\Code::FORMAT_CHAR_CAPITAL` : Capital letter characters. includes only A-Z\n- `ShortCode\\Code::FORMAT_CHAR_SMALL` : Small letter characters. includes only a-z\n- `ShortCode\\Code::FORMAT_NUMBER` : Numbers. includes only 0-9. Can be used for random number generation\n\n## Generating Random Code\n\n```php\n\u003c?php\nShortCode\\Random::get(); \n// Something like (8 chars by default) : aWg2m5Q3\n\nShortCode\\Random::get(6); \n// 6 character length. e.g. r43Nx2\n\nShortCode\\Random::get(8, ShortCode\\Code::FORMAT_ALNUM_SMALL); \n// 8 characters with alnum (small letter only). e.g. f43nbg3e2\n```\n\n## Generating Reversible Code from numbers\n```php\n\u003c?php\nShortCode\\Reversible::convert(46345223); \n// Output: 38svB\n\nShortCode\\Reversible::revert('38svB');\n// Output: 46345223\n\n// If you specify a format for converting, remember to use the same format for reverting\nShortCode\\Reversible::convert(46345223, ShortCode\\Code::FORMAT_ALNUM_CAPITAL);\n// Output: RLC7B\n\nShortCode\\Reversible::revert('RLC7B', ShortCode\\Code::FORMAT_ALNUM_CAPITAL);\n// Output: 46345223\n```\n\n### Reversible code with having a minimum length\n\nYou can create code with a minimum output length. \nYou have to mention the length for both, converting and reverting functions.\n\n```php\n\u003c?php\n// Creating alphanumeric code with minimum 6 character and reverting\nShortCode\\Reversible::convert(9876, \\ShortCode\\Code::FORMAT_ALNUM, 6); \n// Output: 1002zi\nShortCode\\Reversible::revert('1002zi', \\ShortCode\\Code::FORMAT_ALNUM, 6);\n// Output: 9876\n\n// Creating small letter only code with minimum 6 character and reverting\nShortCode\\Reversible::convert(9876, \\ShortCode\\Code::FORMAT_CHAR_SMALL, 6);\n// Output: baardm\nShortCode\\Reversible::revert('baardm', \\ShortCode\\Code::FORMAT_CHAR_SMALL, 6);\n// Output: 9876\n```\n\nPlease note that, using this method, you can only ensure the minimum character length. This length may exceed for larger numbers.\n\n### Dependency\n\nThis library has dependency on BCMath PHP extension. Please check the [installation page](http://php.net/manual/en/bc.setup.php) in case you don't have it configured. \n\nAlso it can be installed on linux based os with something similar to -\n```\n// FOr php 5.x\nsudo apt-get install php-bcmath\n// For php 7\nsudo apt-get install php7.0-bcmath\n```\n\n---\n\u003e \"This is the Book about which there is no doubt, a guidance for those conscious of Allah\" - [Al-Quran](http://quran.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajaxray%2Fshort-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajaxray%2Fshort-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajaxray%2Fshort-code/lists"}