Download the PHP package benji/public-id without Composer

On this page you can find all versions of the php package benji/public-id. 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 public-id

Laravel Public ID

A simple and automatic short ids (like youtube ids) generator for your laravel projects. Powered by Hashids project (and malahierba dev team)

Installation

Add in your composer.json:

{
    "require": {
        "malahierba-lab/public-id": "1.*"
    }
}

Then you need run the composer update command.

Very Important: in composer.json use the "1.*" notation, not the ">1". If in future releases we change the conversion tool, you can loose your old public id values. For prevent this, always stay in the same mayor version.

Use

After Public ID installation, you must add the trait in any model which you want get public id functionality.

Example for Post Model:

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Malahierba\PublicId\PublicId;

class Post extends Model {
    use PublicId;

    //your code...

After that, you can setup the static variables to define the settings for the publicID: public_id_salt, public_id_min_length, public_id_alphabet, in previous example:

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Malahierba\PublicId\PublicId;

class Post extends Model {
    use PublicId;

    static protected $public_id_salt = 'some_string_for_salt_your_ids';

    static protected $public_id_min_length = 6; // min length for your generated short ids.

    static protected $public_id_alphabet = 'ABCDEFGHIJKLM'; // Only letters A-M

    //your code...

There are 4 predefined alphabets you can use. Setting the public_id_alphabet variable to upper_alphanumeric, upper_alpha, lower_alphanumeric, lower_alpha will use those predefined alphabets:

upper_alphanumeric => ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
upper_alpha => ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower_alphanumeric => abcdefghijklmnopqrstuvwxyz0123456789
lower_alpha => abcdefghijklmnopqrstuvwxyz

That's all. Now you can use the Public ID functionality in your Post Model:

Get the Public ID (a.k.a. short id) for a model:

$short_id =  $post->public_id;

Get a model based on a public id string

$post = Post::findByPublicId($public_id);

Get the original ID with the public id string

$original_id = Post::publicIdDecode($public_id);

Big numbers

The max ID than can be managed by default is a billion (1.000.000.000). But, depending of your environment this number could be bigger. For test the max ID in your environment setup you can use the testPublicIdMaxInt function:

$max_id = Post::testPublicIdMaxInt();

Licence

This project has MIT licence. For more information please read LICENCE file.


All versions of public-id with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.18
laravel/framework Version 5.*
hashids/hashids Version 1.0.5
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 benji/public-id contains the following files

Loading the files please wait ....