Skip to content

Instantly share code, notes, and snippets.

@helhum
Last active February 12, 2024 10:54
Show Gist options
  • Save helhum/2ee31dc411b7c014ab9148becce0d55b to your computer and use it in GitHub Desktop.
Save helhum/2ee31dc411b7c014ab9148becce0d55b to your computer and use it in GitHub Desktop.
The (currently) ideal TYPO3 composer setup
{
"require": {
"typo3-console/composer-auto-setup": "^0.1",
"georgringer/news": "^6.1",
"helhum/typo3-secure-web": "^0.2.5",
"typo3/cms-introduction": "^3.0"
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "public",
"root-dir": "private"
},
"helhum/typo3-console": {
"install-extension-dummy": "0"
}
},
"require-dev": {
"typo3-console/php-server-command": "^0.1.1"
}
}
#!/bin/bash
####################################################################################################################
# These are the command line steps to get to a composer.json file you see below
# I suggest to exeute them if you want to learn step by step what happens in each step
# However if you just want results, use the composer.json above
####################################################################################################################
# Create a new directory and switch into it
mkdir demo && cd demo
# Start with initializing git version control
git init && git commit --allow-empty -m 'initial commit'
# That is how we started a few years ago
composer require typo3/cms
# Save the current composer.json in git history
git add composer.json && git commit -m "Add composer.json"
# Move the TYPO3 package to the composer standard location
composer config extra.typo3/cms.cms-package-dir '{$vendor-dir}/typo3/cms'
# cleanup and re-install
git clean -dffx && composer install
# Move most things out of the web server's document root
composer config extra.typo3/cms.web-dir 'public'
# cleanup and re-install
git clean -dffx && composer install
# Add a package which adds TYPO3 Console convenience to your composer execution (similar to minimum distribution)
# You will be asked for mysql credentials and other TYPO3 setup things in this step
composer require typo3-console/composer-auto-setup ^0.1
# Disable a deprecated console feature
composer config extra.helhum/typo3-console.install-extension-dummy 0
# Add some little dev helpers for starting a PHP based web server
composer require --dev typo3-console/php-server-command
# Start the server and investigate the backend (ctrl + c to quit)
typo3cms server:run
# Add Georg's News extension
composer require georgringer/news
# Go to the backend and directly add new records
typo3cms server:run
# Now to the really cool stuff
# Configure a "private" directory, which will be the place where your TYPO3 installation lives
composer config extra.typo3/cms.root-dir 'private'
# It previously lived in public, but will now be private, so move the dir upfront
# so we do not have to re-install everything during the demo
# The new things in the public folder will all be generated, thus this folder should be in .gitignore completely
mv public private
# To activate / evaluate the new settings and generate the public folder/files, require this package
composer require helhum/typo3-secure-web
# Uh, nice everything still works, but is secure by default.
# Change your extensions to have public assets in Resources/Public only to get the most out of it.
typo3cms server:run
# Bonus
# You can now even remove the full TYPO3 composer package and use the individual ones instead.
# helhum/typo3-secure-web comes with requirements to the basic TYPO3 extensions already.
# You can require other packages as well in your extensions or later in root composer.json
rm -rf vendor/typo3/cms private/typo3/sysext && composer remove typo3/cms
# One more thing
# If you require a distribution, it will import the data automatically after this command line
# So you can get a fully working TYPO3 website with one composer command (clone repo, composer install)
composer require typo3/cms-introduction
# make sure you also commit the lock file along with your composer.json once you're finished
git add composer.json composer.lock
git commit -m 'Finish demo distribution'
# Yes, you can verify that you have a full website now
typo3cms server:run
# Clean up and see that only composer.json and composer.lock remains
git clean -dffx
# After a composer install, you will be asked for db connection data and after process is finished
# you have a fully working TYPO3 installation including data
composer install
@helhum
Copy link
Author

helhum commented Dec 25, 2017

@josefglatz Extension Icons need to be in Resouces/Public/Icons/Extension.png

Works since TYPO3 8.7

@hirnschmalz
Copy link

Hi @helhum,

is this still your preferred way to setup TYPO3 via composer?

@helhum
Copy link
Author

helhum commented Oct 4, 2019

@hirnschmalz there are obviously different opinions on that, and some details have changed. But in general, that is still how I set up TYPO3 installations with Composer.

@Cponcax
Copy link

Cponcax commented Feb 13, 2020

hey! warning "typo3-console/composer-auto-setup": "^0.1" It is only compatible with PHP versions: >=7.0 < 7.2

Problem 1
- Installation request for typo3-console/composer-auto-setup ^0.1 -> satisfiable by typo3-console/composer-auto-setup[0.1.0].
- typo3-console/composer-auto-setup 0.1.0 requires php >=7.0 <7.2 -> your PHP version (7.2.24) does not satisfy that requirement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment