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
String Template

String Template Laravel Package

nicmart/string-template

nicmart/string-template is a fast, lightweight PHP library for rendering templates with a clean, elegant syntax. It supports nested placeholders, variable transformations, custom renderers, and reusable engines—ideal for emails, notifications, and dynamic text generation.

View on GitHub
Deep Wiki
Context7

nicmart/string-template is a lightweight PHP library for rendering strings with placeholders. It offers a simple, readable syntax for injecting dynamic values into messages, emails, and other short templates without the overhead of a full templating engine. Templates stay framework-agnostic and easy to embed in existing PHP code.

  • Simple {placeholder} syntax for inline templates
  • Custom delimiters for flexible string formats
  • Resolves values from arrays and objects
  • Lightweight and framework-agnostic, with minimal dependencies
Frequently asked questions about String Template
How do I install nicmart/string-template in a Laravel application?
Install it with Composer using composer require nicmart/string-template and pin the version in composer.json. There is no Laravel service provider, so integration is manual and should stay explicit. Commit the lockfile and confirm the PHP constraint matches your Laravel runtime before using it.
Does nicmart/string-template support Laravel 11, Laravel 12, and PHP 8.3?
It is not a Laravel package and has no first-party Laravel integration, so there is no official Laravel version matrix to rely on. Verify the Composer PHP constraint and run CI against your target Laravel and PHP versions, especially PHP 8.2 and 8.3 or newer. If Laravel 11 or 12 and PHP 8.3 or newer support is unverified, treat it as a fork-or-replace decision.
How do arrays and objects work with {placeholder} substitution?
The package renders {placeholder} tokens by substituting values from arrays or objects, which makes it suitable for short messages and labels. Keep inputs simple and validate types at the boundary because the output should be treated as a plain string. Write characterization tests for object property resolution and array key lookup before relying on them in production.
Can I use nested keys in string templates?
The package advertises nested key support, but nesting semantics are the key functional risk area. Test how nested resolution handles missing intermediate keys, null values, repeated placeholders, and cyclic input. Bound or reject recursive structures in your adapter if the package does not enforce limits.
What happens when a placeholder is missing or null?
Missing-key and null behavior must be proven with tests because it is not safe to assume a specific policy. Wrap the package in an internal renderer that defines whether missing keys throw, log, or render empty. Apply the same policy consistently so templates fail predictably rather than silently.
Does nicmart/string-template escape output or prevent XSS?
Treat the package as a string interpolation utility, not an HTML escaper; output should still be escaped at the presentation boundary. Do not expose it directly to untrusted template authors or render its output as raw HTML. If you use it for user-facing text, enforce escaping in your adapter or Blade layer.
Can I change the placeholder delimiters?
Yes, the package supports custom delimiters, which helps when braces conflict with your content or other syntax. Document the chosen delimiters in your adapter so templates stay consistent across the codebase. Test malformed templates and delimiter edge cases before rolling it out broadly.
Should I use this instead of Blade or sprintf in Laravel?
No, it is not a substitute for Blade, Twig, or a full view layer, and it should not replace Blade for HTML views. It is reasonable only for short dynamic strings such as messages, labels, log fragments, and generated descriptions. Compare it with sprintf, strtr, or a small internal helper before adding a dependency.
How should I use nicmart/string-template safely in production?
Put it behind an internal interface such as App\Support\TemplateRenderer and prohibit direct package calls outside that adapter. Add contract tests for missing keys, nested placeholders, escaping, malformed templates, and type coercion. Pilot it in one non-critical feature with a clear rollback path, then migrate only simple string-assembly call sites.
Is nicmart/string-template maintained, and what are the alternatives?
The last release appears to be from October 2022 with very few dependents, so maintenance signal is weak even though the code surface is small and MIT-licensed. Alternatives include Blade for views, sprintf or strtr for simple substitutions, or a small in-house helper behind an interface. If you adopt it, pin the version and keep a fork-or-replace path open.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager