Download the PHP package basteyy/php-stringer without Composer
On this page you can find all versions of the php package basteyy/php-stringer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-stringer
basteyy`s PHP Stringer Package
Every developer knows the drill: Here I need a random string, there I have to generate a URL from an input, and then I want to find out how long ago an event was. This package bundles a few functions that I constantly need in my projects. You are welcome to contribute and expand it.
Installation
Usage
To use the basteyy\php-stringer
package in your projects, here are some examples with their expected outputs:
String Mainiplation
Escape String
For safe output of strings in an HTML context, use escapeString
:
Generate Hash Sum
Create a hash sum of a string (default algorithm is SHA256) using getStringHashSum
:
Remove Double Slashes
Use remove_double_slashes
to clean up file paths or URLs:
Slugify Text
Convert a string into a URL-optimized version with getSlugifiedText
:
Slugify (Deprecated)
For backward compatibility, slugify
is still available but is deprecated. It functions the same as getSlugifiedText
:
Random String Generation
Generate Alphanumeric String
Generate Numeric String
Generate Alphabet String
Generate String with Custom Characters:
Create memorable password
The createMemorablePassword function in the basteyy\Stringer library generates passwords that are easier to remember, combining words, numbers, and symbols. This function is not cryptographically secure and is more suitable for user-friendly passwords rather than high-security purposes.
In this example, the function generates a password with:
- 2 random words from a predefined list.
- 2 random numbers.
- 2 random symbols from the default symbol set !@#$%^&*.
- Converts the password to lowercase.
The output will be a string like apple7%cloud4*
, making it memorable yet unique. You can adjust the counts of words, numbers, and symbols as needed.
Attention: The function
createMemorablePassword
is not cryptographically secure and should not be used for high-security.
Time Manipulation
Get Nice Time Ago
getNiceTimeAgo
function returns a human-readable time difference from the current time to the provided DateTime.
These examples showcase the versatility of the getNiceTimeAgo
function, providing options for exact time intervals, custom unit names, and localization.