blake/laraveldoctrine-hashids 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blake/laraveldoctrine-hashids

Composer 安装命令:

composer require blake/laraveldoctrine-hashids

包简介

Hashid type for Doctrine

README 文档

README

This package uses vinkla's Hashids bridge for Laravel to provide a Doctrine type that obfuscates integer IDs using Hashids.

Installation

Before installing this package, install and configure the vinkla/hashids package.

Require this package using composer:

composer require "blake/laraveldoctrine-hashids:~1.0"

The next step is enabling the Doctrine type. If you are using the laravel-doctrine/orm package, add this to your config/doctrine.php file:

    'custom_types'              => [
        // ...
        'hashid' => Blake\Dbal\Types\HashidType::class,
    ],

Usage

Anywhere you are using an integer in your entities you may safely replace with the hashid type:

<?php

namespace App\Entities;

use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity
 * @ORM\Table
 */
class User
{
    /**
     * @var string
     * @ORM\Id
     * @ORM\Column(type="hashid", nullable=false)
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;
    
    // ...
}

Interacting with the entity manager is as you'd expect. Simply replace where you'd use lame integer IDs with their obfuscated version:

$user = EntityManager::find(User::class, 'dlGRfgH73');

The ID will be decoded before it hits the database, and it will be encoded on the way out. This allows you to use performant integer IDs while obfuscating details about your database and making URLs that point to objects slightly prettier.

Configuration

vinkla/hashids allows you to set up multiple "connections". This package will look for a doctrine connection and use main as a fallback if the doctrine connection doesn't exist.

统计信息

  • 总下载量: 89
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固