All Projects → SiroDiaz → Base62

SiroDiaz / Base62

Licence: MIT License
PHP Base62 encoder and decoder for integers and big integers with Laravel 5 support.

Programming Languages

PHP
23972 projects - #3 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to Base62

Laravel Server Monitor
Server Monitoring Command for Laravel Applications
Stars: ✭ 424 (+2550%)
Mutual labels:  composer, laravel-package, laravel-5-package
artisan-shortcuts
🍰 Register shortcuts to execute multiple artisan commands
Stars: ✭ 56 (+250%)
Mutual labels:  laravel-framework, laravel-package, laravel-5-package
Laraupdater
Enable Laravel App Self-Update. Allow your Laravel Application to auto-update itself.
Stars: ✭ 75 (+368.75%)
Mutual labels:  laravel-framework, laravel-package, laravel-5-package
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+1337.5%)
Mutual labels:  laravel-framework, laravel-package, laravel-5-package
video-downloader
Video Downloader for Facebook.
Stars: ✭ 63 (+293.75%)
Mutual labels:  composer, laravel-package, laravel-5-package
Laravel Gitscrum
GitScrum is a Project Management Tool, developed to help entrepreneurs, freelancers, managers, and teams Skyrocket their Productivity with the Agile methodology and Gamification.
Stars: ✭ 2,686 (+16687.5%)
Mutual labels:  laravel-framework, laravel-package, laravel-5-package
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (+1137.5%)
Mutual labels:  laravel-framework, laravel-package, laravel-5-package
Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+1893.75%)
Mutual labels:  composer, laravel-package, laravel-5-package
Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+13725%)
Mutual labels:  composer, laravel-package, laravel-5-package
yii2-minify-url
Project on YII2 framework for create short url (url shortener)
Stars: ✭ 15 (-6.25%)
Mutual labels:  url-shortener, shortener
correios-consulta
Buscar informações de serviços dos correios diretamente nos sites deles, sem utilizar api de terceiros.
Stars: ✭ 155 (+868.75%)
Mutual labels:  laravel-package, laravel-5-package
VBCorLib
The VBCorLib framework brings many of the powerful .NET classes to VB6.
Stars: ✭ 81 (+406.25%)
Mutual labels:  encoding, biginteger
collage
Generate Image Collage with PHP and Laravel
Stars: ✭ 70 (+337.5%)
Mutual labels:  composer, laravel-5-package
as-bignum
Fixed length big numbers for AssemblyScript 🚀
Stars: ✭ 49 (+206.25%)
Mutual labels:  biginteger, bigint
bytes-java
Bytes is a utility library that makes it easy to create, parse, transform, validate and convert byte arrays in Java. It supports endianness as well as immutability and mutability, so the caller may decide to favor performance.
Stars: ✭ 120 (+650%)
Mutual labels:  encoding, biginteger
laravel-jwt-auto-installer
A Laravel Library that let's you add tymon jwt auth library and all it's features with single command
Stars: ✭ 19 (+18.75%)
Mutual labels:  laravel-framework, laravel-package
querydumper
Laravel package to dump all running queries on the page.
Stars: ✭ 24 (+50%)
Mutual labels:  composer, laravel-5-package
laravel-crm
Free & Opensource Laravel CRM solution for SMEs and Enterprises for complete customer lifecycle management.
Stars: ✭ 927 (+5693.75%)
Mutual labels:  laravel-framework, laravel-package
dwarf
A O(1) URL shortener microservice backed by redis and gRPC communication.
Stars: ✭ 33 (+106.25%)
Mutual labels:  url-shortener, shortener
BigInteger
Be limited not by the size of your register but by the bulk of your RAM.
Stars: ✭ 13 (-18.75%)
Mutual labels:  biginteger, bigint

Base62

Build Status paypal

Base62 encoder and decorder also for big numbers. Useful to short database numeric ids in URLs.

requirements

  • requires PHP >= 7.1.0 or higher
  • Composer
  • GMP (preferred) or BCMath extensions enabled.

Composer

$ composer require base62/base62

Laravel 5

You just need to follow the composer command listed before and then you have to publish the base62.php config file into the config path of Laravel with the following command:

$ php artisan vendor:publish --tag=base62/base62

Then you can change in config/base62.php the default driver that is 'basic' (the PHP encoder implementation) for another supported by your host. It is recomended to use GMP extension because it is the most fast solution. Allowed encoders and decoders drivers are:

  • basic
  • gmp
  • bcmath

Quick Start and Examples

Methods

encode and decode

Encoders/Decoders drivers

  • basic
  • gmp
  • bcmath

Examples

Encoding and decoding litle numbers.

require 'vendor/autoload.php';

use Base62\Base62;

$base62 = new Base62();		// by default use 'basic' driver. It is the default PHP encoder and decoder
$encodedValue = $base62->encode(200000);	// 'Q1O'
$decodedValue = $base62->decode($encodedValue); // 200000

Encoding and decoding big numbers. An important thing you must take in count: your PHP can be 32 or 64 bit, this means that a representation of an integer can take a maximum or 32 or 64 bit. This is a important limitation when you work with big integers, but for solve this problem we have GMP and BCMath native extensions for PHP.

require 'vendor/autoload.php';

use Base62\Base62;

// unsigned bigint (MySQL) 18446744073709551615
$id = '214748364787898954454';

$base62 = new Base62('gmp');
// print encoded base62 number id
$encodedValue = $base62->encode($id);	// '47rhmv5JHMPe'
$decodedValue = $base62->decode($base62->encode($id)); // '214748364787898954454'

Note that encode method uses strings as argument and not an integer. This is the best option by a simple reason. Imagine that you uses an integer that can not been represented by native PHP 32 or 64 bit interpreter, what would happen? Simple, the integer is truncated and can take negative values or a different positive number.

License

MIT License Copyright © 2014-present, Siro Díaz Palazón

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].