### Setup Virtual Environment for Documentation Source: https://github.com/sulu/sulu-docs/blob/3.x/README.md Commands to create and activate a Python virtual environment and install necessary dependencies for building the documentation. ```bash python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` ```fish python3 -m venv venv source venv/bin/activate.fish pip install -r requirements.txt ``` -------------------------------- ### Install Varnish on Ubuntu/Debian Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/caching-with-varnish.md Installs the Varnish caching proxy daemon using the apt package manager. ```bash apt-get install varnish ``` -------------------------------- ### Install varnish-modules for XKey Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/caching-with-varnish.md Package installation command for varnish-modules, which provides XKey support for Varnish cache invalidation. This is an alternative to building from source. ```bash apt-get install varnish-modules ``` -------------------------------- ### Example Repository for SmartContentProvider Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/smart-content-data-provider.md Implement findByFilters and countByFilters methods in your repository to query and count entities based on provided filters. This example demonstrates applying tags, sorting, and pagination. ```php createQueryBuilder('example'); // Apply filters (tags, categories, types, etc.) if (isset($filters['tags']) && !empty($filters['tags'])) { $queryBuilder->join('example.tags', 'tag') ->andWhere('tag.id IN (:tags)') ->setParameter('tags', $filters['tags']); } // Apply sorting foreach ($sortBys as $sortBy) { $queryBuilder->addOrderBy('example.' . $sortBy['column'], $sortBy['direction']); } // Apply pagination if (isset($params['limit'])) { $queryBuilder->setMaxResults($params['limit']); } if (isset($params['offset'])) { $queryBuilder->setFirstResult($params['offset']); } return $queryBuilder->getQuery()->getResult(); } public function countByFilters(array $filters): int { $queryBuilder = $this->createQueryBuilder('example') ->select('COUNT(example.id)'); // Apply same filters as findByFilters if (isset($filters['tags']) && !empty($filters['tags'])) { $queryBuilder->join('example.tags', 'tag') ->andWhere('tag.id IN (:tags)') ->setParameter('tags', $filters['tags']); } return (int) $queryBuilder->getQuery()->getSingleScalarResult(); } } ``` -------------------------------- ### Install PHP-FFmpeg Bundle Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/video-preview-images.md Installs the required PHP-FFmpeg library via Composer to enable video processing capabilities within the Sulu project. ```bash composer require php-ffmpeg/php-ffmpeg ``` -------------------------------- ### Install VIPS Adapter Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/media/imagine-adapter.md Commands to install the VIPS extension and its required PHP library via Composer on macOS and Linux. ```bash # macOS brew install pkg-config brew install vips pecl install vips composer require rokka/imagine-vips # Linux apt-get install libvips-dev composer require rokka/imagine-vips ``` -------------------------------- ### Install Production Dependencies Source: https://github.com/sulu/sulu-docs/blob/3.x/book/deployment.md Install Composer dependencies for production, optimizing autoloading and classmaps. ```bash composer install --no-dev --optimize-autoloader --classmap-authoritative ``` -------------------------------- ### Start Development Web Server Source: https://github.com/sulu/sulu-docs/blob/3.x/book/getting-started.md Launches the local PHP development server to serve both the administration interface and the website frontend. ```bash php -S localhost:8000 -t public/ config/router.php ``` -------------------------------- ### Build Assets with NPM Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/webpack-encore.md Installs dependencies and compiles the assets for the website. ```bash npm install npm run build ``` -------------------------------- ### Install Imagick Adapter Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/media/imagine-adapter.md Commands to install the Imagick extension and its dependencies on macOS and Linux systems. ```bash # macOS brew install imagemagick pecl install imagick # Linux apt-get install libmagickwand-dev apt-get install php8.3-imagick ``` -------------------------------- ### Setup Database and Build Environment Source: https://github.com/sulu/sulu-docs/blob/3.x/book/getting-started.md Configures the database connection via environment variables and populates the database with default Sulu data using the build command. ```bash DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7 php bin/adminconsole sulu:build dev ``` -------------------------------- ### Configure Redis Cache for Preview Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/preview/index.md Configuration examples for using Redis as the cache adapter for the preview system, including framework cache settings. ```yaml sulu_preview: cache_adapter: "cache.adapter.redis" framework: cache: default_redis_provider: 'redis://localhost' app: cache.adapter.redis ``` -------------------------------- ### Implement SmartContentProviderInterface Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/smart-content-data-provider.md Create a SmartContentProvider by implementing the `SmartContentProviderInterface`. This example demonstrates a basic implementation with configuration for tags, categories, limit, pagination, sorting, types, and views. ```php enableTags() ->enableCategories() ->enableLimit() ->enablePagination() ->enableSorting([ ['column' => 'created', 'title' => 'sulu_admin.created'], ['column' => 'title', 'title' => 'sulu_admin.title'], ]) ->enableTypes([ ['type' => 'example-type-1', 'title' => 'app.example_type_1'], ['type' => 'example-type-2', 'title' => 'app.example_type_2'], ]) ->enableView('app.example_edit_form', ['id' => 'id']) ->getConfiguration(); } public function countBy(array $filters, array $params = []): int { return $this->repository->countByFilters($filters); } /** * @return array */ public function findFlatBy(array $filters, array $sortBys, array $params = []): array { $entities = $this->repository->findByFilters($filters, $sortBys, $params); return array_map( static fn (Example $entity) => [ 'id' => (string) $entity->getId(), 'title' => $entity->getTitle(), ], $entities, ); } public function getType(): string { return 'examples'; } public function getResourceLoaderKey(): string { return ExampleResourceLoader::RESOURCE_LOADER_KEY; } } ``` -------------------------------- ### Build Admin Interface with Docker Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/build-admin-frontend.md Manually builds the administration interface using a Node.js Docker container. This involves starting a container, mapping the project directory, cleaning up old build artifacts, and then installing dependencies and running the build script within the container. ```bash docker run --rm --interactive --tty --volume ${PWD}:/var/project node:24.11.1 /bin/bash cd /var/project rm -rf assets/admin/node_modules && rm -rf vendor/sulu/sulu/node_modules && rm -rf vendor/sulu/sulu/src/Sulu/Bundle/*/Resources/js/node_modules rm -rf assets/admin/package-lock.json && rm -rf vendor/sulu/sulu/package-lock.json && rm -rf vendor/sulu/sulu/src/Sulu/Bundle/*/Resources/js/package-lock.json cd /var/project/assets/admin npm install npm run build ``` -------------------------------- ### Build Admin Interface Locally with npm Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/build-admin-frontend.md Manually builds the administration interface on a local machine using Node.js and npm. This method requires Node.js to be installed locally. It involves cleaning up previous build artifacts and then installing dependencies and running the build script. ```bash cd /var/project rm -rf assets/admin/node_modules && rm -rf vendor/sulu/sulu/node_modules && rm -rf vendor/sulu/sulu/src/Sulu/Bundle/*/Resources/js/node_modules rm -rf assets/admin/package-lock.json && rm -rf vendor/sulu/sulu/package-lock.json && rm -rf vendor/sulu/sulu/src/Sulu/Bundle/*/Resources/js/package-lock.json cd /var/project/assets/admin npm install npm run build ``` -------------------------------- ### Install GD Adapter in Docker Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/media/imagine-adapter.md Installs the GD extension and its required system libraries within a Docker environment. This ensures support for various image formats like JPEG, PNG, and WebP. ```bash RUN apt-get update && apt-get install -y libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp && docker-php-ext-install -j$(nproc) gd ``` -------------------------------- ### Bootstrap Sulu Project Source: https://github.com/sulu/sulu-docs/blob/3.x/book/getting-started.md Uses Composer to create a new project based on the Sulu skeleton. This command initializes the directory structure and installs necessary dependencies. ```bash composer create-project sulu/skeleton my-project -n ``` -------------------------------- ### Event Template Example Source: https://github.com/sulu/sulu-docs/blob/3.x/book/templates.md This is a base 'Event' template defining properties like 'startDate'. It serves as a source for inclusion in other templates. ```xml ``` -------------------------------- ### Install and Configure Two-Factor Authentication in Sulu Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/security/index.md This section outlines the steps to enable Two-Factor Authentication (2FA) in Sulu using the scheb/2fa package. It involves installing the necessary composer packages, configuring the admin firewall in security.yaml to handle 2FA requests, and setting up email and trusted device providers in scheb_2fa.yaml. Finally, it includes adding the 2FA check route. ```bash composer require scheb/2fa-bundle scheb/2fa-email scheb/2fa-trusted-device ``` ```yaml security: # ... access_control: # ... - { path: ^/admin/login$, roles: PUBLIC_ACCESS } - { path: ^/admin/2fa, role: PUBLIC_ACCESS } # ... firewalls: # ... admin: # ... logout: path: sulu_admin.logout two_factor: prepare_on_login: true prepare_on_access_denied: true check_path: 2fa_login_check_admin authentication_required_handler: sulu_security.two_factor_authentication_required_handler success_handler: sulu_security.two_factor_authentication_success_handler failure_handler: sulu_security.two_factor_authentication_failure_handler ``` ```yaml scheb_two_factor: email: enabled: true sender_email: "%env(SULU_ADMIN_EMAIL)%" trusted_device: enabled: true ``` ```yaml # For Admin: 2fa_login_check_admin: path: /admin/2fa_check ``` -------------------------------- ### Listen for an Event Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/activity.md Example of how to listen for and react to events dispatched by the ActivityBundle, such as sending an email when a page is created. ```APIDOC ## Listen for an Event ### Description Listen for specific events dispatched by the ActivityBundle to react to application changes. This example shows sending an email when a page with a specific template is created. ### Method Event Listener ### Endpoint N/A (Event Listener) ### Parameters #### Event - **PageCreatedEvent** (Sulu\Bundle\PageBundle\Domain\Event\PageCreatedEvent) - The event triggered when a page is created. ### Request Example ```php 'sendPageCreatedMail', ]; } public function sendPageCreatedMail(PageCreatedEvent $event): void { if ('product' === $event->getPageDocument()->getStructureType()) { return; } $email = (new Email()) ->from('from@example.com') ->to('to@example.com') ->subject('New product page created') ->text('Page Title: ' . $event->getPageDocument()->getTitle()); $this->mailer->send($email); } } ``` ``` -------------------------------- ### Configure HttpCache Features Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/http_cache.md Provides YAML configuration examples for enabling debug headers and tag-based cache invalidation in the SuluHttpCache bundle. ```yaml sulu_http_cache: debug: enabled: true tags: enabled: true ``` -------------------------------- ### Define Form Metadata in XML Source: https://github.com/sulu/sulu-docs/blob/3.x/book/extend-admin.md Example of a form configuration XML file. It defines the form key and individual properties with their respective types, validation rules, and UI parameters. ```xml
event_details sulu_admin.name app.start_date app.end_date
``` -------------------------------- ### Twig Integration for Single Media Selection Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/single_media_selection.md Examples demonstrating how to use the single media selection in Twig templates for displaying images and documents, including handling display options. ```APIDOC ## Twig Integration ### Basic Image Display ```twig {% set image = content.image %} {{ image.description|default(image.title) }} ``` ### Displaying with Display Options If your property defines `displayOptions`, you can access the selected `displayOption` via `view..displayOptions`: ```twig {% set image = content.image %}
{{ image.description|default(image.title) }}
``` ### Document Download Link If you want to provide a link for downloading a document, you can use `.url` attribute or wrap it with the [sulu_get_media_url](../twig-extensions/functions/sulu_get_media_url.md) to control which [disposition header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) the target url should use: ```twig {{ document.title }} ``` ### NOTE on Image Rendering For performance reasons you should never use the `.url` attribute to render `images` on your website. Always use `thumbnails` and [configure your image formats](../../book/image-formats.md) to provide fast optimized cacheable images. ``` -------------------------------- ### Get Navigation with Custom Properties Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/twig-extensions/functions/sulu_page_navigation_root_flat.md This example demonstrates how to fetch navigation items and specify custom properties like 'excerptTitle' and 'uuid' for more detailed page information. It allows for flexible display of page titles using defaults. ```twig {% for item in sulu_page_navigation_root_flat('main', 2, { 'title': 'title', 'url': 'url', 'excerptTitle': 'excerpt.title', 'uuid': 'object.resource.uuid', }) %} {{ item.excerptTitle|default(item.title) }} {% endfor %} ``` -------------------------------- ### Build Development Environment and Data Source: https://github.com/sulu/sulu-docs/blob/3.x/book/deployment.md Run this command once to set up the database, create fixtures, and generate search indexes for development. ```bash php bin/console sulu:build dev ``` -------------------------------- ### Booting Kernel in Website Context for Integration Tests Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/test.md Demonstrates how to extend KernelTestCase to boot the Sulu kernel specifically in the website context, ensuring access to website-only services. ```php namespace App\Tests\Integration\Service; use Sulu\Bundle\TestBundle\Testing\KernelTestCase; use Sulu\Component\HttpKernel\SuluKernel; class NewsletterGeneratorTest extends KernelTestCase { public function testSomething() { self::bootKernel([ 'sulu.context' => SuluKernel::CONTEXT_WEBSITE ]); } } ``` -------------------------------- ### Initialize New Sulu Project and Migrate Git History Source: https://github.com/sulu/sulu-docs/blob/3.x/upgrades/upgrade-1.6-2.0.md This command sequence creates a fresh project instance using the Sulu skeleton and preserves the existing git history by moving the .git directory. It is the recommended starting point for a clean migration. ```bash composer create-project sulu/skeleton cp /.git ``` -------------------------------- ### Route Property Configuration Example Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/route.md This XML snippet shows how to configure a 'route' property type. It includes parameters for mode and route schema, demonstrating dynamic URL generation using the 'sulu.rlp.part' tag. ```xml URL ``` -------------------------------- ### GET /admin/api/events Source: https://github.com/sulu/sulu-docs/blob/3.x/book/extend-admin.md Retrieves a paginated list of all events. ```APIDOC ## GET /admin/api/events ### Description Retrieves a paginated list of all events available in the system. ### Method GET ### Endpoint /admin/api/events ### Response #### Success Response (200) - **items** (array) - List of event objects - **page** (integer) - Current page number - **limit** (integer) - Items per page - **total** (integer) - Total count of events #### Response Example { "items": [{"id": 1, "name": "Example Event"}], "page": 1, "limit": 10, "total": 1 } ``` -------------------------------- ### Clone Repository for Initial Deployment Source: https://github.com/sulu/sulu-docs/blob/3.x/book/deployment.md Use this command to clone your application's repository into the desired deployment directory. ```bash cd /var/www git clone example.org cd example.org ``` -------------------------------- ### GET /admin/api/events/{id} Source: https://github.com/sulu/sulu-docs/blob/3.x/book/extend-admin.md Retrieves details for a specific event. ```APIDOC ## GET /admin/api/events/{id} ### Description Fetches the details of a single event by its unique identifier. ### Method GET ### Endpoint /admin/api/events/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the event ### Response #### Success Response (200) - **id** (integer) - Event ID - **name** (string) - Event name ``` -------------------------------- ### Execute Bundle Tests with runtests Source: https://github.com/sulu/sulu-docs/blob/3.x/developer/contributing/test-your-code.md Uses the runtests script to initialize the database and execute bundle tests. This is the standard way to run tests in a continuous integration or local development environment. ```bash ./bin/runtests -i -C ``` ```bash ./bin/runtests -a ``` -------------------------------- ### sulu_category_url_clear Function Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/twig-extensions/functions/sulu_category_url_clear.md Clears a specified GET parameter from the current URL. ```APIDOC ## sulu_category_url_clear ### Description Returns the current URL with a specified GET parameter removed. ### Method N/A (This appears to be a client-side JavaScript function or a Twig function, not a REST API endpoint) ### Endpoint N/A ### Parameters #### Query Parameters - **categoryParameter** (string) - Optional - The name of the GET parameter to remove from the URL. ### Request Example N/A ### Response #### Success Response - **URL** (string) - The current URL with the specified GET parameter removed. #### Response Example N/A ### See Also - [sulu_category_url](sulu_category_url.md#sulu-category-url) - [sulu_category_url_append](sulu_category_url_append.md#sulu-category-url-append) - [sulu_category_url_remove](sulu_category_url_remove.md#sulu-category-url-remove) - [sulu_category_url_toggle](sulu_category_url_toggle.md#sulu-category-url-toggle) ``` -------------------------------- ### sulu_category_url_append Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/twig-extensions/functions/sulu_category_url_append.md Appends a category to the current URL's GET parameters. ```APIDOC ## sulu_category_url_append ### Description Returns current URL and appends the given category to the GET parameter. ### Method Not applicable (this appears to be a function call within a templating language or PHP). ### Endpoint Not applicable. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - **category** (array) - Serialized Category instance to determine value. - **categoryParameter** (string) - Optional. The name of the category parameter (defaults to 'category'). ### Returns string - The current URL with the given category appended in the categories parameter. ### See also - [sulu_category_url](sulu_category_url.md#sulu-category-url) - [sulu_category_url_remove](sulu_category_url_remove.md#sulu-category-url-remove) - [sulu_category_url_toggle](sulu_category_url_toggle.md#sulu-category-url-toggle) - [sulu_category_url_clear](sulu_category_url_clear.md#sulu-category-url-clear) ``` -------------------------------- ### Configure Category Selection with Parameters Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/category_selection.md Demonstrates how to pass request parameters to the category selection tree, such as defining a rootKey to filter categories. ```xml Category Selection ``` -------------------------------- ### GET /property/snippet_selection Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/snippet_selection.md Configuration and usage documentation for the snippet_selection property type. ```APIDOC ## Snippet Selection Property ### Description Allows to select an arbitrary number of snippets. Snippets are reusable pieces of content that can be included on multiple pages. The assigned snippets will be saved as an array of references. ### Parameters #### Configuration Parameters - **types** (string) - Optional - If set, only snippets of the type can be selected. - **default** (string) - Optional - If set, the default snippet of the given area will be used as fallback. - **item_disabled_condition** (string) - Optional - JEXL expression to disable specific items. - **allow_deselect_for_disabled_items** (bool) - Optional - Defines if disabled items can be deselected (Default: true). - **sortable** (bool) - Optional - Defines if items can be sorted (Default: true). - **min** (string) - Optional - Minimum number of selected snippets. - **max** (string) - Optional - Maximum number of selected snippets. ### XML Configuration Example ```xml Snippets ``` ### Twig Rendering Example ```twig {% for snippet in content.snippets %} {{ snippet.title }} {% endfor %} ``` ``` -------------------------------- ### Configure Webspace Security System (XML) Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/security/security_system.md This XML snippet demonstrates how to define a security system for a webspace. It shows the basic configuration for a 'Website' system and how to enable permission checks with a specific system like 'example'. ```xml Website ``` ```xml example ``` -------------------------------- ### GET /admin/api/pages/{uuid} Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/page/content-repository.md Retrieves a specific page by its UUID from the content repository. ```APIDOC ## GET /admin/api/pages/{uuid} ### Description Fetches details for a single page identified by its UUID. ### Method GET ### Endpoint /admin/api/pages/{uuid} ### Parameters #### Path Parameters - **uuid** (string) - Required - The unique identifier of the page. #### Query Parameters - **locale** (string) - Required - The localization code. - **webspace** (string) - Required - The webspace key. - **fields** (string) - Required - Comma-separated list of properties to load. ### Response #### Success Response (200) - **page** (object) - The requested page object with specified properties. ``` -------------------------------- ### sulu_tag_url_clear Function Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/twig-extensions/functions/sulu_tag_url_clear.md This function returns the current URL with a specified GET parameter removed. ```APIDOC ## sulu_tag_url_clear ### Description Returns the current URL with a specified GET parameter removed. ### Method Not Applicable (This is a function, not an HTTP endpoint) ### Endpoint Not Applicable ### Parameters #### Query Parameters - **tagsParameter** (string) - Optional - The name of the GET parameter to remove from the URL. Defaults to 'tags'. ### Request Example Not Applicable ### Response #### Success Response (string) - **URL** (string) - The current URL with the specified GET parameter removed. #### Response Example ``` "/current/path?other_param=value" ``` ``` -------------------------------- ### Configure Event Admin Views Source: https://github.com/sulu/sulu-docs/blob/3.x/book/extend-admin.md Demonstrates how to implement the configureViews method in a Sulu Admin class to define list views, resource tabs, and form views with associated toolbar actions. ```php viewBuilderFactory->createListViewBuilder(static::EVENT_LIST_VIEW, '/events') ->setResourceKey(Event::RESOURCE_KEY) ->setListKey('events') ->addListAdapters(['table']) ->setAddView(static::EVENT_ADD_FORM_VIEW) ->setEditView(static::EVENT_EDIT_FORM_VIEW) ->addToolbarActions([new ToolbarAction('sulu_admin.add'), new ToolbarAction('sulu_admin.delete')]); $viewCollection->add($listView); $addFormView = $this->viewBuilderFactory->createResourceTabViewBuilder(static::EVENT_ADD_FORM_VIEW, '/events/add') ->setResourceKey(Event::RESOURCE_KEY) ->setBackView(static::EVENT_LIST_VIEW); $viewCollection->add($addFormView); $addDetailsFormView = $this->viewBuilderFactory->createFormViewBuilder(static::EVENT_ADD_FORM_VIEW . '.details', '/details') ->setResourceKey(Event::RESOURCE_KEY) ->setFormKey(static::EVENT_FORM_KEY) ->setTabTitle('sulu_admin.details') ->setEditView(static::EVENT_EDIT_FORM_VIEW) ->addToolbarActions([new ToolbarAction('sulu_admin.save'), new ToolbarAction('sulu_admin.delete')]) ->setParent(static::EVENT_ADD_FORM_VIEW); $viewCollection->add($addDetailsFormView); $editFormView = $this->viewBuilderFactory->createResourceTabViewBuilder(static::EVENT_EDIT_FORM_VIEW, '/events/:id') ->setResourceKey(Event::RESOURCE_KEY) ->setBackView(static::EVENT_LIST_VIEW); $viewCollection->add($editFormView); $editDetailsFormView = $this->viewBuilderFactory->createFormViewBuilder(static::EVENT_EDIT_FORM_VIEW . '.details', '/details') ->setResourceKey(Event::RESOURCE_KEY) ->setFormKey(static::EVENT_FORM_KEY) ->setTabTitle('sulu_admin.details'); } } ``` -------------------------------- ### Install WebpackEncoreBundle via Composer Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/webpack-encore.md Adds the WebpackEncoreBundle dependency to your Symfony project using Composer. ```bash composer require symfony/webpack-encore-bundle ``` -------------------------------- ### Configure Advanced Page Selection with Conditions Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/page_selection.md An advanced configuration example showing how to include additional resource properties and apply a JEXL expression to disable specific items in the selection UI. ```xml Pages ``` -------------------------------- ### Define a Mandatory Date Property Source: https://github.com/sulu/sulu-docs/blob/3.x/book/templates.md Example of defining a 'date' property that is mandatory for content managers. ```xml ``` -------------------------------- ### Configure Local Hosts File Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/web-server/apache.md Maps a local domain name to the loopback address in the system hosts file to enable local development access. ```text # ... 127.0.0.1 example.org ``` -------------------------------- ### Sulu Link Tag Usage Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/markup/link.md Examples of how to use the sulu-link tag with different attributes and providers. ```APIDOC ## Sulu Link Tag Usage ### Description The `sulu-link` tag allows linking to pages and other entities in the application by their ID. The ID is validated and replaced by a proper anchor tag when a response is generated. It also supports adding query strings (?) or hashes (#) to the resulting anchor. ### Providers In a basic installation, the tag supports two providers: `page` (default) and `media`. Additional providers can be implemented by registering a service with the `sulu.link.provider` tag. ### Examples **Basic Usage:** ```html Link Text ``` **With Query String and Anchor:** ```html Anchor Example Query String Example ``` **Specifying Provider:** ```html Link Text Link Text ``` ### Results into: ```html Page Title Page Title Link Text Anchor Example Query String Example Link Text Media Title Link Text ``` ``` -------------------------------- ### Implementing TeaserProviderInterface Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/teaser_selection.md How to create a custom class that implements TeaserProviderInterface to fetch and configure custom data for the Sulu admin teaser selection. ```APIDOC ## Implementing TeaserProviderInterface ### Description To display custom data as teasers in the Sulu admin interface, implement the `TeaserProviderInterface`. This requires defining a configuration and a method to fetch the data based on IDs. ### Method PHP Class Implementation ### Parameters #### TeaserConfiguration - **title** (string) - Required - Display name in admin dropdown - **resourceKey** (string) - Required - Unique resource identifier - **listAdapter** (string) - Required - List view type ('table' or 'column_list') - **displayProperties** (array) - Required - Properties shown in selection list - **overlayTitle** (string) - Required - Title of the selection overlay ### Request Example ```php public function getConfiguration(): TeaserConfiguration { return new TeaserConfiguration( 'Recipe', 'recipes', 'table', ['title'], 'Select Recipe', 'app.recipe_edit_form', ['id' => 'id'] ); } ``` ### Response #### Success Response - **Teaser[]** (array) - Returns an array of Teaser objects containing id, type, locale, title, description, url, and mediaId. ``` -------------------------------- ### GET /admin/api/pages Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/page/content-repository.md Retrieves a list of pages from the content repository based on the provided webspace and locale. ```APIDOC ## GET /admin/api/pages ### Description Retrieves a collection of pages. If a parent parameter is provided, it returns the children of that page; otherwise, it defaults to the webspace root. ### Method GET ### Endpoint /admin/api/pages ### Parameters #### Query Parameters - **locale** (string) - Required - The localization code (e.g., 'de'). - **webspace** (string) - Required - The webspace key (e.g., 'sulu_io'). - **fields** (string) - Required - Comma-separated list of properties to load. - **parent** (uuid) - Optional - The UUID of the parent page to query children from. - **exclude-ghosts** (boolean) - Optional - If true, filters out ghost pages. Default: false. - **exclude-shadows** (boolean) - Optional - If true, filters out shadow pages. Default: false. ### Response #### Success Response (200) - **items** (array) - List of page objects containing the requested fields. ``` -------------------------------- ### Define a Single Select Property Source: https://github.com/sulu/sulu-docs/blob/3.x/book/templates.md Example of defining a 'single_select' property with predefined values for 'concert' and 'festival'. ```xml ``` -------------------------------- ### Performing Functional Tests with SuluTestCase Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/test.md Shows how to use SuluTestCase to create a website client and perform functional tests on controllers. It also demonstrates the equivalent manual configuration for the client. ```php namespace App\Tests\Functional\Controller\Website; use Sulu\Bundle\TestBundle\Testing\SuluTestCase; use Sulu\Component\HttpKernel\SuluKernel; class RegistrationControllerTest extends SuluTestCase { public function testIndexAction(): void { $client = static::createWebsiteClient(); $crawler = $client->request('GET', '/registration/'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('h1', 'Join our Community'); } } // Alternative manual client creation: $client = static::createClient([ 'sulu.context' => SuluKernel::CONTEXT_WEBSITE, ]); ``` -------------------------------- ### Basic Varnish VCL Configuration for Sulu Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/caching-with-varnish.md This VCL configuration sets up Varnish to work with Sulu. It includes the necessary Sulu VCL include, defines the backend, and customizes the vcl_recv, vcl_backend_response, and vcl_deliver subroutines for cache handling. ```vcl vcl 4.0; include "/vendor/sulu/sulu/src/Sulu/Bundle/HttpCacheBundle/Resources/varnish/sulu.vcl"; acl invalidators { "localhost"; } backend default { .host = "127.0.0.1"; .port = "8090"; } sub vcl_recv { call sulu_recv; # Add a Surrogate-Capability header to announce ESI support. # set req.http.Surrogate-Capability = "abc=ESI/1.0"; # Remove all cookies except the session ID (SULUSESSID) # Check configured session ID name in your config/packages/framework.yaml # if (req.http.Cookie) { # set req.http.Cookie = ";" + req.http.Cookie; # set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); # set req.http.Cookie = regsuball(req.http.Cookie, ";(SULUSESSID)=", "; \1="); # set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", ""); # set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", ""); # if (req.http.Cookie == "") { # # If there are no more cookies, remove the header to get page cached. # unset req.http.Cookie; # } # } # if (req.method != "GET" && req.method != "HEAD") { # return (pass); # } # In different to the builtin.vcl of varnish we cache the page still when it have a cookie # if (req.http.Authorization) { # return (pass); # } # Force the lookup, the backend must tell not to cache or vary on all # headers that are used to build the hash. return (hash); } sub vcl_backend_response { call sulu_backend_response; } sub vcl_deliver { call sulu_deliver; } ``` -------------------------------- ### sulu_category_url_remove Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/twig-extensions/functions/sulu_category_url_remove.md Removes a specified category from the GET parameters of a URL. It can optionally take a custom parameter name for the category. ```APIDOC ## sulu_category_url_remove ### Description Returns current URL and removes given category from GET parameters. ### Arguments #### Request Body - **category** (array) - Serialized Category instance to determine value - **categoryParameter** (string) - optional “category”: parameter name ### Returns string - current URL without given category in categories parameter ### See Also - [sulu_category_url](sulu_category_url.md#sulu-category-url) - [sulu_category_url_append](sulu_category_url_append.md#sulu-category-url-append) - [sulu_category_url_toggle](sulu_category_url_toggle.md#sulu-category-url-toggle) - [sulu_category_url_clear](sulu_category_url_clear.md#sulu-category-url-clear) ``` -------------------------------- ### Basic Single Media Selection Configuration (XML) Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/single_media_selection.md This XML snippet demonstrates the basic configuration for a single media selection property, specifying its name and type. ```xml Document ``` -------------------------------- ### Build Admin Interface Locally with Bun Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/build-admin-frontend.md Manually builds the administration interface locally using Bun, an experimental alternative to Node.js/npm. This process involves cleaning up previous build artifacts (including bun.lockb files) and then installing dependencies and running the build script using Bun. ```bash cd /var/project rm -rf assets/admin/node_modules && rm -rf vendor/sulu/sulu/node_modules && rm -rf vendor/sulu/sulu/src/Sulu/Bundle/*/Resources/js/node_modules rm -rf assets/admin/bun.lockb && rm -rf vendor/sulu/sulu/bun.lockb && rm -rf vendor/sulu/sulu/src/Sulu/Bundle/*/Resources/js/bun.lockb cd /var/project/assets/admin bun run preinstall bun install bun run build ``` -------------------------------- ### Rendering Teaser Selection in Twig Source: https://github.com/sulu/sulu-docs/blob/3.x/reference/property-types/teaser_selection.md Example of how to access the selected presentation variant and iterate through teaser items within a Twig template. ```twig ``` -------------------------------- ### Execute Component Tests Source: https://github.com/sulu/sulu-docs/blob/3.x/developer/contributing/test-your-code.md Shows how to run component-level tests using either the runtests script or the standard PHPUnit binary directly from the project root. ```bash ./bin/runtests -B vendor/bin/phpunit vendor/bin/phpunit src/Sulu/Component/Cache ``` -------------------------------- ### Implode Function Example Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/route/index.md Shows how to use the 'implode' function within the 'route_schema' parameter to join object properties with a specified separator. ```xml ``` -------------------------------- ### Implement Custom Media Properties Provider Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/media/properties-provider.md Create a custom class implementing the MediaPropertiesProviderInterface to extract specific metadata from files. This example demonstrates extracting EXIF data from image files. ```php getMimeType(); if (!$mimeType || !\fnmatch('image/*', $mimeType)) { return []; } $properties = []; $exifData = exif_read_data($file->getPathname(), 'EXIF'); if (isset($exifData['EXIF_HEADER_NAME'])) { $properties['exif_header_name'] = $exifData['EXIF_HEADER_NAME']; } return $properties; } } ``` -------------------------------- ### Custom Entity Example Source: https://github.com/sulu/sulu-docs/blob/3.x/bundles/route/index.md A basic PHP entity class that can be used with Sulu routing. It does not require any specific interfaces for routing integration. ```php namespace App\Entity; class Event { private ?int $id = null; private string $title; private string $locale; public function getId(): ?int { return $this->id; } public function getTitle(): string { return $this->title; } public function getLocale(): string { return $this->locale; } } ``` -------------------------------- ### Varnish VCL Configuration with XKey Support Source: https://github.com/sulu/sulu-docs/blob/3.x/cookbook/caching-with-varnish.md Extended VCL configuration for Varnish that includes the 'fos_tags_xkey.vcl' and enables XKey functionality. It also sets a grace period for backend responses. ```vcl vcl 4.0; include "/vendor/sulu/sulu/src/Sulu/Bundle/HttpCacheBundle/Resources/varnish/sulu.vcl"; include "/vendor/friendsofsymfony/http-cache/resources/config/varnish/fos_tags_xkey.vcl"; acl invalidators { "localhost"; } backend default { .host = "127.0.0.1"; .port = "8090"; } sub vcl_recv { call fos_tags_xkey_recv; call sulu_recv; # Force the lookup, the backend must tell not to cache or vary on all # headers that are used to build the hash. return (hash); } sub vcl_backend_response { set beresp.grace = 2m; call sulu_backend_response; } sub vcl_deliver { call fos_tags_xkey_deliver; call sulu_deliver; } ```