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

Twig Classes Laravel Package

zicht/twig-classes

A Twig extension for building CSS class lists in templates. Add classes conditionally, merge class arrays, and output clean class attributes without messy inline logic, keeping Twig markup readable and maintainable in Laravel/PHP projects.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

zicht/twig-classes is a thin Twig extension that exposes the class-composition API of zicht/classes to templates. Architecturally it is a presentation-layer adapter, not a framework component: it registers a Twig extension, wraps a class-list builder, and emits a space-delimited class attribute string. That is a deliberately narrow surface, which is good — the blast radius of adopting or removing it is small.

The problem is contextual. Laravel is Blade-first, and this package assumes a Twig rendering pipeline. In a Laravel codebase that is only true if you have introduced rcrowe/twigbridge (or are running October CMS, which is Twig-native). So the real architecture question is not "is this extension well-built" but "do we have a Twig tier at all, and is it worth maintaining one to get conditional class composition?"

It is also worth noting that Laravel ships a native @class([...]) Blade directive as of 8.51, which covers the dominant use case here (conditional class lists from arrays/booleans). Any team already on modern Laravel has this capability for free.

Integration feasibility

Low. The signals are unambiguous: zero stars, zero dependents, a package score of 0. A Twig extension with no dependents means no downstream verification, no community bug reports, and no evidence anyone has run this against a current Twig release. zicht/classes as an upstream dependency inherits the same risk profile — an unmaintained transitive dependency in the render path of every page.

The opportunity: 8.32 figure should be read carefully. It measures whitespace in the ecosystem, not fitness for use. A high opportunity score on a zero-dependent package is usually a description of abandonment, not of untapped value. I would not present that number to a stakeholder as a positive signal without that framing.

Technical risk

  • Dependency rot (high). Composer constraints on both this package and zicht/classes likely predate Twig 3 and PHP 8.x. Installing into a current Laravel app is a plausible constraint-conflict failure before you write a line of code.
  • Unpatched render path (high). This code runs on every template render. No maintainer means no security response and no PHP minor-version fixes.
  • Silent failure mode (medium). Class composition helpers fail by emitting a wrong string, not by throwing. Regressions surface as broken styling in production, which is expensive to trace back to a templating dependency.
  • Bus factor (certain). There is no bus to factor. Any adoption is a fork-and-own commitment from day one.

Key questions

  1. Does the target application actually render Twig, or is this being evaluated for a Blade codebase? If Blade, the evaluation ends here.
  2. Which Twig major version is in play, and does this extension's constraint allow it?
  3. What does zicht/classes provide that implode(' ', array_filter($classes)) or Laravel's @class does not?
  4. Is there existing template code depending on this extension's exact output semantics (ordering, deduplication, null handling)? That determines whether a replacement must be bug-compatible.
  5. Who owns the fork, and what is the review cadence when Twig or PHP bumps?

Integration Approach

Stack fit

Only viable in one of two configurations: (a) Laravel + rcrowe/twigbridge, where the extension can be registered through the bridge's extension config; or (b) October CMS, where Twig extensions are a first-class plugin concern. In a standard Blade application, there is no natural insertion point and forcing one means standing up a Twig tier to justify a class-string helper — a poor trade.

Migration path

Recommended path is not to install this package. Instead:

  • Blade stacks: adopt the native @class directive. It covers conditional arrays, boolean keys, and nested arrays, and it is maintained by the framework.
  • Twig stacks: if the class-composition semantics are genuinely load-bearing, port them. The extension is small enough that a reimplementation as a single Twig extension class, tested against your Twig version, is a day of work and removes two unmaintained dependencies.
  • Genuine migration case: if you inherit a codebase already using this, the exit is mechanical — replace the Twig function/filter calls with macro or inline expressions, then delete both packages. Do it behind a template-level test harness so output diffs are visible.

Compatibility

Verify before anything else: PHP constraint against your runtime, Twig constraint against your installed major, PSR-4 autoload sanity, and whether zicht/classes pulls any further transitive weight. If any of these fail, the decision is made for you.

Sequencing

  1. Confirm Twig presence and version (kills or advances the evaluation).
  2. Inventory existing call sites and their expected output.
  3. Spike a replacement in the native idiom for that stack.
  4. Diff outputs across a representative template set.
  5. Only fall back to forking this package if output parity proves non-trivial — and if you do, vendor it under your own namespace with a named owner.

Operational Impact

Maintenance

Adoption converts an install into an ownership obligation. Both packages are effectively static code you now maintain. Budget for a fork, a CI job pinning the supported Twig/PHP matrix, and a documented owner. This is a real but bounded cost — roughly tens of lines of logic and a test suite — and it is entirely avoidable by using framework-native facilities.

Support

None available. No active maintainer, no issue triage, no documentation beyond the repository, and no dependents to consult. Internal teams will be the sole source of truth, which means onboarding material must be written rather than linked.

Scaling

Runtime cost is negligible — string composition on render, microseconds per template. Nothing here affects throughput or horizontal scaling. The scaling concern is organizational: every additional Twig-version bump becomes an internal migration task with no upstream to lean on.

Failure modes

  • Composer resolution failure on install or update (most likely, and loud — preferable).
  • Template render exception after a Twig upgrade (loud, caught in staging).
  • Silent class-string drift producing visual regressions (quiet, expensive, escapes to production).
  • Upstream repository deletion or Packagist abandonment, breaking clean builds (loud but disruptive; mitigate with a committed lockfile and a vendored fork).

Ramp-up

Trivial for individual contributors — the API surface is a function or filter returning a class string, learnable in minutes. The ramp-up cost sits with the maintainer, not the user: someone must own the fork, understand zicht/classes semantics well enough to patch them, and know the Twig extension registration path. That asymmetry (cheap to use, non-trivial to own) is exactly the profile that produces orphaned dependencies.

Verdict

Do not adopt. The capability is small, the ecosystem support is zero, and the modern equivalents — Laravel's @class for Blade, a short in-house extension for Twig — are strictly better on maintenance and risk with no meaningful loss of function. The only defensible reason to take this on is inheriting a codebase already committed to it, and even then the correct move is a planned exit rather than a deepening dependency.

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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings