First, configure the repository in your application's composer.json
:
{
"repositories": [
{
"name": "enterprise-tooling-for-symfony/webui-bundle:path",
"type": "path",
"url": "../webui-bundle",
"options": {
"symlink": true
}
}
]
}
Then require the bundle:
composer require enterprise-tooling-for-symfony/webui-bundle:dev-master
The bundle should be automatically registered via Symfony Flex. If not, add it manually to your config/bundles.php
:
<?php
return [
// ... other bundles
EnterpriseToolingForSymfony\WebuiBundle\WebuiBundle::class => ['all' => true],
];
Add the bundle's routes to your config/routes.yaml
:
webui:
resource: '@WebuiBundle/config/routes.yaml'
Import the bundle's CSS in your main application CSS file (assets/styles/app.css
):
@import url("../../vendor/enterprise-tooling-for-symfony/webui-bundle/assets/styles/webui.css");
Replace your local TailwindCSS configuration with the one from the bundle, in file tailwind.config.js
:
import WebuiTailwindConfig from './vendor/enterprise-tooling-for-symfony/webui-bundle/tailwind.config.js';
/** @type {import('tailwindcss').Config} */
module.exports = WebuiTailwindConfig;
The bundle's JavaScript is automatically configured via the importmap. Verify that your importmap.php
includes:
<?php
return [
// ...
'@enterprise-tooling-for-symfony/webui' => [
'path' => './vendor/enterprise-tooling-for-symfony/webui-bundle/assets/index.js',
],
];
In your application's assets/bootstrap.ts
, bootstrap the WebUI client-side code with your Stimulus App:
import { webuiBootstrap } from "@enterprise-tooling-for-symfony/webui";
const app = startStimulusApp();
webuiBootstrap(app);
Create a service that extends AbstractMainNavigationService
. For example:
<?php
namespace App\Common\Presentation\Service;
use EnterpriseToolingForSymfony\WebuiBundle\Entity\MainNavigationEntry;
use EnterpriseToolingForSymfony\WebuiBundle\Service\AbstractMainNavigationService;
class MainNavigationPresentationService extends AbstractMainNavigationService
{
public function getPrimaryMainNavigationEntries(): array
{
return [
// Your navigation entries in the form of MainNavigationEntry objects
];
}
protected function getSecondaryMainNavigationEntries(): array
{
return [
// Your navigation entries in the form of MainNavigationEntry objects
];
}
public function getTertiaryMainNavigationEntries(): array
{
return [
// Your navigation entries in the form of MainNavigationEntry objects
];
}
}
The bundle will automatically detect your navigation service implementation and use it for rendering the navigation components.
To use the navigation components, extend the bundle's base template in your application's base template:
{% extends '@Webui/base_appshell.html.twig' %}
Or include the navigation components manually:
<div {{ stimulus_controller('webuiMainNavigation') }} class="min-h-screen">
{{ component('webui|main_navigation|small_viewport|appshell') }}
{{ component('webui|main_navigation|large_viewport|appshell') }}
</div>
When working in development mode, your app provides a living styleguide at /living-styleguide
to preview available components and styles.