This guide covers installing Password Toggle Bundle in a Symfony application.
- PHP >= 8.2, < 8.6
- Symfony ^7.0 || ^8.0
- symfony/form, symfony/framework-bundle, symfony/twig-bundle
- symfony/ux-icons ^2.0 || ^3.0 and symfony/http-client (matching your Symfony major) — required for the default Twig widget (
ux_icon()withtabler:eye/tabler:eye-off). The bundle only lists them assuggest; Symfony Flex installs both automatically via the recipe. Without Flex:
composer require symfony/ux-icons symfony/http-client
php bin/console ux:icons:lockcomposer require nowo-tech/password-toggle-bundleUse a constraint such as ^1.0 to stay on the current major version.
If you use Symfony Flex, the bundle is registered automatically, configuration is created at config/packages/nowo_password_toggle.yaml, symfony/ux-icons and symfony/http-client are added, and tabler icons are copied under assets/icons/tabler/. Run after install:
php bin/console ux:icons:lockWith UX Icons 3.x, the command scans Twig templates (no icon names as arguments). Use --force to overwrite existing local SVGs.
- Register the bundle in
config/bundles.php:
<?php
return [
// ...
Nowo\PasswordToggleBundle\NowoPasswordToggleBundle::class => ['all' => true],
];-
Add the form theme so the password toggle widget is used. In
config/packages/twig.yamladd the bundle's widget toform_themes:twig: form_themes: - '@NowoPasswordToggleBundle/Form/toggle_password_widget.html.twig'
You can override this template in your app by placing a copy in
templates/bundles/NowoPasswordToggleBundle/Form/toggle_password_widget.html.twig. See USAGE.md. -
Install icon dependencies (required for the default widget):
composer require symfony/ux-icons symfony/http-client
Add
config/packages/ux_icons.yaml(or equivalent):ux_icons: iconify: enabled: true ignore_not_found: '%kernel.debug%'
Copy tabler SVGs under
assets/icons/tabler/(see the Flex recipe in.symfony/recipes/.../1.2.3/assets/icons/tabler/) or lock icons after install:php bin/console ux:icons:lock
-
Create configuration (optional). Create
config/packages/nowo_password_toggle.yamlwith your preferred defaults. See CONFIGURATION.md for all options. -
Publish optional CSS (if you use the legacy stylesheet instead of your own styles):
php bin/console assets:install
<link rel="stylesheet" href="{{ asset('css/toggle_password.css', 'nowo_password_toggle') }}">
If your app uses Symfony AssetMapper, the bundle registers the
nowo_password_toggleasset package. Runassets:installonce socss/toggle_password.cssis published topublic/bundles/nowopasswordtoggle/.
If symfony/ux-icons or symfony/http-client is not installed:
- The bundle does not throw during
cache:warmupor container compile. - A one-time warning is logged (Monolog channel
nowo_password_togglewhen Monolog is present) with the exactcomposer requireandux:icons:lockcommands. - The default widget degrades gracefully:
- dev: toggle works; a small
[icons missing]hint is shown instead of icons. - prod: toggle works without icons (no uncaught exception from
ux_icon()).
- dev: toggle works; a small
To restore icons, install both packages and run php bin/console ux:icons:lock, or override the form theme to avoid ux_icon().