Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpanalysis Laravel Package

lmz/phpanalysis

A PHP Chinese word segmentation library based on PHPAnalysis. It splits Chinese text into words using dictionary rules, supports UTF-8/GBK input, and is useful for keyword extraction, search indexing, and basic text analysis in PHP projects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Chinese-language search relevance. Whitespace tokenizers break on CJK text; without segmentation, a query for "中文分词" won't reliably match documents containing those characters in different contexts. This package is the in-process option on the build-vs-buy table for any zh-CN search work.
  • Build vs buy for NLP pre-processing. MIT-licensed and Composer-installable, it represents the "zero marginal cost, no new infrastructure" end of the spectrum — against cloud NLP APIs (per-call spend, data egress) and a Python/jieba sidecar (ops headcount, another runtime).
  • Feature gating for zh-CN roadmap items. Auto-tagging, related-content, topic clustering, keyword extraction for SEO/slugs, autocomplete, and pre-processing for moderation or sentiment all depend on tokenization. Deciding this unblocks or blocks that whole cluster of work.
  • Architecture direction: adapter vs. commitment. The decision this most cleanly informs is whether to define a Segmenter interface in the codebase and treat any concrete implementation as swappable. That decision is reversible and cheap; picking this library is neither.
  • Prototype velocity. For a spike validating whether a zh-CN feature is worth building, a 5-minute install beats a two-week platform ticket.

It does not support decisions where search relevance is a core differentiator or where segmentation quality is user-visible and measured. At 2 stars and 0 dependents, there is no community validation, no regression suite you didn't write, and no signal that anyone has run this in production.

When to Consider This Package

Consider it when:

  • You need CJK segmentation inside a PHP process with no new services, no external calls, and no vendor contract.
  • The quality bar is low-to-moderate: admin-side tooling, rough keyword extraction, internal tagging, a prototype you intend to throw away.
  • Compliance or air-gap constraints forbid sending user text to a third-party NLP API.
  • You are willing to vendor the source into your repository and own it. The MIT license permits this, and given the maintenance profile, forking is the honest framing — not "adding a dependency."
  • You accept that you will write the test suite, the PHP-version matrix, and the edge-case handling yourself.

Look elsewhere when:

  • Search relevance is product-critical. Use Elasticsearch/OpenSearch with an IK or jieba analyzer, or Meilisearch/Typesense with CJK support. Segmentation belongs in the index, not in application code, once relevance matters.
  • You need custom domain dictionaries, POS tagging, named-entity recognition, or measurable accuracy. Use jieba, HanLP, or a hosted API (Baidu, Tencent, Alibaba).
  • You need maintenance guarantees: PHP 8.3+/Laravel 11+ compatibility, security patching, a responsive maintainer. A single-contributor repackaging with zero dependents offers none of this.
  • Throughput is high enough that per-request dictionary matching in PHP becomes a CPU and latency problem.
  • You cannot verify provenance. The description ("the PHP library for phpanalysis") suggests a wrapper or fork of the original phpanalysis. Before adopting, confirm: does it ship the dictionary data, is the license chain clean, does it carry upstream fixes, or is it just a composer.json around copied files? Treat an unverified answer as a no.

How to Pitch It (Stakeholders)

To executives (one paragraph): Chinese word segmentation is table stakes for any zh-CN market entry — search, tagging, and content discovery all sit on top of it. This library is a free, MIT-licensed, in-process option that avoids vendor spend and data-egress review. It is also unproven: two GitHub stars, no downstream dependents, one maintainer. Recommendation is a time-boxed spike behind an internal interface, not a platform commitment — we get a working demo cheaply while preserving the ability to swap in a proven engine if the feature graduates.

To engineering (the actual ask): Treat this as code we adopt, not a dependency we trust. Concretely:

  1. Define a Segmenter contract in our domain layer with a single segment(string): array method. All call sites depend on that, never on lmz/phpanalysis directly.
  2. Fork and vendor the source under our namespace; pin the dictionary version; add it to our CI matrix against our supported PHP versions.
  3. Build a small golden-set evaluation — 50–100 real zh-CN strings from our domain with expected token boundaries — before writing any feature logic. If it fails there, we've spent days, not a quarter.
  4. Document the exit path up front: swap to Elasticsearch IK, a jieba sidecar, or a hosted API. The interface makes that a one-class change.

Risk statement to carry into any review: low adoption, single maintainer, unverified fork lineage, unknown PHP-version support, and dictionary quality we cannot benchmark against alternatives without doing the work ourselves. All of that is acceptable for a spike and unacceptable for a load-bearing production path without the vendoring, testing, and abstraction steps above.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core