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

Text Wrap Laravel Package

treestoneit/text-wrap

A PHP text-wrapping utility for Laravel that breaks long strings into fixed-width lines. Wrap plain text or HTML safely, preserve whole words, and control line length for emails, reports, consoles, and any output where clean, readable formatting matters.

View on GitHub
Deep Wiki
Context7

Getting Started

The first step is not installing — it is confirming what you actually have. The package listing and the description.md describe a dependency-free PHP string-wrapping utility ("break long strings at a configurable width, multibyte safe, one call returns the wrapped string"), while the code and prior assessments describe a Laravel Nova field (Text subclass + service provider + compiled Vue asset) that renders long values wrapped instead of truncated in index/detail views. Those are different packages with different integration stories. Resolve that before you write a single line of code.

Read the repo in this order:

  1. composer.json — check require for laravel/nova and the PHP constraint, and look at extra.laravel.providers for auto-discovery. A laravel/nova: ^1.0 constraint tells you the field reading is correct and your Nova version is the blocker.
  2. src/ — if there is a class extending Laravel\Nova\Fields\Text, it is a Nova field. Note the exact namespace and class name; every example you find online (including the ones below) is a guess until you confirm it. If instead there is a static helper class with a wrap()-style method, it is a utility and the Nova instructions do not apply.
  3. The service provider — find Nova::script(...) / Nova::style(...) and any publishes(...) tag. This is what makes the field render.
  4. resources/js/field.js and dist/js/field.js — confirm whether only the compiled bundle shipped, and grep for v-html before trusting it in an admin panel.

Install:

composer require treestoneit/text-wrap

If auto-discovery does not fire, register the provider in config/app.php. If the provider publishes assets, run its tag:

php artisan vendor:publish --tag=text-wrap

First use case (Nova field reading): replace a truncating Text field on an index view where operators need to read notes, addresses, or error payloads in full.

// Verify namespace/class in src/ before using.
use TreeStoneIT\TextWrap\TextWrap;

public function fields(Request $request)
{
    return [
        TextWrap::make('Notes')->onlyOnIndex(),
    ];
}

Before any of that, run the one-day spike: stock Text with a display callback plus a CSS override in your Nova theme. If it passes, you are done and you never add the dependency.

use Laravel\Nova\Fields\Text;

Text::make('Notes', 'notes')
    ->displayUsing(fn ($value) => $value)
    ->onlyOnIndex();

First use case (utility reading): wrap fixed-width output, e.g. a plain-text report or console table, at a set width and verify multibyte behaviour with real UTF-8 data before trusting it.

Implementation Patterns

Use it as a display-only field, never as the edit affordance. The daily pattern is to separate forms from read views: a normal Textarea on forms, the wrapped field on index and detail.

use Laravel\Nova\Fields\Textarea;

TextWrap::make('Notes')->onlyOnIndex()->exceptOnForms(),
TextWrap::make('Notes')->onlyOnDetail(),
Textarea::make('Notes')->onlyOnForms()->alwaysShow(),

Keep the construction in one place. Because you will almost certainly swap the implementation later (theme CSS, displayUsing, or an in-repo field), centralise field creation so resource classes never change:

private function wrappedNotes(): TextWrap
{
    return TextWrap::make('Notes')
        ->onlyOnIndex()
        ->help('Long text is wrapped for readability.');
}

Keep the public shape (TextWrap::make(...) plus standard Nova modifiers like sortable(), rules(), onlyOnIndex()) stable across whatever replaces it.

Vendor it, do not require it from Packagist. Since the package is archived, treat adoption as forking. Put it under a local path and own the code:

{
  "repositories": [{ "type": "path", "url": "nova-components/text-wrap" }],
  "require": { "treestoneit/text-wrap": "*" }
}

Then rebuild the Vue component against your installed Nova toolchain rather than shipping the 2018 bundle. Pin the commit; otherwise a future composer update can pull the abandoned release back in.

Prefer the CSS route when the requirement is purely visual. Wrapping width in the Nova index table is a theme concern (white-space, word-break, max-width on the cell), not a package setting. A handful of selectors in your Nova theme's CSS is often the whole fix.

If you end up building it yourself, php artisan nova:field vendor/text-wrap gets you the same skeleton (PHP field class, provider, Vue component) in an afternoon and puts the upgrade path under your control.

Test the render, not just the resolution. A PHPUnit test that boots a resource and asserts the field resolves will pass while the UI is blank — the common failure is asset-pipeline drift, not an exception. Add a browser smoke test or an explicit manual QA step confirming the cell shows wrapped text.

Gotchas and Tips

  • Documentation and code disagree about what this package is. Confirm the Nova-field-vs-string-utility question before designing around it. Installing a Nova field to wrap console output, or a string helper to fix an admin table, both waste a day.
  • The version cliff is the first wall. Last release 2018-08-31: it predates Nova 3/4/5, Vue 3, Vite, and PHP 8. Composer resolution will likely fail outright against a modern laravel/nova constraint. Do not force-install past the resolver; a conflict is doing you a favour.
  • Archived means you own the risk. No security patches, no compat fixes, no upstream support, 10 stars, 0 dependents. Budget the fork as first-party code with a review, an owner, and a place in your dependency policy.
  • Silent failure mode: blank or unstyled cells. If the field renders as nothing or as plain text, check that the provider actually calls Nova::script()/Nova::style(), that dist/js/field.js exists at the registered path, and that you published assets. Then clear Laravel and Nova caches and republish.
  • Audit for stored XSS before it touches production. This renders admin-panel data. Grep the component for v-html and innerHTML; if user-controlled values are interpolated raw, switch to escaped interpolation. An archived admin field is an unattractive thing to explain in an incident review.
  • Verify the class name and $component string. Namespaces and component identifiers get renamed between forks and minor releases; use what is in src/, not what a blog post says.
  • Do not look for a width setting in the package. Line length in a Nova column is CSS. If lines overflow or wrap too aggressively, that is theme work, not configuration.
  • Out of scope by design: editing, expand/collapse, copy-to-clipboard, per-resource configuration, sanitisation. If those are requirements, you are building a field, not adopting one.
  • Do not require it alongside a fork. Path repos plus a Packagist requirement for the same name is a reliable way to get the abandoned release back after a composer update.
  • Decision framing: on Nova 1/2 with no upgrade in the next 12–18 months, this is a defensible stopgap. On Nova 3+, use displayUsing() or a theme override, and treat this repo as a reference implementation to read for structure — not a dependency to add.
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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib