Skip to content

Instantly share code, notes, and snippets.

@benjaminkott
Last active November 22, 2018 13:25
Show Gist options
  • Save benjaminkott/04453f795f659b26778f8e3339f725a6 to your computer and use it in GitHub Desktop.
Save benjaminkott/04453f795f659b26778f8e3339f725a6 to your computer and use it in GitHub Desktop.
Create TYPO3 Project Windows
# Database Credentials
TYPO3_DB_CONNECTIONS_DEFAULT_HOST = "db"
TYPO3_DB_CONNECTIONS_DEFAULT_PORT = 3306
TYPO3_DB_CONNECTIONS_DEFAULT_USER = "db"
TYPO3_DB_CONNECTIONS_DEFAULT_PASS = "db"
TYPO3_DB_CONNECTIONS_DEFAULT_NAME = "db"
# Graphics
TYPO3_GFX_PROCESSOR = "ImageMagick"
TYPO3_GFX_PROCESSOR_PATH = "/usr/bin/"
TYPO3_GFX_PROCESSOR_PATH_LZW = "/usr/bin/"

Demo Setup (Windows)

Prerequisites

  1. You have Windows 10 Pro (if not buy it!)
  2. Git installed on Windows
  3. sh installed on Windows and added to the PATH (C:\Program Files\Git\bin)
  4. Docker installed on Windows
  5. DDEV installed on Windows

Start Powershell

Press WIN+ X then A

Starting Docker with DDEV

  1. mkdir <projectname>

  2. cd <projectname>

  3. ddev config --project-type php --php-version 7.2 --docroot public --create-docroot

  4. ddev start

  5. ddev auth ssh

    Note: You may need to restart Docker on Windows if you are getting an error, after restarting Docker the problem should not occur anymore. Simply restart the command.

    Example: ERROR: for ddev-project-db Cannot start service db: driver failed programming external connectivity on endpoint ddev-project-db (7044e9fd1a97d702155ca50b7a706704e9e5afa38c075a3b25a5e5edd6279b7b): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:32859:tcp:172.18.0.9:3306: input/output error

  6. Open frontend with urls shown in commandline. The format is always http://<projectname>.ddev.local

    Note: The hosts file on windows can only contain a certain amount of hosts per line, if the provided url cannot be resolved please break the automaticly added hostnames into multiple lines. The hosts file is usually located in C:\Windows\System32\drivers\etc\hosts

    Before

    127.0.0.1 project1.ddev.local project2.ddev.local
    

    After

    127.0.0.1 project1.ddev.local
    127.0.0.1 project2.ddev.local
    

Initialize Project

ddev composer init --name vendorname/project --type project ddev composer config bin-dir bin

Require TYPO3

ddev composer require typo3/cms-about typo3/cms-adminpanel typo3/cms-backend typo3/cms-belog typo3/cms-beuser typo3/cms-core typo3/cms-extbase typo3/cms-extensionmanager typo3/cms-feedit typo3/cms-felogin typo3/cms-filelist typo3/cms-filemetadata typo3/cms-fluid typo3/cms-fluid-styled-content typo3/cms-form typo3/cms-frontend typo3/cms-impexp typo3/cms-indexed-search typo3/cms-info typo3/cms-install typo3/cms-linkvalidator typo3/cms-lowlevel typo3/cms-opendocs typo3/cms-recordlist typo3/cms-recycler typo3/cms-redirects typo3/cms-reports typo3/cms-rsaauth typo3/cms-rte-ckeditor typo3/cms-scheduler typo3/cms-seo typo3/cms-setup typo3/cms-sys-action typo3/cms-sys-note typo3/cms-t3editor typo3/cms-taskcenter typo3/cms-tstemplate typo3/cms-viewpage typo3/cms-workspaces

Note: this is the full TYPO3 Package you may want to customize it to your own needs. Please check https://get.typo3.org/misc/composer/helper.

