### Initiate TYPO3 Installation Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/DirectoryStructure/FlagFiles.rst This command starts the TYPO3 installation process. It is used on fresh TYPO3 setups to guide the user through the initial configuration. ```bash # Lock the TYPO3 Backend for everyone including administrators vendor/bin/typo3 setup ``` -------------------------------- ### Install Tool Password Reset Example Output Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Troubleshooting/TYPO3.rst This is an example of the response received when the provided install tool password does not match. Copy the hash for use in settings.php. ```text "Given password does not match the install tool login password. Calculated hash: $argon2i$v=xyz" ``` -------------------------------- ### Example Output of Successful TYPO3 Setup Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/AutomateSetup/Index.rst This output confirms that the `typo3 setup` command was executed because `settings.php` was not found. ```text [INFO] No settings.php found, running 'typo3 setup'... ✓ Congratulations - TYPO3 Setup is done. ``` -------------------------------- ### Create Startup Script for TYPO3 Setup Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/AutomateSetup/Index.rst The startup script checks if TYPO3 has already been installed. If not, it runs the `typo3 setup` CLI command in non-interactive mode using environment variables defined in Docker Compose. It also starts Apache in the foreground. ```bash #!/bin/bash # Check if TYPO3 is already installed if [ ! -f "typo3conf/settings.php" ]; then echo "[INFO] No settings.php found, running 'typo3 setup'..." # Run TYPO3 setup in non-interactive mode # Ensure all required environment variables are set in docker-compose.yml typo3 setup --no-interaction --database-user "${TYPO3_DB_USER}" --database-password "${TYPO3_DB_PASSWORD}" --database-host "${TYPO3_DB_HOST}" --database-name "${TYPO3_DB_NAME}" --admin-user "${TYPO3_ADMIN_USER}" --admin-password "${TYPO3_ADMIN_PASSWORD}" echo "✓ Congratulations - TYPO3 Setup is done." else echo "[INFO] settings.php found, skipping setup." fi # Start Apache in the foreground exec apache2 -DFOREGROUND ``` -------------------------------- ### Run TYPO3 Setup via Console Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Installation/ComposerMode/Index.rst Use this command to initiate the TYPO3 installation process from the console. This is an alternative to the web-based installer. ```bash # Use console command to run the install process # or use the Install Tool GUI (See below) ./vendor/bin/typo3 setup ``` ```powershell # Use console command to run the install process # or use the Install Tool GUI (See below) ./vendor/bin/typo3 setup ``` ```bash # Use console command to run the install process # or use the Install Tool GUI (See below) ddev exec ./vendor/bin/typo3 setup ``` -------------------------------- ### Example Output When TYPO3 Setup is Skipped Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/AutomateSetup/Index.rst This output indicates that the TYPO3 setup was skipped because the `settings.php` file already exists. ```text [INFO] settings.php found, skipping setup. ``` -------------------------------- ### Setup Specific or All Extensions Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/ExtensionManagement/Composer/Index.rst Run the `extension:setup` command to perform TYPO3-specific installation steps for extensions, such as importing static data or setting up database tables. You can target a specific extension or run it for all. ```bash # Setup the extension with key "news" vendor/bin/typo3 extension:setup --extension=news ``` ```bash # Setup all extensions vendor/bin/typo3 extension:setup ``` -------------------------------- ### Clone and Set Up site-introduction Project Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Testing/Tutorial/Acceptance.rst These commands clone the site-introduction repository, start the ddev environment, and import the database and files. Ensure ddev is installed and configured. ```shell lolli@apoc /var/www/local $ git clone git@github.com:TYPO3-Documentation/site-introduction.git lolli@apoc /var/www/local/site-introduction $ cd site-introduction lolli@apoc /var/www/local/site-introduction $ ddev start lolli@apoc /var/www/local/site-introduction $ ddev import-db --src=./data/db.sql lolli@apoc /var/www/local/site-introduction $ ddev import-files --src=./assets lolli@apoc /var/www/local/site-introduction $ ddev composer install ``` -------------------------------- ### Extending setUp() in Functional Tests Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Testing/FunctionalTesting/Index.rst When overriding the setUp() method, always call parent::setUp() first. This example demonstrates initializing the system under test and loading fixtures. ```php setUpBackendUser(); $this->importCSVDataSet(__DIR__ . '/Fixtures/pages.csv'); $this->subject = GeneralUtility::makeInstance(LocalizationRepository::class); } // ... other test methods } ``` -------------------------------- ### PackageInitializationEvent API Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Events/Events/Core/Package/PackageInitializationEvent.rst Demonstrates the basic API of the PackageInitializationEvent, including getting package information and adding storage entries. ```php */ protected array $storage = []; public function __construct(Package $package) { $this->package = $package; } public function getPackage(): Package { return $this->package; } public function getPackageName(): string { return $this->package->getName(); } public function getPackagePath(): string { return $this->package->getPackagePath(); } public function addStorageEntry(string $key, mixed $value): void { $this->storage[$key] = $value; } public function getStorageEntry(string $key, mixed $defaultValue = null): mixed { return $this->storage[$key] ?? $defaultValue; } /** * @return array */ public function getStorage(): array { return $this->storage; } } ``` -------------------------------- ### Extbase Controller Initialization Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/ExtbaseRewrite/Controller/ActionController.rst This snippet demonstrates the use of initializeAction() for common setup and per-action initializers for action-specific configuration, such as property mapping. ```php arguments['conference'] = $this->argumentsManager->convert( $this->arguments['conference'], ['dateOfBirth' => ['format' => 'Y-m-d']] ); } public function createAction(Conference $conference): { // ... action logic ... } } ``` -------------------------------- ### Example Page Tree Structure Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/MountPoints/Index.rst Illustrates a basic page tree setup with a mount point and its target page. ```none page tree ====== ==================== 1 Root 2 ├── Basic Mount Point <- mount point, mounting page 3 3 └── Company <- mounted by page 2 4 └── About us ``` -------------------------------- ### Install Extension via Composer Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/ExtbaseRewrite/QuickStart/Index.rst Installs the extension in a Composer-based TYPO3 project. This command adds the extension to your project's dependencies. ```bash composer require myvendor/my-extension ``` -------------------------------- ### Activate Extension Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/ExtbaseRewrite/QuickStart/Index.rst Activates the extension within the TYPO3 installation. This command makes the extension available for use. ```bash vendor/bin/typo3 extension:activate my_extension ``` -------------------------------- ### Full Example: Hello World Wizard Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Backend/JavaScript/Modules/MultiStepWizard.rst This example demonstrates creating a basic multi-step wizard with a single slide, using a warning severity for visual feedback. ```javascript import { SeverityEnum } from 'TYPO3/CMS/Core/SeverityEnum'; MultiStepWizard.addSlide({ identifier: 'hello-world-slide', title: 'Hello World', content: 'This is the content of the first slide.', severity: SeverityEnum.warning, progressBarTitle: 'Step 1 of 1', callback: () => { console.log('Hello World slide rendered!'); } }); MultiStepWizard.show(); ``` -------------------------------- ### Create FIRST_INSTALL file for GUI Installer Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Installation/ComposerMode/Index.rst Create an empty file named FIRST_INSTALL in the public directory to trigger the GUI-based web installer upon first access. ```bash touch example-project-directory/public/FIRST_INSTALL ``` ```powershell echo $null >> public/FIRST_INSTALL ``` ```bash ddev exec touch public/FIRST_INSTALL ``` -------------------------------- ### TYPO3 CI/CD Pipeline Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Deployment/Automated/Index.rst This YAML configuration defines a GitHub Actions workflow for a TYPO3 project. It handles checkout, PHP setup, dependency installation, code linting, static analysis with PHPStan, and running PHPUnit tests. The deployment step demonstrates a basic SSH command to pull changes, install production dependencies, and flush TYPO3 caches on a remote server. ```yaml name: TYPO3 CI/CD Pipeline on: push: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - name: Set up PHP uses: shivammathur/setup-php@v2 with: php-version: '8.3' - name: Install Dependencies run: composer install --prefer-dist - name: Lint PHP run: find . -name "*.php" -exec php -l {} \; - name: Run PHPStan run: vendor/bin/phpstan analyse - name: Run PHPUnit Tests run: vendor/bin/phpunit - name: Deploy (Example) run: | ssh user@server 'cd /var/www/html && git pull && composer install \ --no-dev && ./vendor/bin/typo3 cache:flush' ``` -------------------------------- ### Get Full TypoScript Setup Array Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/RequestLifeCycle/RequestAttributes/FrontendTyposcript.rst Retrieve the complete TypoScript setup array from the frontend request attribute. This is a substitution for the older $GLOBALS['TSFE']->tmpl->setup. ```php // Substitution of $GLOBALS['TSFE']->tmpl->setup $fullTypoScript = $request->getAttribute('frontend.typoscript') ->getSetupArray(); ``` -------------------------------- ### Install Extensions with Composer Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/ExtensionManagement/Composer/Index.rst Use `composer install` to install exact versions of extensions as defined in `composer.lock`. This is typically used on co-worker machines or production servers after initial setup. ```bash git update # Install versions that have been changed composer install # Rerun the setup for all extensions vendor/bin/typo3 extension:setup ``` -------------------------------- ### Example Directory Structure (Good) Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Upgrade/MigrateToComposer/Requirements.rst Presents the recommended project structure with a dedicated 'public/' directory as the web root, enhancing security and organization. ```none $ tree typo3_root └── public/ ├── index.php ├── fileadmin/ ├── typo3/ ├── typo3conf/ └── typo3temp/ ``` -------------------------------- ### Get Absolute Web Path for Assets Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Upgrade/MigrateToComposer/AssetMigration.rst Use PathUtility to get the absolute web path for an asset. This is useful for linking to assets within your TYPO3 installation. ```php PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:my-extension/Resources/Public/logo.jpg')) ``` -------------------------------- ### Verbose Composer Install for Debugging Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Upgrade/ApplyingCorePatches/Index.rst Use the `-vvv` flag with `composer install` to get highly verbose output, which is useful for diagnosing patch application errors. ```bash composer install -vvv ``` -------------------------------- ### Create FIRST_INSTALL file Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Installation/ClassicMode/InstallationWizard.rst Create an empty file named FIRST_INSTALL in the TYPO3 root directory to trigger the installation wizard. This can be done via FTP or command line. ```bash touch FIRST_INSTALL ``` -------------------------------- ### MyEventListener Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Events/Events/Core/Package/PackageInitializationEvent.rst An example listener for the PackageInitializationEvent. Demonstrates how to listen to the event and potentially store data. ```php getPackageName(); $packagePath = $event->getPackagePath(); // Store some data in the event $event->addStorageEntry('my_custom_data', ['key' => 'value']); } } ``` -------------------------------- ### Get Frontend TypoScript Setup Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Configuration/TypoScript/PhpApi/Index.rst Accesses the parsed Frontend TypoScript setup as an array. This is available via the 'frontend.typoscript' request attribute, typically added by middlewares. ```APIDOC ## Get Frontend TypoScript Setup ### Description Accesses the parsed Frontend TypoScript setup as an array. This is available via the 'frontend.typoscript' request attribute, typically added by middlewares. ### Method `$request->getAttribute('frontend.typoscript')->getSetupArray(): array` ### Parameters This method does not take direct parameters but relies on the PSR-7 `request` object. ### Request Example ```php // Assuming $request is a PSR-7 request object $fullTypoScript = $request->getAttribute('frontend.typoscript')->getSetupArray(); ``` ### Response #### Success Response (array) - Returns an associative array representing the parsed Frontend TypoScript setup. ``` -------------------------------- ### Automate Extension Setup with Composer Scripts Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/ExtensionManagement/Composer/Index.rst Configure your `composer.json` to automatically run the extension setup command after Composer's require, install, or update operations. ```json { "scripts": { "post-install-cmd": [ "vendor/bin/typo3 extension:setup" ], "post-update-cmd": [ "vendor/bin/typo3 extension:setup" ], "post-require-cmd": [ "vendor/bin/typo3 extension:setup" ] } } ``` -------------------------------- ### Full Project Routing Configuration Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Routing/Examples/Index.rst A comprehensive routing configuration example taken from a live project. ```yaml imports: - resource: "EXT:my_site_package/Configuration/Routes/Default.yaml" routeEnhancers: MyEnhancer: type: Extbase extension: MyExtension plugin: "plugin" routes: "- { routePath: "/my-route/{parameter}", _options: parameters: parameter: "parameter" }" defaultController: "Standard::execute" suffixVisible: true AnotherEnhancer: type: PageType routePath: "/page-type/{pageType}" default: "_route_params": pageType: "123" requirements: pageType: - "\d+" ``` -------------------------------- ### Get Site Path Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the path part to the frontend. Example: '/some/sub/dir/'. ```php $normalizedParams->getSitePath() ``` -------------------------------- ### Example settings.php structure Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Configuration/Typo3ConfVars/Index.rst Illustrates the typical structure of the settings.php file, showing a two-level array for system-wide configuration categories and properties. ```php [ 'host' => 'localhost', 'username' => 'db_user', 'password' => 'db_password', 'database' => 'db_name', 'socket' => '', 'driver' => 'mysqli', ], // Mailer configuration 'MAIL' => [ 'transport' => 'smtp', 'transport_smtp_server' => 'smtp.example.com', 'transport_smtp_port' => 25, 'transport_smtp_username' => '', 'transport_smtp_password' => '', 'defaultMailFromAddress' => 'noreply@example.com', 'defaultMailFromName' => 'Example TYPO3 Site', ], // Frontend configuration 'FE' => [ 'debug' => false, 'loginControllerEnabled' => true, ], // Backend configuration 'BE' => [ 'debug' => false, 'install' => false, ], // Other settings can be added here ]; ``` -------------------------------- ### Start TYPO3 Webserver Container Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/DockerDemo/Index.rst Use this command to start the TYPO3 webserver container. Ensure the container name 'typo3-demo' is correct. ```bash docker start typo3-demo ``` -------------------------------- ### Get Frontend TypoScript Setup Array Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Configuration/TypoScript/PhpApi/Index.rst Accesses the parsed frontend TypoScript setup as an array from the request attributes. This is typically used within TYPO3 frontend controllers. ```php $fullTypoScript = $request->getAttribute('frontend.typoscript')->getSetupArray(); ``` -------------------------------- ### Creating Instances with GeneralUtility::makeInstance Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Namespaces/Index.rst Demonstrates the recommended way to create instances of classes using GeneralUtility::makeInstance, which leverages autoloading. Ensure necessary classes are imported using 'use' statements. ```php use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); ``` -------------------------------- ### Run database schema setup via Composer Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Database/DatabaseUpgrade/Index.rst Use this command to add tables and columns defined by installed or updated extensions when using a Composer-based TYPO3 installation. ```bash vendor/bin/typo3 extension:setup ``` -------------------------------- ### Update Dockerfile for gosu and Node.js Installation Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/AutomateSetup/Index.rst Extend the Dockerfile to install `gosu` for secure user switching and include the `startup.sh` script to automate the TYPO3 setup process. ```docker FROM martinhelmich/typo3:latest RUN apt-get update && apt-get install -y --no-install-recommends gosu nodejs npm && apt-get clean && rm -rf /var/lib/apt/lists/* COPY startup.sh /usr/local/bin/startup.sh RUN chmod +x /usr/local/bin/startup.sh ENTRYPOINT ["/usr/local/bin/startup.sh"] ``` -------------------------------- ### Complete ext_localconf.php Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/BestPractises/ConfigurationFiles.rst This is a complete example of an ext_localconf.php file for an extension, demonstrating various best practices. ```php getScriptName() ``` -------------------------------- ### Site Setting Definition Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/SiteHandling/SiteSettingDefinitions.rst An excerpt from a `settings.definitions.yaml` file demonstrating how to define site settings for a blog example. ```yaml categories: - label: "Blog" settings: - label: "Blog posts per page" type: "int" default: 10 - label: "Enable comments" type: "boolean" default: true - label: "Comment form" type: "text" default: "

Leave your comment

" - label: "Date format" type: "string" default: "Y-m-d" - label: "Date format (PHP)" type: "string" default: "Y-m-d" description: "Configure `Y-m-d` to be used in `bar`." - label: "Date format (PHP)" type: "string" default: "Y-m-d" category: "Blog" readonly: true - label: "Post order" type: "string" default: "newest" enum: ["newest", "oldest"] ``` -------------------------------- ### Get Request Host Only Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the host or domain or IP address only. Example: 'www.domain.com'. ```php $normalizedParams->getRequestHostOnly() ``` -------------------------------- ### Run database schema setup without Composer Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Database/DatabaseUpgrade/Index.rst Use this command to add tables and columns defined by installed or updated extensions in a classic TYPO3 installation mode (without Composer). ```bash typo3/sysext/core/bin/typo3 extension:setup ``` -------------------------------- ### Get Site URL Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the full website frontend URL. Example: 'https://www.domain.com/some/sub/dir/'. ```php $normalizedParams->getSiteUrl() ``` -------------------------------- ### Manual File Upload Configuration Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/Extbase/Reference/FileUpload.rst Excerpt of an Extbase Controller demonstrating manual file upload configuration within the initialize*Action method. ```php setUploadFolder('1:/user_upload/files/'); $uploadConfiguration->addValidator(FileExtensionValidator::class, ['allowedExtensions' => ['jpg', 'png']]); $this->request->setArgument('myFile', $uploadConfiguration); } public function uploadAction( array $myFile ): void { // ... handle uploaded file ... } } ``` -------------------------------- ### Get Script Filename Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the absolute path of the entry script on the server. Example: '/var/www/typo3/index.php'. ```php $normalizedParams->getScriptFilename() ``` -------------------------------- ### Full Extbase Plugin Configuration Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/ExtbaseRewrite/Registration/FrontendPlugin.rst This example demonstrates a complete TypoScript configuration for an Extbase plugin, covering view, persistence, and settings. It shows how to set template paths, storage PID, and items per page. ```typoscript plugin.tx_myextension_conferencelist { view { templateRootPaths.10 = EXT:my_extension/Resources/Private/Templates/ } persistence { storagePid = {$plugin.tx_myextension_conferencelist.persistence.storagePid} } settings { itemsPerPage = 10 } } ``` -------------------------------- ### Display all available TYPO3 commands Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/CommandControllers/Index.rst Use the appropriate entry point for your TYPO3 installation to list all available commands. This is useful for discovering and understanding the CLI's capabilities. ```bash vendor/bin/typo3 ``` ```bash typo3/sysext/core/bin/typo3 ``` ```bash ddev typo3 ``` ```bash bin/typo3 ``` -------------------------------- ### Get Document Root Path Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the absolute path to the web document root. Example: /var/www/typo3. ```php $normalizedParams->getDocumentRoot() ``` -------------------------------- ### Basic Comparison Examples Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Database/DoctrineDbal/ExpressionBuilder/Index.rst Demonstrates various comparison methods like eq(), gte(), like(), notInSet(), and in(). Emphasizes the importance of proper parameter quoting and escaping for security. ```php // `bodytext` = 'foo' - string comparison ->eq('bodytext', $queryBuilder->createNamedParameter('foo')) ``` ```php // `tt_content`.`bodytext` = 'foo' ->eq('tt_content.bodytext', $queryBuilder->createNamedParameter('foo')) ``` ```php // `aTableAlias`.`bodytext` = 'foo' ->eq('aTableAlias.bodytext', $queryBuilder->createNamedParameter('foo')) ``` ```php // `uid` = 42 - integer comparison ->eq('uid', $queryBuilder->createNamedParameter(42, Connection::PARAM_INT)) ``` ```php // `uid` >= 42 ->gte('uid', $queryBuilder->createNamedParameter(42, Connection::PARAM_INT)) ``` ```php // `bodytext` LIKE 'lorem' ->like( 'bodytext', $queryBuilder->createNamedParameter( $queryBuilder->escapeLikeWildcards('lorem') ) ) ``` ```php // `bodytext` LIKE '%lorem%' ->like( 'bodytext', $queryBuilder->createNamedParameter( '%' . $queryBuilder->escapeLikeWildcards('lorem') . '%' ) ) ``` ```php // usergroup does not contain 42 ->notInSet('usergroup', $queryBuilder->createNamedParameter('42')) ``` ```php // `uid` IN (42, 0, 44) - properly sanitized, mind the intExplode and PARAM_INT_ARRAY ->in( 'uid', $queryBuilder->createNamedParameter( GeneralUtility::intExplode(',', '42, karl, 44', true), Connection::PARAM_INT_ARRAY ) ) ``` ```php // `CType` IN ('media', 'multimedia') - properly sanitized, mind the PARAM_STR_ARRAY ->in( 'CType', $queryBuilder->createNamedParameter( ['media', 'multimedia'], Connection::PARAM_STR_ARRAY ) ) ``` -------------------------------- ### Get Icon Example in ES6 Module Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Icon/Index.rst Demonstrates how to use the Icons.getIcon() method within an ES6 module to retrieve and log an icon. This example shows fetching a 'spinner-circle-light' icon with small size and disabled state. ```js import Icons from '@typo3/backend/icons.js'; class MyEs6Module { constructor() { // Get a single icon Icons.getIcon('spinner-circle-light', Icons.sizes.small, null, 'disabled').then((icon: string): void => { console.log(icon); }); } } export default new MyEs6Module(); ``` -------------------------------- ### Dockerfile Excerpt for Startup Script Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/ExtendImage/Index.rst This Dockerfile excerpt shows how to copy a custom startup script into the image and set it as the entrypoint. ```docker USER root COPY ./startup.sh /usr/local/bin/startup.sh RUN chmod +x /usr/local/bin/startup.sh USER www-data ENTRYPOINT ["/usr/local/bin/startup.sh"] ``` -------------------------------- ### Blog Model with Constructor and initializeObject() (No Domain Rules) Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/Extbase/Reference/Domain/Model/Hydrating/Index.rst A recommended setup for a Blog model when no specific domain rules need to be enforced by the constructor. It includes both a constructor and an initializeObject() method for proper initialization. ```php */ protected $posts; public function __construct() { $this->initializeObject(); } protected function initializeObject(): void { $this->posts = new ObjectStorage(); } public function getTitle(): string { return $this->title; } public function setTitle(string $title): { $this->title = $title; } // ... other methods } ``` -------------------------------- ### Get Request Script URI Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the request URI without the query part. Example: 'http://www.domain.com/typo3/index.php'. ```php $normalizedParams->getRequestScript() ``` -------------------------------- ### Create Directories and Docker Network Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/DockerDemo/Index.rst Prepare project directories and create a Docker network for the TYPO3 demo. On Linux/WSL, ensure write permissions for TYPO3. ```bash mkdir -p fileadmin typo3conf typo3temp # On Linux and WSL during development: Ensure TYPO3 can write to these directories # chmod -R 777 fileadmin typo3conf typo3temp docker network create typo3-demo-net ``` -------------------------------- ### Get Request Host with Protocol Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the sanitized HTTP_HOST value with the protocol scheme. Example: 'https://www.domain.com/'. ```php $normalizedParams->getRequestHost() ``` -------------------------------- ### Get Sanitized HTTP Host Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the sanitized HTTP_HOST value, including the port if specified. Example: 'www.domain.com:8080'. ```php $normalizedParams->getHttpHost() ``` -------------------------------- ### Deployment Cache Warmup Example Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/CachingFramework/Index.rst Example command for warming the 'system' cache group on the live system during deployment preparation. This ensures file-related caches are ready before the release symlink is switched. ```bash vendor/bin/typo3 cache:warmup --group system ``` -------------------------------- ### Get User TSconfig Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Backend/BackendUserObject.rst Retrieves the user's TSconfig configuration. This example specifically accesses the 'options.clipboardNumberPads' value. ```php $tsconfig = $GLOBALS['BE_USER']->getTSConfig(); $clipboardNumberPads = $tsconfig['options.']['clipboardNumberPads'] ?? ''; ``` -------------------------------- ### Verify TYPO3 Setup Execution via Docker Logs Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/Administration/Docker/AutomateSetup/Index.rst Check the Docker logs to confirm that the setup script executed on startup. The expected output indicates whether setup was run or skipped. ```bash docker logs -f compose-demo-typo3 ``` -------------------------------- ### Example Site Set Configuration (config.yaml) Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ExtensionArchitecture/FileStructure/Configuration/Sets/Index.rst Defines the structure and dependencies of a site set. This file is mandatory for every set. ```yaml imports: - resource: "EXT:my_extension/Configuration/Sets/Base/config.yaml" setup: # ... site set specific setup ... ``` -------------------------------- ### Get Site Script with Parameters Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/CodeSnippets/Manual/Entity/NormalizedParams.rst.txt Retrieves the path to the entry script with parameters, excluding subdirectories. Example: 'typo3/index.php?id=42'. ```php $normalizedParams->getSiteScript() ``` -------------------------------- ### Example: Building a Module Header Source: https://github.com/typo3-documentation/typo3cms-reference-coreapi/blob/main/Documentation/ApiOverview/Backend/BackendModules/DocHeaderComponent.rst This example demonstrates how to use the DocHeaderComponent to register buttons and a menu for the module header. ```APIDOC ## Example: Build a module header with buttons and a menu We use the DocHeaderComponent to register buttons and a menu to the module header. .. include:: _AboutBlogExample.rst.txt .. include:: _ModifyDocHeaderComponent.rst.txt ```