Download the PHP package parsidev/randomizr without Composer

On this page you can find all versions of the php package parsidev/randomizr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package randomizr

Randomizr: generating random madness

Randomizr is a simple package that helps you generate all kinds of random stuff (hashes, strings, numbers, ...). It can even check whether the created random is unique within a given database table or directory.

Table of contents

  1. Installation
  2. Usage
    2.1. Charsets
    2.2. Aliases
    2.3. Generating unique randoms
    2.4. Using the Facade
    2.5. Additional helpers
  3. Customizing
    3.1. Registering custom charsets
    3.2. Registering custom aliases

  4. Installation

Register the Service Provider:

Additionally, you may register an alias for it, though it's not required (you can also use the helper or include the namespace):

To make sure the package will be loaded properly, run:

  1. Usage

2.1. Charsets

Randomizr distincs several character sets, which are:

Name Contents
num 0123456789
vowel aeijoy
consonant bcdfghklmnpqrstvwxyz
special áäâàæãåāaeéëêèęėēuúüûùūiíïïìiîįīoóöôòõœøōç
space ' '
dash -
underscore _
punctuation :,.?!()

Simple usage

To generate a random using either one of the charset, simply call the make() method on the randomizr() helper and tell it which charset you want to use:

Setting bounderies

The make() method accepts 2 (optional) arguments: $max and $min:

Combining charsets

You can also mix 'n match different charsets. For example, if you want to generate a random num, but also allow a dash and an underscore in it:

2.2. Aliases

Though camel- or snake casing is a very convenient way to merge various charsets, you may as well register an alias for it. By default, these are the ones provided:

Name Combines
lowercase vowel, consonant
uppercase uppercased lowercase
alpha uppercase, lowercase
string alpha, num, dash, space, underscore, punctuation, '&$@'
hash alpha, num, dash, underscore, '&$@'

So in fact, lowercase is an alias to vowel_constant. And lets be honest, it's far more cleaner looking.

Combining aliases and/or charsets

As you may have seen it already in the table above, aliases also allow to combine charsets with aliases, or even aliases with each other:

2.3 Generating unique randoms

Randomizr can generate randoms that are unique either in a directory or in a database table using the unique() method instead of make().

Unique in a directory

Unique in a database table (for a field)

Note: Checking for uniqueness against a database table requires the package to run in a Laravel application. You won't be able to use this feature elsewhere.

Setting bounderies

The same way you can set bouderies for make(), you can do it for unique():

2.4. Using the Facade

I personally prefer using the helper method (which doesn't require you to put the full namespace at the top of your file), but you can just as well use the facade or alias (if registered in the app config):

2.5. Additional helpers

In addition to the randomizr() helper, a few other helper functions are included that can be used throughout the entire application:

Strings

str_starts_with

str_starts_with checks if a given string starts with a specified (group of) character(s).

str_ends_with

str_ends_with checks if a given string ends with a specified (group of) character(s).

  1. Customizing

Several charsets and aliases are available by default, but you can add your own ones if you like. All you need to do is config the Randomizr config file:

The config file will be published to app/config/packages/luminol/randomizr/randomizr.php.

Note: I made a custom artisan command for this to keep publishing assets the same for both L4 and L5.

3.1. Registering custom charsets

Registering custom charsets is pretty straight forward. Just add:

Important: Charset names should always consise of one word only. Do not use snake- or camel casing (it'll break the combine functionality).

3.2. Registering custom aliases

Custom aliases are a bit more configurable: it uses piping to separate the different components to combine. These components can be a raw string, charset or alias and can even be altered using a basic string functions.

To illustrate all of this, let's image you need to generate a random ID, which can contains alpha characters (both upper- and lowercase), dashes and '.'.

Combining charsets and/or aliases

The example above tells us the ID alias may contain alpha characters (which is an alias) and dashes (which is a charset). So to combine them in the id alias:

Randomizr will automatically resolve these as an alias and a charset.

Adding a raw string to an alias

In our example above, we also need a '.' (dot) to be added. It is available in the punctuation charset, but all other characters in this one are not allowed in the ID alias.

We could register the single dot as a charset, but we can also pass it as a raw string to the alias. Just wrap it between single quotes:

If you want to add a raw number to the alias, no need to wrap it in single quotes (though it will work as well):

Using simple string functions

Aliases also allow basic string functions to be used. For example, you might only want an uppercased version of the special charset. In that case, you can seperate the function name and its argument using method:arg1,arg2 format:

The functions arguments can be a charset, an alias or even a raw string (wrapped in single quotes):


All versions of randomizr with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
illuminate/support Version ~7.0 | ~8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package parsidev/randomizr contains the following files

Loading the files please wait ....