PHPackages                             madmatt/silverstripe-uuid - 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. [Database &amp; ORM](/categories/database)
4. /
5. madmatt/silverstripe-uuid

AbandonedArchivedSilverstripe-vendormodule[Database &amp; ORM](/categories/database)

madmatt/silverstripe-uuid
=========================

A module that allows for easy usage of UUIDs on Silverstripe DataObjects

21.8k2[1 issues](https://github.com/madmatt/silverstripe-uuid/issues)PHPCI failing

Since Mar 14Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/madmatt/silverstripe-uuid)[ Packagist](https://packagist.org/packages/madmatt/silverstripe-uuid)[ RSS](/packages/madmatt-silverstripe-uuid/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Archived repository
===================

[](#archived-repository)

Caution

This repository is archived, please consider using [lekoala/silverstripe-uuid](https://github.com/lekoala/silverstripe-uuid) instead.

silverstripe-uuid
=================

[](#silverstripe-uuid)

This module provides an easy system for generating, storing and retrieving `DataObject`s by UUID, instead of the auto-incrementing IDs provided in Silverstripe CMS by default.

This module *does not* replace the auto-incrementing ID system, and this is still used as the standard primary key for all tables. It only adds a supplementary UUID as a secondary way of accessing an object. Therefore, it also does not provide the database-level benefits that using UUIDs can provide (e.g. the ability to asynchronously create unique IDs for objects in a multi-master replication setup).

The key reason for using this module is to ensure you don't leak information about your system to potential attackers. You should use UUIDs instead of auto-incrementing IDs in any public-facing context where you are referring to unique identifiers for an object.

For example, a URL to view an individual member's profile might be `/members/view-profile/ae9d059a-88b7-4480-b9fa-07b63e480e9a` instead of `/members/view-profile/273`. This ensures that attackers can't easily guess other IDs by just adding or subtracting numbers, and more importantly ensures that nobody knows how many customers you have etc.

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

[](#requirements)

- SilverStripe ^4.0

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

[](#installation)

```
composer require madmatt/silverstripe-uuid

```

Quick Usage
-----------

[](#quick-usage)

There are two ways to use this module:

- The simple but non-customisable way (adding the `UUIDExtension`)
- The advanced, DIY way (using one or more `UUIDField`s.

Which way you choose depends on how you want to use the module - in particular review the details below carefully to understand what each option means.

### Easy: Add the `UUIDExtension`

[](#easy-add-the-uuidextension)

The easiest way to use this module is to simply add the `UUIDExtension` to any `DataObject` that you want a UUID to be generated for:

**With YAML:**

```
App\Model\MyDataObject:
  extensions:
    - 'Madmatt\UUID\UUIDExtension'
```

**With PHP:**

```
