PHPackages                             monamoxie/vocab-mapper - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. monamoxie/vocab-mapper

ActiveLibrary[Testing &amp; Quality](/categories/testing)

monamoxie/vocab-mapper
======================

Supercharge your application by providing a seamless and personalized experience. Vocab Mapper ensures that users across different regions or domains can easily interact with and navigate your application, even if they use different vocabulary for the same concepts

1.0.3(1y ago)0342[3 issues](https://github.com/Monamoxie/vocab-mapper/issues)MITPHPPHP ^8.1CI passing

Since May 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Monamoxie/vocab-mapper)[ Packagist](https://packagist.org/packages/monamoxie/vocab-mapper)[ Docs](https://github.com/Monamoxie/vocab-mapper)[ RSS](/packages/monamoxie-vocab-mapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (4)Used By (0)

[![](files/img/logo-w.png)](files/img/logo-w.png)

[![Github Actions](https://camo.githubusercontent.com/befef46ef15434d3fb063ebfae608744f3ba1f3f8b971f44093d56b734453443/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4172636869746563747572652d4d756c74695f54656e616e63792d6c696d65677265656e3f7374796c653d706c6173746963)](https://camo.githubusercontent.com/befef46ef15434d3fb063ebfae608744f3ba1f3f8b971f44093d56b734453443/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4172636869746563747572652d4d756c74695f54656e616e63792d6c696d65677265656e3f7374796c653d706c6173746963)[ ![](https://camo.githubusercontent.com/a7a0b367b817941a439dc73935b975fb030bdf403eb8d05dbe26816f14ff4489/68747470733a2f2f636f6465636f762e696f2f67682f4d6f6e616d6f7869652f766f6361622d6d61707065722f6272616e63682f6d61737465722f67726170682f62616467652e737667) ](https://codecov.io/gh/Monamoxie/vocab-mapper)[![Github Actions](https://github.com/Monamoxie/vocab-mapper/actions/workflows/build.yml/badge.svg?branch=master&event=push)](https://github.com/Monamoxie/vocab-mapper/actions/workflows/build.yml)[![Latest Stable Version](https://camo.githubusercontent.com/fa3cf366fb3e9f41c20d17ab26030fed5e576480f40ed8c61b9b8c1237848b8a/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e616d6f7869652f766f6361622d6d61707065722f762f737461626c65)](https://packagist.org/packages/monamoxie/vocab-mapper)

VOCAB MAPPER
============

[](#vocab-mapper)

A Laravel package for both multi-tenant and single tenant architectures.

Vocab Mapper provides your tenants or users a personalized experience, by defining mappings between standard terminology (The Default Vocab) and user-preferred terminology (The Custom Vocab), especially when both terminologies are referring to the same core concept.

INSTALLATION
------------

[](#installation)

```
composer require monamoxie/vocab-mapper

```

VENDOR PUBLISHING
-----------------

[](#vendor-publishing)

Vocab Mapper includes some default configurations out of the box, but it's recommended you publish and customize these settings to suit your needs.

#### PUBLISHING THE CONFIG

[](#publishing-the-config)

```
php artisan vendor:publish --tag=vocab-mapper-config

```

#### EXPLORING THE VOCAB CONFIG

[](#exploring-the-vocab-config)

###### MIGRATION SUB DIR

[](#migration-sub-dir)

```
migration_sub_dir => null

```

This is the subdirectory where Vocab Mapper's migration files will be published. The default value is null, suitable for most single-tenant applications.

For multi-tenant systems needing a different subdirectory for tenant-specific migrations, you can simply set the subdirectory value here. For example, the stancl/tenancy multi-tenant package requires tenant migrations be kept in `database/migrations/tenant`.

If that is the case, then you should set the value of `migration_sub_dir => '/tenant'`

###### ENTITY MODEL

[](#entity-model)

An entity in your application is a unique tenant or user who whiches to use a custom vocabulary for a core concept, different from the standard term.

###### Single-tenant systems

[](#single-tenant-systems)

In single-tenant systems, this is typically the model class representing your users. For example, `\App\Models\User::class`, or whichever model namespace manages and identifies your users.

keytypeDefault Value`entity_model``string,array``\App\Models\User::class`###### Multi-tenant systems

[](#multi-tenant-systems)

In multi-tenant systems, this is typically the model class representing the tenant. For example, `\App\Models\Tenant::class`, or whichever model namespace manages and identifies your tenants.

keytypeRecommended`user_entity``string,array``\App\Models\Tenant::class`Please refer to the section on [BREAK DOWN OF TERMS](#break-down-of-terms) for a more information on this.

###### ENTITY HAS UUID

[](#entity-has-uuid)

Enable this option if the entity model utilizes a UUID as its primary key.

keytypeDefault Value`user_entity_has_uuid``boolean``false`#### PUBLISHING THE MIGRATION

[](#publishing-the-migration)

```
php artisan vendor:publish --tag=vocab-mapper-migration

```

This action will publish the migration files based on the provided configuration in `migration_sub_dir`. If no specific path is set, the files will be published to Laravel's default migration directory.

MIGRATION
---------

[](#migration)

Run the artisan command responsible for handling your Database migrations.

###### Single-tenant systems

[](#single-tenant-systems-1)

```
php artisan migrate

```

###### Multi-tenant systems

[](#multi-tenant-systems-1)

The command to execute depends on your setup or package configuration. For example, projects utilizing the stancl/tenancy package would execute:

```
php artisan tenants:migrate

```

MAKING YOUR ELOQUENT MODELS VOCABLE
-----------------------------------

[](#making-your-eloquent-models-vocable)

A vocab is a name, identity or a domain driven terminology used by default across your application. In an educational project, it could be the word `SUBJECTS` for storing all the subjects taught in a school. In an automotive project, it could be the word `VEHICLES` for identifying all vehicles available in your system.

To make any of your models `VOCABLE`, (which is the ability to maintain and be represented in a different term across multiple tenants or users), you should include the `HasVocab` trait to the model

```
