PHPackages                             darkghosthunter/rut-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. darkghosthunter/rut-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

darkghosthunter/rut-utils
=========================

A complete library for handling chilean RUTs and RUNs.

v3.0.1(5y ago)31.4k[1 PRs](https://github.com/DarkGhostHunter/RutUtils/pulls)1MITPHPPHP ^7.4||^8.0

Since Dec 21Pushed 1y agoCompare

[ Source](https://github.com/DarkGhostHunter/RutUtils)[ Packagist](https://packagist.org/packages/darkghosthunter/rut-utils)[ Fund](https://paypal.me/darkghosthunter)[ Fund](https://ko-fi.com/DarkGhostHunter)[ RSS](/packages/darkghosthunter-rut-utils/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (2)Versions (20)Used By (1)

[![Pablo García Saldaña - Unsplash (UL) #Y-MGVIkpyFw](https://camo.githubusercontent.com/f0b02b85e699048bb5759e36444db805ca0649c70db3eead11e1c5c438db351e/68747470733a2f2f696d616765732e756e73706c6173682e636f6d2f70686f746f2d313434313438343239353935352d6462303764653166646261643f69786c69623d72622d312e322e31266175746f3d666f726d6174266669743d63726f7026773d3132383026683d34303026713d3830)](https://camo.githubusercontent.com/f0b02b85e699048bb5759e36444db805ca0649c70db3eead11e1c5c438db351e/68747470733a2f2f696d616765732e756e73706c6173682e636f6d2f70686f746f2d313434313438343239353935352d6462303764653166646261643f69786c69623d72622d312e322e31266175746f3d666f726d6174266669743d63726f7026773d3132383026683d34303026713d3830)

[![Latest Stable Version](https://camo.githubusercontent.com/cd7c779816e26bf37d305dbc015c01f4e953740bad6925fe3d470ee5db12fa0c/68747470733a2f2f706f7365722e707567782e6f72672f6461726b67686f737468756e7465722f7275742d7574696c732f762f737461626c65)](https://packagist.org/packages/darkghosthunter/rut-utils) [![License](https://camo.githubusercontent.com/092ff5986a8bd555caf34f672e61850ca29df0c5d8e2fa9e55a9b7601bf64770/68747470733a2f2f706f7365722e707567782e6f72672f6461726b67686f737468756e7465722f7275742d7574696c732f6c6963656e7365)](https://packagist.org/packages/darkghosthunter/rut-utils)[![](https://camo.githubusercontent.com/ec815f3fbd638fa65736c0d7d9f3579c0211a14a15d9e2aa1b18d9091ca20095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461726b67686f737468756e7465722f7275742d7574696c732e737667)](https://camo.githubusercontent.com/ec815f3fbd638fa65736c0d7d9f3579c0211a14a15d9e2aa1b18d9091ca20095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461726b67686f737468756e7465722f7275742d7574696c732e737667) [![Coverage Status](https://camo.githubusercontent.com/4c37faba4d6955b0800c849b3ea1fbbc3e314555be6737b48028de87fd88a719/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4461726b47686f737448756e7465722f5275745574696c732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/DarkGhostHunter/RutUtils?branch=master) [![Maintainability](https://camo.githubusercontent.com/fc4ba49b4c8c27ad5db568834c6ed20c15886da69b9642b835a3daf4e4995892/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f37313432636563623933653535356364373032382f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/DarkGhostHunter/RutUtils/maintainability)

RUT Utilities
=============

[](#rut-utilities)

A complete library for creating, manipulating and generating chilean RUTs or RUNs.

This package allows you to:

- **Create** a RUT object to conveniently hold the RUT information.
- **Validate**, clean and rectify RUTs.
- **Generate** random RUTs in a flexible manner.

While this package works as a fire-and-forget utility for your project, ensure you read the documentation so you don't repeat yourself.

Requirements
------------

[](#requirements)

This package only needs PHP 7.3 and later.

It may work on older versions, but it will only support active PHP releases.

> Optional: Know what *el weón weón weón* means.

Installation
------------

[](#installation)

Just fire Composer and require it into your project:

```
composer require darkghosthunter/rut-utils
```

If you don't have Composer in your project, you should be ashamed just [install it](https://getcomposer.org/download/) .

Usage
-----

[](#usage)

- [What is a RUT or RUN?](#what-is-a-rut-or-run)
- [Creating a RUT](#creating-a-rut)
- [Retrieving a RUT](#retrieving-a-rut)
- [Generating RUTs](#generating-ruts)
- [Helpers](#helpers)
- [Make Callbacks](#make-callbacks)
- [Serialization](#serialization)
- [Global helper](#global-helper)

### What is a RUT or RUN?

[](#what-is-a-rut-or-run)

A RUT (or RUN for people) is a string of numbers which identify a person or company. They're unique for each one, and they're never re-assigned to an individual, so the registry of RUTs is always growing.

The RUT its comprised of a random Number, like `18.765.432`, and a Verification Digit, which is the result of a mathematical algorithm [(Modulo 11)](https://www.google.com/search?q=modulo+11+algorithm) over that number. This Verification Digit vary between `0` and `9`, or a `K`. In the end. you get this:

```
18.765.432-1

```

This identification information is a safe bet for chilean companies. It allows to attach one account to one individual (person or company), and can be cross-referenced with other data the user may have available through other services.

> What's the difference between RUTs and RUNs? RUT are meant for identifying a person or company taxes, RUNs are to identify single persons. For both cases, **they're practically the same**.

### Creating a RUT

[](#creating-a-rut)

There are two ways to create a RUT: manual instancing, which is strict, and using the `make()` static helper.

#### Manual instancing

[](#manual-instancing)

Using manual instantiation allows you to create a RUT by the given number and verification digit quickly. For example, with data coming from a Database or any other trustful source.

```
