## Getting Started
### Minimal Setup
1. **Installation**:
```bash
composer require artgris/page-bundle
php bin/console doctrine:schema:update --force
Configure Dependencies:
Knp\DoctrineBehaviors\DoctrineBehaviorsBundle to config/bundles.php:
return [
// ...
Knp\DoctrineBehaviors\DoctrineBehaviorsBundle::class => ['all' => true],
];
locale parameter in config/services.yaml:
parameters:
locale: 'en'
Integrate with EasyAdmin:
ArtgrisPage to DashboardController:
use Artgris\Bundle\PageBundle\Entity\ArtgrisPage;
public function configureMenuItems(): iterable {
yield MenuItem::linkToCrud('Page', 'fa fa-file-alt', ArtgrisPage::class);
}
First Use Case:
title) and assign it to a route (e.g., App\Controller\MainController::index).{{ blok('title') }}
Page Management:
route selector in the page configuration.Block Rendering:
{{ blok('block-tag') }} {# Retrieves a block by tag #}
{% for blok in bloks() %}
{{ blok }}
{% endfor %}
{% for blok in page('homepage') %}
{{ blok }}
{% endfor %}
{% for blok in regex_array_blok('^sidebar-*') %}
{{ blok }}
{% endfor %}
Custom Form Types:
PageFromInterface to create custom block types (e.g., TinyMCE):
namespace App\Form;
use Artgris\Bundle\PageBundle\Form\Type\PageFromInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
class CustomType extends AbstractType implements PageFromInterface {
public function getParent() { return TextareaType::class; }
public static function getRenderType($value) { return $value . '<hr>'; }
}
config/packages/artgris_page.yaml:
artgris_page:
types:
- custom: 'App\Form\CustomType'
Translation Support:
a2lix_translation_form in config/packages/a2lix_translation_form.yaml:
a2lix_translation_form:
locales: [fr, en]
default_locale: fr
Debugging:
EasyAdmin Assets:
Add JavaScript/CSS for custom form types (e.g., TinyMCE) in DashboardController:
public function configureAssets(): Assets {
return Assets::new()
->addJsFile('js/tinymce5/tinymce.min.js');
}
Caching:
bloks() or blok().page() or regex functions sparingly (they bypass cache and query the DB each time).Data Export/Import:
php bin/console artgris:page:export
php bin/console artgris:page:import
php bin/console artgris:page:import --remove-deviants
Route Selector Misconfiguration:
hide_route_form: true is set in artgris_page.yaml, blocks won’t be linked to routes. Use this only for single-page sites.Cache Invalidation:
bloks() or blok()) are not updated until the cache is cleared or the page is refreshed.page() or regex functions for dynamic content if performance is critical.Translation Quirks:
a2lix_translation_form is properly configured. Missing locales may cause errors when editing translatable blocks.Doctrine Behaviors:
Knp\DoctrineBehaviorsBundle to bundles.php will break the schema update and block functionality.Custom Type Rendering:
getRenderType() in custom form types to control how blocks are rendered. Forgetting this may result in raw data being output.Debug Bar:
Database Schema:
php bin/console doctrine:schema:update --dump-sql to verify schema changes after installation.YAML Import Errors:
--ignore-names to skip name mismatches during import:
php bin/console artgris:page:import --ignore-names
--remove-deviants to delete blocks with mismatched types:
php bin/console artgris:page:import --remove-deviants
EasyAdmin Compatibility:
EasyAdminBundle version is compatible (e.g., ^4.0 for PageBundle 4.x). Check the release notes.Custom Block Types:
PageFromInterface to create reusable block types (e.g., rich text editors, custom inputs).Override Twig Functions:
Event Listeners:
artgris.page.pre_save or artgris.page.post_save events to modify page/block data before/after saving.Form Themes:
artgris_page template in your project’s templates/ directory.Validation:
---
How can I help you explore Laravel packages today?