uxf / page-builder
UXF Page Builder - CMS page/section versioning system
Requires
- php: ^8.4
- doctrine/collections: ^2.0 || ^3.0
- doctrine/dbal: ^4.0
- doctrine/orm: ^3.0
- ramsey/uuid: ^4.0
- ramsey/uuid-doctrine: ^2.0
- symfony/config: ^8.0
- symfony/console: ^8.0
- symfony/dependency-injection: ^8.0
- symfony/framework-bundle: ^8.0
- symfony/http-kernel: ^8.0
- symfony/lock: ^8.0
- symfony/routing: ^8.0
- symfony/security-bundle: ^8.0
- symfony/security-core: ^8.0
- symfony/validator: ^8.0
- uxf/core: 3.87.2
- uxf/datagrid: 3.87.2
- uxf/hydrator: 3.87.1
Requires (Dev)
None
Suggests
- uxf/cms: for automatic crontab generation via bin/console uxf:cron-gen (#[CronJob] on PublishScheduledCommand)
Provides
None
Conflicts
None
Replaces
None
README
Symfony bundle for pages built from sections: pages and their revisions, sections and shared sections, publishing and scheduled publishing, previews, the REST API for the backoffice editors and the public read API.
The bundle holds no section types. The project defines them (request class with #[SectionField] attributes, a
SectionContentMapper and a response) and registers its layouts, groups and languages in a registry JSON.
Frontend counterparts: @uxf/page-builder (contract), @uxf/page-builder-cms (backoffice editors) and
@uxf/page-builder-web (renderer, editor iframe, previews).
Install in a project
composer require uxf/page-builder
The bundle needs uxf/core, uxf/datagrid, symfony/security-bundle and a Symfony security
setup that resolves Symfony\Component\Security\Core\User\UserInterface to a concrete user
entity (e.g. via uxf/security or uxf/cms).
Setup
Register the bundle in config/bundles.php:
UXF\PageBuilder\UXFPageBuilderBundle::class => ['all' => true],
Import its routes in config/routes.php:
$routingConfigurator->import('@UXFPageBuilderBundle/config/routes.php');
The routes are /api/cms/page-builder/* (editors, admin only) and /api/app/page-builder/* (public read API).
Configuration
$containerConfigurator->extension('uxf_page_builder', [
// role allowed to publish, unpublish and archive; other admins edit drafts only
'publisher_role' => 'ROLE_ROOT',
// TypeScript file `page-builder:schema-gen` writes the section schemas into
'schema_destination' => '%kernel.project_dir%/../packages/page-builder-project/src/section-schemas.ts',
// the project's registry JSON (layouts, groups, section types, languages); null = nothing is restricted
'registry' => '%kernel.project_dir%/config/page-builder/registry.json',
]);
Add the bundle sources to the hydrator map sources, so the section requests and the bundle DTOs share one map:
$containerConfigurator->extension('uxf_hydrator', [
'map_sources' => [
__DIR__ . '/../../src',
__DIR__ . '/../../vendor/uxf/page-builder/src',
],
]);
Database
The bundle ships no migrations. Generate them in the project after installing or upgrading the bundle:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
Generated clients
The backoffice client comes from the project's uxf_gen hook area. Include the page builder paths in its pattern:
'hook' => [
'areas' => [
'admin' => [
'path_pattern' => '/^\/api\/(app\/page-builder|admin|cms)/',
'output' => 'swr',
'destination' => '%kernel.project_dir%/../backoffice/src/generated/api.ts',
],
],
],
Section schemas for the editors: bin/console page-builder:schema-gen (run it from the project's make gen).
Scheduled publishing
bin/console page-builder:publish-scheduled publishes approved page and shared section revisions whose scheduled time has passed. It carries
#[CronJob('* * * * *')] (uxf/cms), an optional integration: when uxf/cms is installed, it lands in the project's
crontab once the bundle sources are among the cron sources:
$containerConfigurator->extension('uxf_cms', [
'cron' => [
'sources' => [__DIR__ . '/../../src', __DIR__ . '/../../vendor/uxf/page-builder/src'],
'destinations' => [__DIR__ . '/../../crontab'],
],
]);
Then run bin/console uxf:cron-gen and run the crontab with supercronic. The command takes a lock (symfony/lock),
so overlapping runs skip.
Without uxf/cms, add the command to the project's crontab by hand instead:
* * * * * bin/console page-builder:publish-scheduled
License
MIT