Add .env Support

  1. ddev composer require vlucas/phpdotenv
  2. ddev exec curl https://gist.githubusercontent.com/benjaminkott/04453f795f659b26778f8e3339f725a6/raw/0eded45de81b086b854cfa020ca734aefaba55ba/.env.dist --output .env.dist
  3. ddev exec mkdir public/typo3conf
  4. ddev exec touch public/typo3conf/AdditionalConfiguration.php
  5. ddev exec curl https://gist.githubusercontent.com/benjaminkott/04453f795f659b26778f8e3339f725a6/raw/0eded45de81b086b854cfa020ca734aefaba55ba/AdditionalConfiguration.php --output public/typo3conf/AdditionalConfiguration.php

Install TYPO3

  1. ddev exec touch public/FIRST_INSTALL
  2. Open frontend, if you forgot the urls use ddev describe to get the hostname
  3. Follow install instructions
  4. ddev exec bin/typo3 extension:activate filemetadata
  5. ddev exec bin/typo3 extension:activate indexed_search
  6. ddev exec bin/typo3 extension:activate recycler
  7. ddev exec bin/typo3 extension:activate scheduler
  8. ddev exec bin/typo3 extension:deactivate sys_note

Install Bootstrap Package

  1. ddev composer require bk2k/bootstrap-package
  2. ddev exec vendor/typo3/cms-cli/typo3 extension:deactivate fluid_styled_content
  3. ddev exec vendor/typo3/cms-cli/typo3 extension:activate bootstrap_package

Sitepackage

For further customizing we need to create a Sitepackage to have a deployable package with all additional configuration and assets included. Sitepackages for the Bootstrap Package can be easily generated by heading to https://sitepackagebuilder.com.

  1. Select Version 9.5
  2. Select Bootstrap Package as Base
  3. Fill out the other form fields required and click Create Sitepackage
  4. ddev exec mkdir extensions
  5. ddev exec mkdir extensions/<sitepackagename>
  6. Extract sitepackage into this directory
  7. ddev composer config repositories.extensions path extensions/*
  8. ddev composer require <vendor>/<packagename> Note: The package name can be cound in the composer.json in the directory you just extracted
  9. ddev exec curl https://gist.githubusercontent.com/ohader/f4b792e0bb99e79efe75605008ce4a0d/raw/89119a77ade100f92b4775c2b2d62dc1c6d63166/use-native-symlinks.bat --output file-use-native-symlinks.bat
  10. .\file-use-native-symlinks.bat
  11. ddev exec bin/typo3 extension:activate <sitepackagename>

Create Page

  1. Create Page on Rootpage
  2. Edit Page and set the following options
    Behaviour > Miscellaneous > Use as Root Page = true
    Access > Visibility > Page visible = true
    
  3. Go to Template Module
  4. Select the Root Page you just created
  5. Create template for a new site -> Save
  6. Select Info/Modify in document header dropdown
  7. Click Edit the whole template record and set the following options
    General > Website Title -> Set the string that should be displayed in the title after the name of the current page
    General > Setup -> Clear this field, it should be empty
    Includes > Include static (from extensions) -> only include the tempalte from the Sitepackage you created
    

Create Site

  1. Go to Sites Module
  2. Click Add new site configuration for this site and set the following options
    General > Site Identifier = <sitepackagename>
    General > Entry Point -> set the frontend url
    Languages -> Configure the languages as reuired
    
<?php
$loader = new Dotenv\Dotenv(__DIR__ . '/../../', '.env.dist');
$loader->overload();
if (file_exists(__DIR__ . '/../../.env')) {
$loader = new Dotenv\Dotenv(__DIR__ . '/../../');
$loader->overload();
}
// Database Credentials
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['host'] = getenv('TYPO3_DB_CONNECTIONS_DEFAULT_HOST');
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['port'] = getenv('TYPO3_DB_CONNECTIONS_DEFAULT_PORT');
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['user'] = getenv('TYPO3_DB_CONNECTIONS_DEFAULT_USER');
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['password'] = getenv('TYPO3_DB_CONNECTIONS_DEFAULT_PASS');
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = getenv('TYPO3_DB_CONNECTIONS_DEFAULT_NAME');
// Graphics
$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor'] = getenv('TYPO3_GFX_PROCESSOR');
$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'] = getenv('TYPO3_GFX_PROCESSOR_PATH');
$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path_lzw'] = getenv('TYPO3_GFX_PROCESSOR_PATH_LZW');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment