### Launch Pimcore Interactive Installer Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Navigates to the project directory and executes the Pimcore installer script. This command initiates an interactive setup process for Pimcore. ```bash cd ./my-project ./vendor/bin/pimcore-install ``` -------------------------------- ### Install Pimcore Demo Package using Composer Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Installs the demo package of Pimcore, which includes exemplary blueprints. It utilizes Composer with an increased memory limit for the installation. ```bash COMPOSER_MEMORY_LIMIT=-1 composer create-project pimcore/demo my-project ``` -------------------------------- ### Install Pimcore Skeleton Package using Composer Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Installs the skeleton package of Pimcore, suitable for experienced developers. It uses Composer with an increased memory limit to handle the installation process. ```bash COMPOSER_MEMORY_LIMIT=-1 composer create-project pimcore/skeleton my-project ``` -------------------------------- ### Create MySQL Database for Pimcore Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Creates a new MySQL database named 'project_database' with UTF8MB4 character set, which is required for Pimcore installation. Assumes root user access. ```bash mysql -u root -p -e "CREATE DATABASE project_database charset=utf8mb4;" ``` -------------------------------- ### Install OptiPng for Image Optimization Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs OptiPng, a utility for optimizing PNG images using lossless compression. This command is intended for Debian-based Linux systems and helps reduce PNG file sizes without quality loss. ```bash apt-get install optipng ``` -------------------------------- ### Install JPEGOptim for Image Optimization Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Downloads and installs JPEGOptim, a command-line utility for optimizing JPEG images. The command fetches the binary and makes it executable, ensuring it's available system-wide. Add to PATH if necessary. ```bash wget https://github.com/imagemin/jpegoptim-bin/raw/main/vendor/linux/jpegoptim -O /usr/local/bin/jpegoptim chmod 0755 /usr/local/bin/jpegoptim ``` -------------------------------- ### Configure MySQL Server for Pimcore Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/DB_Setup Example `pimcore.cnf` file content to enforce required MySQL server configurations for Pimcore. This includes setting default character sets for clients and the server, and specifying collation. ```ini # MySQL Server configuration for Pimcore. # @See https://dev.mysql.com/doc/refman/8.0/en/option-files.html # @See https://pimcore.com/docs/pimcore/11.0/Development_Documentation/Installation_and_Upgrade/System_Setup_and_Hosting/DB_Setup.html # Applies to any client connecting to this sever [client] default-character-set=utf8mb4 # Applies to mysql cli client application [mysql] default-character-set=utf8mb4 # Applies to mysql server [mysqld] character-set-server=utf8mb4 collation-server=utf8mb4_unicode_520_ci init-connect='SET NAMES utf8mb4' #lower_case_table_names=1 # activate when working on different operating system platforms, like MacOS + Windows and or Linux # this is not required when consistently working on Linux or Docker ``` -------------------------------- ### Install WebP Support Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs the WebP library, enabling support for the WebP image format within Pimcore. This allows for efficient image compression and display. This command is for Debian-based Linux distributions. ```bash apt-get install webp ``` -------------------------------- ### Install Exiftool for Metadata Extraction Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs Exiftool, a powerful command-line utility for reading, writing, and editing meta information in a wide variety of files, including images. This command is for Debian-based Linux distributions. ```bash apt-get install libimage-exiftool-perl ``` -------------------------------- ### Modify Pimcore Bundles with BundleSetupEvent Subscriber (PHP) Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Advanced_Installation_Topics Subscribing to the BundleSetupEvent allows modification of installable and recommended bundles. This example demonstrates adding 'PimcoreAdminBundle' as both installable and required. ```php [ ['bundleSetup'], ], ]; } public function bundleSetup(BundleSetupEvent $event): void { // make bundle installable (using --install-bundles) and recommend it in interactive installation $event->addInstallableBundle('PimcoreAdminBundle', PimcoreAdminBundle::class, true); // add required bundle $event->addRequiredBundle('PimcoreAdminBundle', PimcoreAdminBundle::class); } } ``` -------------------------------- ### Install AWS S3 Adapter for Flysystem (Composer) Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/File_Storage_Setup This command installs the `league/flysystem-aws-s3-v3` package, which provides the necessary adapter to integrate AWS S3 storage with Pimcore's Flysystem configuration. This is a prerequisite for using S3 as a file storage. ```bash composer require league/flysystem-aws-s3-v3 ``` -------------------------------- ### Install LibreOffice for PDF Generation Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs LibreOffice and related utilities for PDF generation. This command is suitable for Debian-based Linux systems. It includes components for document conversion and rendering. Ensure these are in your system's PATH. ```bash apt-get install libreoffice libreoffice-script-provider-python libreoffice-math xfonts-75dpi poppler-utils inkscape libxrender1 libfontconfig1 ghostscript ``` -------------------------------- ### Install Gotenberg PHP Client for PDF Generation Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs the official Gotenberg PHP client via Composer, enabling Pimcore to use the Docker-powered Gotenberg API for PDF generation. This requires Composer to be installed and available in your PATH. ```bash composer require gotenberg/gotenberg-php ^2.0 ``` -------------------------------- ### Implement Installer in Pimcore Bundle Source: https://docs.pimcore.com/platform/Pimcore/Extending_Pimcore/Bundle_Developers_Guide/Pimcore_Bundles/Installers This PHP code demonstrates how a Pimcore bundle implements the `getInstaller()` method to return an installer instance. The installer is fetched from the service container. ```php container->get(Installer::class); } } ``` -------------------------------- ### Pimcore Migration Console Commands Source: https://docs.pimcore.com/platform/Pimcore/Extending_Pimcore/Bundle_Developers_Guide/Pimcore_Bundles/Installers These examples illustrate how to use the Doctrine Migrations console commands with Pimcore's `--prefix` option to filter migrations by namespace. This allows for targeted migration execution. ```bash # only run migrations for the Pimcore core ./bin/console doctrine:migrations:migrate --prefix=Pimcore\Bundle\CoreBundle # list migrations for the CMF bundle ./bin/console doctrine:migrations:list --prefix=CustomerManagementFrameworkBundle\Migrations # run all migrations ./bin/console doctrine:migrations:migrate ``` -------------------------------- ### Install FFMPEG for Video Transcoding Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs the FFMPEG tool, essential for video transcoding functionalities within Pimcore. This command is for Debian-based Linux distributions. Ensure FFMPEG is added to your system's PATH. ```bash sudo apt-get install ffmpeg ``` -------------------------------- ### Implement SettingsStoreAwareInstaller for Bundle Installation Source: https://docs.pimcore.com/platform/Pimcore/Extending_Pimcore/Bundle_Developers_Guide/Pimcore_Bundles/Installers This PHP code demonstrates how to extend the SettingsStoreAwareInstaller to create a custom installer for a Pimcore bundle. It shows the implementation of `install`, `uninstall`, and `getLastMigrationVersionClassName` methods. The `install` and `uninstall` methods must call `$this->markInstalled()` or `$this->markUninstalled()` respectively, or their parent class equivalents. The `getLastMigrationVersionClassName` method is used to specify which migrations should be marked as migrated during installation without execution. ```php markInstalled(); //or call parent::install(); } public function uninstall(): void { //do your uninstall stuff $this->markUninstalled(); //or call parent::uninstall(); } } ``` -------------------------------- ### Install PngQuant for Image Optimization Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs PngQuant, a tool for lossy compression of PNG images, which is useful for optimizing image sizes in Pimcore. This command is for Debian-based Linux distributions. ```bash apt-get install pngquant ``` -------------------------------- ### PHPUnit Calculator Test Example Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Testing/Application_Testing A sample PHPUnit test class (`CalculatorTest.php`) for a hypothetical `AppCalculator` class. It demonstrates basic assertion, setup using `setUp()`, and parameterized testing using `@dataProvider`. The test file should be located in the `tests/App/` directory. ```php calculator = new Calculator(); } public function testAdd(): void { $this->assertEquals(15, $this->calculator->add(10, 5)); } /** * @dataProvider addDataProvider */ public function testAddWithProvider(int $a, int $b, int $expected): void { $this->assertEquals($expected, $this->calculator->add($a, $b)); } public function addDataProvider(): array { return [ [1, 2, 3], [10, 5, 15], [-5, 5, 0], [5, -5, 0], [0, 10, 10], [-50, -50, -100], [-50, 10, -40] ]; } } ``` -------------------------------- ### Install Elasticsearch and Composer Dependencies for Analysis Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Testing/Core_Tests This command installs the Elasticsearch client library and the Composer package itself, which are required for performing a full code analysis. Ensure you have Composer installed and configured correctly. ```bash composer require "elasticsearch/elasticsearch:^7.11" "composer/composer:*" ``` -------------------------------- ### Install PHPStan Dependencies for Analysis Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Testing/Core_Tests This command installs the minimum required PHPStan packages for static analysis. It's essential for code quality checks. Ensure Composer is installed and configured correctly in your environment. ```bash # minimum composer require "phpstan/phpstan:^0.12" "phpstan/phpstan-symfony:^0.12" ``` -------------------------------- ### Example: Get Cities by Country and Zip Source: https://docs.pimcore.com/platform/Pimcore/Objects/Working_with_PHP_API Illustrates retrieving lists of cities based on their country code and individual cities by their zip code. It shows how to iterate through a list of cities and access their properties. The examples also demonstrate fetching a single city by zip code, including handling the case where the limit is set to 1. ```php getZip(); ... } // get a city by zip $city = DataObject\City::getByZip(5020, 1); $city->getZip(); // do something with the city // get the first 10 cities in Austria $list = DataObject\City::getByCountry("AT", 10); foreach ($list as $city) { // do something with the cities $city->getZip(); } ``` -------------------------------- ### Install PimcoreSeoBundle Source: https://docs.pimcore.com/platform/Pimcore/Tools_and_Features/Robots This snippet shows the command to install the PimcoreSeoBundle, which is a prerequisite for using the robots.txt generation feature. Ensure the bundle is enabled in your `bundle.php` file before installation. ```bash bin/console pimcore:bundle:install PimcoreSeoBundle ``` -------------------------------- ### Automate Pimcore Installation with Environment Variables Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Advanced_Installation_Topics Installs Pimcore by setting sensitive parameters like MySQL username and password as environment variables before executing the installation script. This method enhances security by avoiding the direct exposure of credentials in the command line. ```bash $ PIMCORE_INSTALL_MYSQL_USERNAME=username PIMCORE_INSTALL_MYSQL_PASSWORD=password ./vendor/bin/pimcore-install \ --admin-username=admin --admin-password=admin \ --mysql-database=pimcore \ --no-interaction ``` -------------------------------- ### Consume Pimcore Image Optimization Queue Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Starts consuming messages specifically from the Pimcore image optimization queue. This is used for processing image thumbnail optimizations. ```bash bin/console messenger:consume pimcore_image_optimize ``` -------------------------------- ### Consume Pimcore Messenger Queues Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Starts consuming messages from multiple Pimcore messenger queues. This command is used to process background tasks like asset updates and scheduled tasks. ```bash bin/console messenger:consume pimcore_core pimcore_maintenance pimcore_scheduled_tasks pimcore_search_backend_message pimcore_asset_update ``` -------------------------------- ### Dump Reference of Pimcore Configuration Sections Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Configuration This command generates a reference of all valid configuration sections for Pimcore. It's useful for understanding the available configuration options and their structure. ```bash bin/console config:dump-reference pimcore ``` -------------------------------- ### Configure Reject and Start Processing Transitions (YAML) Source: https://docs.pimcore.com/platform/Pimcore/Workflow_Management/Workflow_Tutorial This YAML configuration defines transitions for rejecting a product and restarting the processing workflow. It specifies the source and target states, along with options for enabling comments and whether comments are required. ```yaml transitions: reject_product: from: [new, content_prepared] to: rejected options: label: 'Reject the product' notes: commentEnabled: true commentRequired: true start_processing: from: [new, content_prepared] to: update_content options: label: 'Start processing the product' notes: commentEnabled: true commentRequired: false ``` -------------------------------- ### Usage: List and Execute Pimcore Console Commands Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Console_CLI These examples show how to interact with the Pimcore console application from the command line. The `bin/console list` command displays all available commands, while `bin/console ` executes a specific command. It is recommended to run console commands as the appropriate web server user to avoid permission issues. ```Shell # get a list of all registered commands $ ./bin/console list # call the foo:bar command $ ./bin/console foo:bar ``` -------------------------------- ### Install Graphviz for Workflows Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Installs Graphviz, a graph visualization software used by Pimcore for rendering workflows and diagrams. This command is suitable for Debian-based Linux systems. ```bash apt-get install graphviz ``` -------------------------------- ### Write a PHP Unit Test with Codeception Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Testing/Application_Testing This PHP code demonstrates a basic unit test using Codeception's Unit class. It includes tests for simple calculations, data providers for parameterized tests, object assertions, and exception handling. The `ExampleTest` class is a dummy for demonstration purposes. ```php assertEquals(15, 10 + 5); $this->assertEquals(100, pow(10, 2)); } /** * @dataProvider addDataProvider */ public function testPhpCanAddWithProvider(int $a, int $b, int $expected): void { $this->assertEquals($expected, $a + $b, sprintf('%d + %d = %d', $a, $b, $expected)); } public function testSomethingElse(): void { $obj1 = new \stdClass(); $obj2 = new \stdClass(); $obj3 = new \stdClass(); $obj1->obj = $obj3; $obj2->obj = $obj3; $this->assertNotNull($obj1); $this->assertNotNull($obj2); $this->assertNotNull($obj3); $this->assertNotSame($obj1, $obj2); $this->assertSame($obj1->obj, $obj2->obj); $this->assertSame($obj3, $obj1->obj); $this->assertSame($obj3, $obj2->obj); } public function testException(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('This test is about to fail'); throw new \RuntimeException('This test is about to fail'); } public function addDataProvider(): array { return [ [1, 2, 3], [10, 5, 15], [-5, 5, 0], [5, -5, 0], [0, 10, 10], [-50, -50, -100], [-50, 10, -40] ]; } } ``` -------------------------------- ### Add Custom Logic to Pimcore Startup Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Configuration This PHP snippet shows how to add custom logic to Pimcore's startup process by creating a '/config/pimcore/startup.php' file. The code within this file is executed after initial bootstrapping but before the kernel is booted, allowing for early system reconfiguration. ```php $this->document, 'editmode' => $this->editmode, ]; $params['testPlaceholder'] = ' :-)'; $html = $this->renderView(':Blog:index.html.php', $params); $adapter = \Pimcore\Bundle\WebToPrintBundle\Processor::getInstance(); //add custom settings if necessary if ($adapter instanceof \Pimcore\Bundle\WebToPrintBundle\Processor\PdfReactor) { //Config settings -> http://www.pdfreactor.com/product/doc/webservice/php.html#Configuration $params['adapterConfig'] = [ 'author' => 'Max Mustermann', 'title' => 'Custom Title', 'javaScriptMode' => 0, 'addLinks' => true, 'appendLog' => true, 'enableDebugMode' => true ]; } elseif ($adapter instanceof \Pimcore\Bundle\WebToPrintBundle\Processor\Gotenberg) { $params = Config::getWeb2PrintConfig(); $params = json_decode($params['gotenbergSettings'], true) ?: []; } elseif ($adapter instanceof \Pimcore\Bundle\WebToPrintBundle\Processor\Chromium) { $params = Config::getWeb2PrintConfig(); $params = json_decode($params['chromiumSettings'], true) ?: []; } return new Response( $adapter->getPdfFromString($html, $params), 200, array( 'Content-Type' => 'application/pdf', // 'Content-Disposition' => 'attachment; filename="custom-pdf.pdf"' //direct download ) ); } } ``` -------------------------------- ### Example: Get Cities by Localized Fields and Name Source: https://docs.pimcore.com/platform/Pimcore/Objects/Working_with_PHP_API Provides examples of fetching city data using localized fields, specifying different locales, and retrieving single objects or lists. It demonstrates how to get cities by country name in a default locale, retrieve a specific city by its localized name and zip code, and fetch lists of cities with optional limits and locales. The examples also show retrieving country data by localized name. ```php 1]); // or $city = DataObject\City::getByCity("Wels", null, 1); // get the first 10 cities in Austria by localized field using default locale $list = DataObject\City::getByLocalizedfields("country", "Österreich", null, 10); // or $list = DataObject\City::getByCountry("Österreich", null, 10); // get the first 10 cities in Austria by localized field "de" locale $list = DataObject\City::getByLocalizedfields("country", "Österreich", "de", 10); // or $list = DataObject\City::getByCountry("Österreich", "de", 10); //get a country by localized name in english $country = DataObject\Country::getByLocalizedfields("name", "Austria", "en", 1); // or $country = DataObject\Country::getByName("Austria", "en", 1); ``` -------------------------------- ### Start Job Execution with Custom Context in PHP Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Generic_Execution_Engine/Configuration This PHP code demonstrates how to initiate a job execution using a predefined custom context. The `$jobExecutionAgent->startJobExecution` method is called with the job object, owner, and the name of the custom execution context ('my_custom_context'). This ensures the job run uses the specific translation domain and error handling defined in that context. ```php $jobExecutionAgent->startJobExecution($job, $owner, 'my_custom_context'); ``` -------------------------------- ### Install Symfony PHPUnit Bridge Source: https://docs.pimcore.com/platform/Pimcore/Development_Tools_and_Details/Testing/Application_Testing Installs the Symfony PHPUnit bridge using Composer. This is a prerequisite for using Symfony's default testing setup with PHPUnit in a Pimcore project. Ensure you are in your project's root directory when running this command. ```bash $ composer require --dev 'symfony/phpunit-bridge:*' ``` -------------------------------- ### Render Product Image using Pimcore Thumbnail Configuration Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Create_a_First_Project This code demonstrates how to display a product image on the frontend using Pimcore's thumbnail configuration. It checks if a product picture exists and then uses the `thumbnail()` method to generate an optimized `` or `` tag. The `html|raw` filter ensures correct rendering. Dependencies include the product object with a picture asset and a pre-defined thumbnail configuration named 'content'. ```twig
{% if product.picture %} {{ product.picture.thumbnail("content").html|raw }} {% endif %} {{ product.description|raw }}
``` -------------------------------- ### Install Dependency using Composer Source: https://docs.pimcore.com/platform/Pimcore/Extending_Pimcore/Add_Your_Own_Dependencies_and_Packages This command uses Composer, the standard PHP dependency manager, to require and install a new package into your project. Ensure you are in the project's root directory when executing this command. The package 'mtdowling/cron-expression' is used as an example. ```bash composer require mtdowling/cron-expression ``` -------------------------------- ### Navigate to Project Directory using Terminal Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Changes the current directory to the root folder of your project. This is a prerequisite for running Composer commands. ```bash cd /your/project ``` -------------------------------- ### Get Asset Document Thumbnails (PHP) Source: https://docs.pimcore.com/platform/Pimcore/Assets/Working_with_Thumbnails/Document_Thumbnails Demonstrates how to retrieve image thumbnails for document assets in Pimcore. It shows examples of getting a thumbnail based on a named configuration, dynamically specifying dimensions, and generating thumbnail URLs for all pages asynchronously. Requires `pimcore/pimcore` dependency. ```php $asset = Asset::getById(123); if($asset instanceof Asset\Document) { // get a thumbnail of the first page, resized to the configuration of "myThumbnail" echo $asset->getImageThumbnail("myThumbnail"); // get the thumbnail for the third (see second parameter) page using a dynamic configuration echo $asset->getImageThumbnail(["width" => 230, "contain" => true], 2); // get the thumbnail URL for all pages, but do not generate them immediately (see third parameter) - the thumbnails are then generated on request $thumbnailUrls = []; for($i=1; $i<=$asset->getPageCount(); $i++) { $thumbnailUrls[] = $asset->getImageThumbnail("myThumbnail", $i, true); } } ``` -------------------------------- ### Initialize Pimcore Database with Docker Compose Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Docker_Based_Installation This command executes the Pimcore installation script within a Docker Compose environment. It connects to the database service ('db') with provided credentials and initializes the database for Pimcore. Assumes Docker Compose is running and configured. ```bash docker compose exec php vendor/bin/pimcore-install --mysql-host-socket=db --mysql-username=pimcore --mysql-password=pimcore --mysql-database=pimcore ``` -------------------------------- ### Grant Pimcore Database Permissions Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/DB_Setup SQL commands to create a dedicated user for Pimcore and grant it all necessary permissions on the `project_database`. This is crucial for Pimcore to interact with its database. ```sql CREATE USER 'project_user'@'localhost' IDENTIFIED BY 'PASSWORD'; GRANT ALL ON `project_database`.* TO 'project_user'@'localhost'; ``` -------------------------------- ### List Product Variants using Pimcore Listing in PHP Source: https://docs.pimcore.com/platform/Pimcore/Best_Practice/Implementing_Product_Information_Management This code example shows how to retrieve product variants using Pimcore's generic listing methods. It initializes a `ProductListing` object, sets the object type to `OBJECT_TYPE_VARIANT`, and then loads the results. ```php setObjectTypes([AbstractObject::OBJECT_TYPE_VARIANT]); $variants = $list->load(); ``` -------------------------------- ### Reinitialize MySQL Data Directory Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/DB_Setup Commands to safely reinitialize the MySQL data directory when changing `lower_case_table_names` on MySQL 8+. This process deletes existing data, so backing up databases beforehand is essential. ```bash rm -rf /var/lib/mysql mkdir /var/lib/mysql chown mysql:mysql /var/lib/mysql mysqld --initialize ``` -------------------------------- ### Create Pimcore Demo Project with Docker Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Docker_Based_Installation This command uses Docker to run a pre-configured Pimcore demo package. It mounts the current directory to the container and executes Composer to create a new project named 'my-project'. Requires Docker and Docker Compose to be installed. ```bash docker run -u `id -u`:`id -g` --rm -v `pwd`:/var/www/html pimcore/pimcore:php8.2-latest composer create-project pimcore/demo my-project ``` -------------------------------- ### Create MySQL Database for Pimcore Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/DB_Setup Command to create a new MySQL database specifically for Pimcore. It ensures the database uses the `utf8mb4` character set and `utf8mb4_unicode_520_ci` collation for proper character encoding support. ```bash mysql -u root -p -e "CREATE DATABASE project_database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;" ``` -------------------------------- ### Render Sidebar Navigation with Custom HTML Prefix Source: https://docs.pimcore.com/platform/Pimcore/Documents/Navigation This example shows how to render a sidebar navigation while customizing the HTML output by adding a prefix to menu items using `htmlMenuPrefix`. It also demonstrates the use of `expandSiblingNodesOfActiveBranch` to control the expansion of nodes related to the active branch, along with custom CSS classes. ```twig
{% set sideNav = pimcore_build_nav({active: document, root: navStartNode, htmlMenuPrefix: 'my-nav-'}) %} {{ pimcore_render_nav(sideNav, 'menu', 'renderMenu', { ulClass: 'nav my-sidenav', expandSiblingNodesOfActiveBranch: true }) }} ``` -------------------------------- ### Schedule Pimcore Maintenance Tasks via Cron Source: https://docs.pimcore.com/platform/Pimcore/Getting_Started/Installation/Webserver_Installation Configures a cron job to execute the 'pimcore:maintenance' command every 5 minutes. This command populates the message queue with maintenance tasks to be processed by messenger workers. ```cron */5 * * * * /your/project/bin/console pimcore:maintenance ``` -------------------------------- ### Pimcore Controller Examples in PHP Source: https://docs.pimcore.com/platform/Pimcore/MVC/Controller This PHP code demonstrates various ways to implement actions within a Pimcore controller. It shows how to render Twig templates using `$this->render()`, the `#[Template]` attribute, how to add response headers using `$this->addResponseHeader()` and the `#[ResponseHeader]` attribute, how to return a JSON response using `$this->json()`, and how to return a standard Symfony `Response` object. ```php >render() and passing the parameter 'foo' */ public function myAction(): Response { return $this->render('content/default.html.twig', ["foo" => "bar"]); } /** * Example using the #[Template] attribute to resolve the view. * The frontend controller also provides methods to add response headers or via attributes without having * access to the final response object (as it is automatically created when rendering the view). * */ #[Template('/default/header.html.twig')] #[ResponseHeader(key: "X-Foo", values: ["123456", "98765"])] public function headerAction(Request $request): array { // schedule a response header via code $this->addResponseHeader('X-Foo', 'bar', false, $request); return ["foo" => "bar"]; } /** * This action returns a JSON response. */ public function jsonAction(Request $request): JsonResponse { return $this->json(array('key' => 'value')); } /** * This returns a standard symfony Response object */ public function customAction(Request $request): Response { return new Response("Just some text"); } } ``` -------------------------------- ### Check Pimcore System Requirements via CLI Source: https://docs.pimcore.com/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation Executes a command-line check for Pimcore system requirements using the `pimcore/system-info-bundle` package. This is an alternative to the Admin UI check and provides immediate feedback on your server's configuration. ```bash bin/console pimcore:system:requirements:check ```