Generate readable random phrases for URLs
This library is available on packagist. To install,
composer require hyungju/readable-url
Then create ReadableURL
Class
$readableURL = new HyungJu\ReadableURL();
You can pass four parameters to the class.
use HyungJu\ReadableURL;
// Takes 4 parameters.
// 1. A boolean value - If true, returns string in CamelCase, else lowercase.
// 2. An integer value - The number of words to be generated in the string. (Between 2 and 10).
// 3. A string - The seperator between the words.
// 4. Language Class - Currently Supported : HyungJu\Language\En, HyungJu\Language\Ko. pass language instance! the default is HyungJu\Language\En
$readableURL = new ReadableURL();
//$readableURL = new HyungJu\ReadableURL(false, 5, '-', new HyungJu\Language\Ko()); // Other options.
To generate ReadableURL
, call the generate()
function.
use HyungJu\ReadableURL;
...
$readableURL = new ReadableURL();
$readableURL->generate();
// > QuickScrawnyCamp
In addition, the following are simple to:
use HyungJu\ReadableURL;
...
$str = ReadableURL::gen();
// > FierceSaltyComparison
This can be used to add to the end of a URL.
Example: https://example.com/photos/ForgetfulHarshEgg
For best results, use an integer value of 3, 4, or 5.
composer test
-
Add wordsets to
src/words/[language code]
. adjectives.txt and nouns.txt are needed. -
Create your language class
src/Language/[language code].php
. the class name must be started with Uppercase. -
Implement the class based on other languages already implemented (korean and english)
-
Register your language in
src/Language/LanguageHelper.php
. -
(optional) Add test for your language.
We use SemVer for versioning this project.
MIT License
- This library is a PHP port of readable-url
Thanks goes to these wonderful people (emoji key):
도다 💻 |
Yukihyõ 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!