承接 nimp/link-loom 相关项目开发

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

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

nimp/link-loom

Composer 安装命令:

composer require nimp/link-loom

包简介

This package provides a PHP URL Shortener Library

README 文档

README

Tests PHPStan Code Coverage PHP Version

A flexible, extensible URL shortener library for PHP applications with multiple storage backends and event-driven architecture.

Features

  • 🚀 Multiple Storage Backends - Redis, File, or bring your own
  • 📝 PSR-compliant Logging - Built-in Monolog integration
  • 🎯 Event-Driven Architecture - Hook into URL processing lifecycle
  • 🔧 Extensible Design - Easy to customize validators, code generators, and more
  • 💪 Type-Safe - Full PHP type hints and exceptions

Installation

composer require nimp/link-loom

Quick Start

Basic Usage with Redis

<?php

use Nimp\LinkLoom\UrlShortenerBuilder;
use Redis;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

$shortener = (new UrlShortenerBuilder())
    ->withRedisRepository($redis)
    ->build();

// Shorten URL
$code = $shortener->encode('https://example.com/long-url');
echo "Short code: " . $code;

// Expand URL
$url = $shortener->decode($code);
echo "Original URL: " . $url;

With Logging

$shortener = (new UrlShortenerBuilder())
    ->withRedisRepository($redis)
    ->withLogger('/path/to/urls.log')
    ->build();

Advanced Configuration

$shortener = (new UrlShortenerBuilder())
    ->withCustomRepository(new MySQLRepository())
    ->withCodeGenerator(new MyCustomCodeGenerator())
    ->withCustomValidator(new MyCustomValidator())
    ->build();

Multiple Event Listeners

$shortener = (new UrlShortenerBuilder())
    ->withRedisRepository($redis)
    ->withLogger('/path/to/urls.log')
    ->addListener(new AnalyticsListener())
    ->addListener(new CacheListener())
    ->build();

Custom Event Dispatcher

$shortener = (new UrlShortenerBuilder())
    ->withRedisRepository($redis)
    ->withEventDispatcher($myCustomDispatcher)
    ->build();

Event System

LinkLoom provides a comprehensive event system for monitoring the URL shortening lifecycle using the Observer pattern.

Available Events

All events extend BaseShortenerEvent and provide access to the UrlShortener instance:

$event->context; // UrlShortener instance
Event Trigger Data
EncodeStartEvent Before URL encoding starts url, context
EncodeSuccessEvent After successful URL encoding url, code, context
DecodeStartEvent Before code decoding starts code , context
DecodeSuccessEvent After successful code decoding code, url, context
ValidateErrorEvent When URL validation fails url, message, context
GetFromStorageErrorEvent When storage read fails code, message, context
SaveErrorEvent When storage save fails message, context

UrlShortener Methods

Method Description

encode(string $url): string	Shorten URL and return code
decode(string $code): string	Expand code to original URL

nimp/link-loom 适用场景与选型建议

nimp/link-loom 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 nimp/link-loom 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-03