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
Smartcode Bundle

Smartcode Bundle Laravel Package

intracto/smartcode-bundle

Symfony bundle for generating unique, human-friendly codes such as vouchers, coupons, or activation keys. Configure character sets, length, and patterns, then generate codes in PHP services or directly in Twig templates.

View on GitHub
Deep Wiki
Context7

This bundle provides a way to generate software licenses with Symfony

Frequently asked questions about Smartcode Bundle
Can I use intracto/smartcode-bundle in a Laravel application?
No. It is a Symfony bundle that depends on symfony/http-kernel, symfony/dependency-injection and the Bundle/Extension lifecycle, none of which exist in Laravel, so composer requiring it into a Laravel app will not give you a working service. Laravel offers no equivalent bundle registration, extension load or compiler pass to hook into. The practical path is to bypass the bundle layer and use the underlying generator code directly, or fork the small amount of generation logic into your own package.
How do I install and configure SmartCodeBundle in a Symfony application?
Install it with composer require intracto/smartcode-bundle, then register the bundle in config/bundles.php for the environments where you need it. Set the code pattern, alphabet and length under the bundle configuration key, typically a file in config/packages, and autowire the provided generator service where you need codes. Clear the container cache after changing settings so the new parameters are picked up.
What is the difference between SmartCodeBundle and the underlying SmartCode library?
The bundle is mostly dependency-injection and configuration glue: it registers services, loads your pattern, alphabet and length settings, and exposes a service you can autowire. The actual generation and any signing logic live in the underlying library, which may be framework-agnostic and usable on its own. Confirm that split before adopting anything, because the reusable value is almost always the library rather than the Symfony layer.
How do I generate human-readable voucher codes in Laravel without the bundle?
Require the framework-agnostic core library, or copy its generator class, and bind it in a small Laravel service provider that reads alphabet and length from a config file. Expose it behind an interface such as CodeGenerator so consumers can be unit tested and the implementation swapped later. This is usually around a hundred lines of glue and keeps Symfony dependencies out of your application entirely.
Does it support Laravel 10 or 11 and PHP 8.2?
No Laravel version is supported, because the package targets Symfony rather than Laravel. Its last release was in March 2023, so its composer constraints may cap at older Symfony and PHP versions than your stack runs. If you bypass the bundle, only the core library's PHP and extension requirements still bind you, so check those against PHP 8.2 or newer before committing.
How do I configure code length, alphabet and pattern?
The bundle exposes settings for the character set, the total length and the pattern used to shape the output, which lets you produce grouped formats such as XXXX-XXXX-XXXX for printed vouchers. Choose an alphabet that excludes lookalike characters like 0 and O or 1, I and l if customers will read or type the codes. Treat any change as a format change and version it, since codes already issued must remain valid and verifiable.
Is intracto/smartcode-bundle actively maintained and safe for production?
The repository shows very little activity: roughly four stars, no known dependents and a last release in March 2023, which suggests an open-sourced internal utility rather than a maintained community package. There is no published security policy and no evidence of external review, so adopting it makes your team the de facto maintainer. That matters most if you use it for security-sensitive work such as signed license or activation payloads, where key handling and the verification path should be audited before shipping.
How do I avoid duplicate or ambiguous voucher and activation codes?
Collision risk depends on alphabet size and length, so size the format to your expected issuance volume rather than defaulting to eight characters. Always back the generator with a unique index on the code column and retry on conflict instead of trusting randomness alone. Also drop lookalike characters and normalise case before storing or looking codes up, so customers can type them back reliably.
Can I generate codes directly in Twig or Blade templates?
The bundle is designed to be reachable from Twig, which is convenient for rendering a voucher on a page. In Laravel the equivalent is a view composer or Blade directive backed by an injected generator service. Avoid generating codes inside templates because it makes output untestable and impossible to reproduce; generate in a service and pass the value to the view.
How should I test code generation and what are the alternatives?
Test format, alphabet and length as pure functions, inject a deterministic random source if the library allows it, and add an integration test that generates a large batch and asserts uniqueness against a real unique index. Because the Symfony layer is thin, most of the value is in testing your own wrapper and the storage or signing boundary. Alternatives include keeping the core library behind your own interface, or writing a small generator with random_int plus a database unique constraint, which removes the third-party maintenance risk entirely.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections