Skip to content

Instantly share code, notes, and snippets.

@orlissenberg
Last active August 29, 2015 14:24
Show Gist options
  • Save orlissenberg/5bfd346b3fb77de5981a to your computer and use it in GitHub Desktop.
Save orlissenberg/5bfd346b3fb77de5981a to your computer and use it in GitHub Desktop.
Create a TYPO3 extension directory structure.
#!/usr/bin/env bash
# TYPO3 - Extension directory structure
# http://docs.typo3.org/typo3cms/CodingGuidelinesReference/FileSystemConventions/ExtensionDirectoryStructure/Index.html
# This directory structure is strongly recommended. Extensions may create their own directories (for example, move all
# language files into other directories).
# execute from: typo3conf/ext
if [ $# -eq 0 ]
then
echo "Not enough arguments supplied.";
exit;
fi
if [ -d $1 ]; then
echo 'Directory already exists';
exit;
fi
CURRENT_DIR=${PWD}/$1
mkdir $1
cd $CURRENT_DIR;
# This file contains an array. This array maps class names to file paths. It gets loaded by the autoloader when the
# autoloader is initialized.
touch ext_autoload.php
# This is the only mandatory file in the extension. It describes the extension for the rest of TYPO3.
touch ext_emconf.php
# This is the icon of the extension. The filename may not be changed.
# ext_icon.gif or ext_icon.png
# This file contains hook definitions and plugin configuration. It must not contain a PHP encoding declaration.
# The filename may not be changed.
touch ext_localconf.php
# This file contains table declarations. It must not contain a PHP encoding declaration. For more information about
# table declarations and definitions see the "TYPO3 Core API" document. The filename may not be changed.
touch ext_tables.php
# This files contains SQL definitions for extension tables. The filename may not be changed.
touch ext_tables.sql
# These files contain localizable labels in standard XLIFF format, one language per file. They can also appear in
# subdirectories, e.g. inside Resources/.
# locallang*.xlf
# These files contain localizable labels in a custom XML based format, possibly multiple languages per file. They can
# also appear in subdirectories. Deprecated since TYPO3 4.6; use locallang*.xlf files instead.
# locallang*.xml
mkdir -p {'doc','Classes','Configuration','Documentation','Resources/Private','Resources/Public','Tests/Unit'}
# Extension Manual in OpenOffice format.
# doc/
cd $CURRENT_DIR/doc
# touch manual.sxw
# PHP files
# Classes/
cd $CURRENT_DIR/Classes
mkdir -p {'Controller','Domain/'{'Repository','Model'},'Service','View','Utility','Wizzard','ViewHelpers'}
# Directory for configuration files, in subfolders like TCA/ or TSconfig/. E.g. the subfolder TCA/ contains files
# named like tablename.php, which return an array of the configuration of the according table tablename.
# Configuration/
cd $CURRENT_DIR/Configuration
mkdir -p {'TCA','TSconfig','TypoScript','FlexForm'}
# Contains the subfolders Public/ and Private/, which contain resources.
# This is also the directory for non–TYPO3 files supplied with the extension. TYPO3 is licensed under GPL version 2
# or any later version. Any non–TYPO3 code must be compatible with GPL version 2 or any later version.
# Resources/
cd $CURRENT_DIR/Resources
cd $CURRENT_DIR/Resources/Private
mkdir -p {'Templates','Language','Layouts','Partials'}
cd $CURRENT_DIR/Resources/Public
mkdir -p {'CSS','Icons','Images','JavaScript'}
# This directory contains tests, e.g. unit tests in the subfolder Unit/.
# Tests/
cd $CURRENT_DIR/Tests
# Uncomment if needed.
# Deprecated since 6.x
rm -Rf $CURRENT_DIR/doc
rm $CURRENT_DIR/ext_autoload.php
# Personal preferences.
mkdir $CURRENT_DIR/Classes/Migration
mkdir $CURRENT_DIR/Classes/Helper
# mkdir $CURRENT_DIR/Classes/Eid
# mv $CURRENT_DIR/Classes/ViewHelpers $CURRENT_DIR/Classes/ViewHelper
mkdir $CURRENT_DIR/Resources/Public/Sass
# Don't use often:
rm -Rf $CURRENT_DIR/Classes/View
rm -Rf $CURRENT_DIR/Configuration/TSConfig
cat <<EOF >> $CURRENT_DIR/Configuration/.htaccess
deny from all
EOF
cat <<EOF >> $CURRENT_DIR/Resources/Private/.htaccess
deny from all
EOF
cat <<EOF >> $CURRENT_DIR/README.md
# TYPO3 Extension: $1
Description.
## Notes
EOF
# Extentsion base directory
cd $CURRENT_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment