rem42 / sylius-ui-show-bundle
Configuration-driven "show" pages for the Sylius Stack (Admin UI, Bootstrap Admin UI or Shadcn Admin UI, Twig Hooks) and any Symfony application.
Package info
github.com/rem42/sylius-ui-show-bundle
Type:symfony-bundle
pkg:composer/rem42/sylius-ui-show-bundle
Requires
- php: ^8.4
- psr/container: ^1.1 || ^2.0
- psr/event-dispatcher: ^1.0
- symfony/config: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/property-access: ^7.4 || ^8.0
- symfony/property-info: ^7.4 || ^8.0
- symfony/routing: ^7.4 || ^8.0
- symfony/translation: ^7.4 || ^8.0
- symfony/twig-bundle: ^7.4 || ^8.0
- symfony/type-info: ^7.4 || ^8.0
- twig/twig: ^3.12
Requires (Dev)
- doctrine/doctrine-bundle: ^2.13 || ^3.0
- doctrine/orm: ^3.3
- matthiasnoback/symfony-dependency-injection-test: ^6.1
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.5
- rem42/php-cs-fixer-config: ^4.1
- rem42/shadcn-admin-ui: ^1.0
- sylius/twig-hooks: ^0.14
- symfony/event-dispatcher: ^7.4 || ^8.0
- symfony/framework-bundle: ^7.4 || ^8.0
- symfony/yaml: ^7.4 || ^8.0
- vincentlanglet/twig-cs-fixer: ^4.1
Suggests
- doctrine/doctrine-bundle: Guesses fields from the Doctrine mapping (associations, column types, enums).
- rem42/shadcn-admin-ui: Tailwind CSS / shadcn admin theme matching the "shadcn" templates.
- sylius/bootstrap-admin-ui: Tabler/Bootstrap admin theme matching the "bootstrap" templates.
- sylius/twig-hooks: Renders shows automatically on Sylius Admin UI show pages and enables the Hook element.
Provides
None
Conflicts
None
Replaces
None
README
Configuration-driven "show" pages for the Sylius Stack and any Symfony application.
The Sylius Grid describes index pages in PHP; this bundle does the same for show pages. Describe tabs, cards,
columns and fields in a PHP class, and get it rendered with the markup of your admin UI (bootstrap theme for
sylius/bootstrap-admin-ui, shadcn theme for rem42/shadcn-admin-ui), automatically on your Sylius Admin UI show
pages through Twig Hooks.
Features
#[AsShow]attribute: invokable show definitions, just like#[AsGrid].- Sylius Stack integration: rendered automatically in the
sylius_admin.common.show.contentTwig Hook, configurable per resource. - Layouts: sections, responsive columns, cards, tabs, side navigation, details tables, datagrids, custom templates, Twig Hooks.
- 16 field types: string, number, boolean, datetime, enum, association, collection (table), badge, status, progress, image, icon, URL, file, sensitive, twig.
- Field guessing:
->add('name', 'createdAt', 'category')guesses types from Doctrine, PHP types and naming conventions. - Extensible: one template per element type, custom element types, custom guessers,
ShowBuildEvent, decoratable services.
Installation
composer require rem42/sylius-ui-show-bundle
// config/bundles.php (without Symfony Flex) Rem42\SyliusUiShow\Symfony\Rem42SyliusUiShowBundle::class => ['all' => true],
Quick start
namespace App\Show; use App\Entity\Book; use Rem42\SyliusUiShow\Attribute\AsShow; use Rem42\SyliusUiShow\Builder\ShowBuilder; use Rem42\SyliusUiShow\Model\Field\EnumField; use Rem42\SyliusUiShow\Model\Field\StringField; use Rem42\SyliusUiShow\Model\Layout\Card; use Rem42\SyliusUiShow\Model\Layout\Column; use Rem42\SyliusUiShow\Model\Layout\Section; #[AsShow(resourceClass: Book::class)] final class BookShow { public function __invoke(ShowBuilder $show, Book $book): void { $show->withChildren( Section::create('main')->withChildren( Column::create(8)->withChildren( Card::create('general') ->withChildren(StringField::create('description')->setMultiline()) ->add('title', 'author', 'publishedAt'), // types guessed ), Column::create(4)->withChildren( Card::create('status')->withChildren( EnumField::create('state')->setBadge(['published' => 'success', 'draft' => 'secondary']), ), ), ), ); } }
With the Sylius Stack, add a new Show() operation to your resource: the show is rendered on its admin show page.
Anywhere else, render it in Twig:
{{ rem42_sylius_ui_show(book) }}
Documentation
- Getting started
- Show definitions · Layout elements · Fields · Field guessing
- Admin UI & Twig Hooks integration
- Templates, labels & events
- Twig reference · Configuration reference
Development
make install # composer install make ci # ECS + PHPStan (level max) + PHPUnit make up # demo application showcasing every element, in both themes: # http://localhost:8080/admin/show/product/1 (bootstrap) # http://localhost:8080/shadcn/admin/show/product/1 (shadcn)
The demo application lives in tests/Application (App\Show\ProductShow is a good tour of the API). Each theme runs
in its own kernel (App\Kernel): bundles flagged with its name in config/bundles.php, configuration of
config/packages/{theme}/ and templates of templates/themes/{theme}/. The shadcn theme needs its assets:
make assets (Tailwind CSS build and importmap).
License
This bundle is released under the MIT License.