承接 alecgarcia/laravel-uid 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

alecgarcia/laravel-uid

Composer 安装命令:

composer require alecgarcia/laravel-uid

包简介

Create UIDs like the ones Stripe generates. These can be used on your models or on their own.

README 文档

README

Latest Stable Version Total Downloads License Dependents

This package creates UIDs like the ones Stripe uses for your models or on their own.

Installation

Via Composer

$ composer require alecgarcia/laravel-uid

Usage

To use with a model

1. Add uid column to table

With an existing Model

  1. Add a migration
php artisan make:migration --table users add-uid-to-users
  1. Open up the migration file you just created and add a uid field.
    1. If you overrode the column name in either the config for the default or in your model, make sure you create the column in your table to match.
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('uid', 32)->after('id')->unique();
        });
    }
    
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('uid');
        });
    }

With a new Model

  1. Open up the migration file for the model and add a uid field
    1. If you overrode the column name in either the config for the default or in your model, make sure you create the column in your table to match.
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('uid', 32)->unique();
            $table->timestamps();
        });
    }

2. Add the trait to your model

<?php

namespace App\Models;

use Alecgarcia\LaravelUid\Traits\Uid;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use UID;
}

To used statically

<?php

use Alecgarcia\LaravelUid\Uid;

$generatedUid = Uid::make();
// Generated Uid -> "1mVQuIwVrRS9ijwx" // Defaults to no prefix and 16 Characters long

$generatedUid = Uid::make('uid', 12);
// Generated Uid -> "uid_nuv8V6GH"     // Can set the prefix that is used and the length

Customization

Using the trait

You can add the following properties to your model to configure the Uid trait.

  • This will override the defaults as well as the config file.
<?php

namespace App\Models;

use Alecgarcia\LaravelUid\Traits\Uid;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use UID;
    
    public static string $uidPrefix = 'usr';  // Defaults to models class name
    public static int $uidLength = 10;        // Defaults to 16 total characters
    public static bool $uidCheck = false;     // Default is true
    public static string $uidColumn = 'uidCustomColumn'; // Default is uid
}

Using the config file for defaults

  1. Publish the config file.
$ php artisan vendor:publish --tag laravel-uid.config
  1. Customize the defaults in the app/config/laravel-uid.php file.
<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Customize how the uid is created and used
    |--------------------------------------------------------------------------
    */
    'characters' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
    'prefix_separator' => '_',
    'uid_column' => 'uid',
    'length' => 16,
    'check' => true,
];

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ php vendor/bin/phpunit

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email hello@alecgarcia.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

alecgarcia/laravel-uid 适用场景与选型建议

alecgarcia/laravel-uid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「UID」 「LaravelUid」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 alecgarcia/laravel-uid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alecgarcia/laravel-uid 我们能提供哪些服务?
定制开发 / 二次开发

基于 alecgarcia/laravel-uid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-24