承接 junaidkhan/php-string-helper 相关项目开发

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

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

junaidkhan/php-string-helper

Composer 安装命令:

composer require junaidkhan/php-string-helper

包简介

A PHP helper library offering utilities like truncate, slugify, casing conversions, and more.

README 文档

README

Packagist PHP Version Downloads License Issues Contributors Tests

String Helper is a PHP helper library for common string operations, built for PHP 8+.

Features

  • Truncate strings by character count (with word-safe, custom suffixes and HTML-stripping or HTML-preserving)
  • Limit strings by word count with custom suffixes
  • Check if strings start with, end with, or contain a substring
  • Remove special characters with optional Unicode, dash, or underscore preservation
  • Reverse strings easily
  • Detect valid JSON strings with a simple check
  • Create clean slugs for URLs or SEO
  • Convert strings to camelCase, snake_case, and kebab-case

Installation

Install via Composer:

composer require junaidkhan/php-string-helper

Usage

1. Autoload with Composer

require 'vendor/autoload.php';

2. Import the class

use JunaidKhan\StringHelper\StringHelper;

3. Use the methods

// Slugify
echo StringHelper::slugify('  Mastering PHP in 2025!  '); // master-php-in-2025

// Case conversions
echo StringHelper::toCamelCase('modern_php_tutorial');       // modernPhpTutorial
echo StringHelper::toSnakeCase('modernPhpTutorial');         // modern_php_tutorial
echo StringHelper::toKebabCase('modernPhpTutorial');         // modern-php-tutorial

// String checks
echo StringHelper::startsWith('FrameworkX', 'Frame');         // true
echo StringHelper::endsWith('SuperTool', 'Tool');             // true
echo StringHelper::contains('Debugging helps developers', 'help'); // true

// Truncate with suffix (text, maxLength, suffix, wordSafe, stripHtml, preserveHtml)
echo StringHelper::truncate('Mastering PHP in 2025!', 15, '...', true, false, false); // Mastering PHP...

// Limit words with suffix (text, wordLimit, suffix)
echo StringHelper::limitWords('Master PHP with real-world projects', 3, '...'); // Master PHP with...

// Reverse string (text)
echo StringHelper::reverse('Productivity'); // ytivitcudorP

// Remove special characters (text, preserveUnderscore, preserveDash, allowUnicode)
echo StringHelper::removeSpecialChars('E-mail@example.com!', false, false, false); // Emailexamplecom

// Check valid JSON (string)
echo StringHelper::isJson('{"valid":true}'); // true

Methods

Method Parameters Description
slugify string $string Convert a string into a URL-friendly slug
toCamelCase string $text Convert to camelCase
toSnakeCase string $text Convert to snake_case
toKebabCase string $text Convert to kebab-case
startsWith string $haystack, string $needle Check if string starts with a given substring
endsWith string $haystack, string $needle Check if string ends with a given substring
contains string $haystack, string $needle Check if string contains a given substring
truncate string $text, int $maxLength, string $suffix, bool $wordSafe, bool $stripHtml, bool $preserveHtml Truncate string with full support for HTML, suffix, and word-safety
limitWords string $text, int $wordLimit, string $suffix Limit string by number of words, appending suffix if trimmed
reverse string $text Reverse the given string
removeSpecialChars string $text, bool $preserveUnderscore, bool $preserveDash, bool $allowUnicode Remove all non-alphanumeric characters (with optional preservation)
isJson string $string Check if the string is valid JSON

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

🙌 Contributing

Contributions are welcome! Feel free to fork the repository, open issues, or submit pull requests to help improve the package.

junaidkhan/php-string-helper 适用场景与选型建议

junaidkhan/php-string-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 7, 最近一次更新时间为 2025 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 junaidkhan/php-string-helper 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-19