How to Install TYPO3 Composer: Step-by-Step Guide

TYPO3 is able to run in composer mode. It's fast, it's good for deployment and has a web folder. This post explains what it takes to get your composer up and running.

How to Install TYPO3 Composer: Step-by-Step Guide

Manually Downloading, Installing and Updating TYPO3 Core and TYPO3 Extension

Are you still working the old-fashioned way - using the classic method to set up TYPO3 and its extensions on classic hosting - instead of simply performing a TYPO3 installation? Suppose you want to start a new TYPO3 project - how do you go about it?

Go to typo3.org, download the latest package (TYPO3 core and extensions), unzip it, copy the folder to your server directory, install it, run it, configure it, etc. Whew - that's way too time-consuming and inefficient for a simple TYPO3 installation. And then there are the following questions:

  • What about the version dependency of TYPO3 Core & Extensions?
  • What if you want to install many TYPO3 extensions? Then you need to constantly check the dependency of, download, install, configure and so on.
  • How to update TYPO3 core and many TYPO3 extensions - Again, A long journey of checking dependencies, downloading, installing/updating etc etc etc....the list is long!!!

There is a way to overcome this poor workflow, especially in TYPO3 installation, and improve the typo3 version . Let us introduce you: The Composer. All you need to do is to apply some commands to the terminal, which makes the process much easier.

Do you know the TYPO3 Composer Repository?

Composer - The dependency manager for PHP. Have you ever heard of https://getcomposer.org/? Composer is a tool for managing dependencies in PHP, and it is important to note the php version. It allows you to specify the libraries, including php 8.0, that your project depends on and it manages (installs/updates) them for you.

System requirements:

  • OS: Linux/Unix/OSX/Windows
  • Version: PHP 5.3.2 +
  • PHP settings: Some sensitive PHP settings and compilation flags are also required.
  • Versioning system: git, svn, fossil or hg, depending on how the package is version controlled.

How to set up Composer?

Install and configure Composer with the following steps - as a practical guide:

Step 1: Install Composer

Download and install Composer by following the instructions at https://getcomposer.org/download/ - with the help of online resources.

Step 2: Define composer.json

Create a composer.json file that defines your dependencies and describes the content of your project structure. Note that this example is only a short version for extension applications that are not to be published as a package and are specifically suitable for the current TYPO3 version, and use the typo3 composer for administration. The system extensions and also from the extension repository. To create libraries/packages, please read the documentation.


  "require":{ 
     "monolog/monolog": ">=1.0.0" 
  } 
}

Step 3: Run

Execute the composer command to start the installation. To do this, use: php composer.phar install

Step 4: Browse

Browse more packages on Packagist or look for support in the online community forums.

For more details such as the global installation of Composer, the composer version, updating Composer and more, visit getcomposer.org/doc/00-intro.md

What is the TYPO3 CMS Composer Repository?

getcomposer.org is a Composer repository that allows you to install the TYPO3 core and extensions including the dependencies on the Composer, as well as use the TYPO3 extension repository. Search for available TYPO3 extension packages at https://composer.typo3.org/ satis. html

How to use Composer for TYPO3 Core and TYPO3 Extension?

We will show you how to quickly use Composer to efficiently build your TYPO3 website and optimize the hosting package based on this guide. You can download the TYPO3 Core - Base Distribution with the following steps:

Step 1: Download the TYPO3 CMS base distribution

The current "Stable" version (e.g. 7.6):

Command: composer create-project typo3/cms-base-distribution CmsBaseDistribution

The "Dev" branch (e.g. version 8.1):

Command: composer create-project typo3/cms-base-distribution CmsBaseDistribution dev-master

The "dev" branch for TYPO3 7.6:

Command: composer create-project typo3/cms-base-distribution CmsBaseDistribution 7.6.x-dev

Step 2: Add additional TYPO3 packages/extensions

Now we add TYPO3 extensions using Composer - with the right command. The commands must be executed in the "CmsBaseDistribution" directory.

# Add a CMS extension into typo3conf/ext.
composer require typo3-ter/news
-> if asked for a version constraint, answer with *.
# Add a package from outside the CMS world into Packages/Libraries
# Notice: Packages/Libraries/autoload.php will need to be included in your code.
composer require monolog/monolog
# Personalize your composer.json file to your needs.
edit composer.json

Using Composer to install TYPO3 is quite simple. All you need to do is include the custom composer repository in your composer.json. Once you have done this, you can request the core and/or extensions with the current composer version, the usual composer versioning format, which provides comprehensive composer support. In the following example, you will always receive the current 7.6.x core of TYPO3, the current typo3 version and the news. (including possible dependencies!).

Note:Replace underscores ("_") with hyphens ("-") in the extension key. For example, the extension "tt_products" is written as "tt-products" in the composer.json.

{
"repositories": [
       {"type": 
        "composer",
        "url": "https://composer.typo3.org/" 
        }
],
"require": { 
       "typo3/cms": "^7.6.9",
       "typo3-ter/news": "^3.2.5" 
        }, 
       "extra": { 
              "typo3/cms": { 
                     "cms-package-dir": "{$vendor-dir}/typo3/cms",
                     "web-dir": "web" 
              }
       }
}

Do you have your own customized TYPO3 extension that may need system extensions? It is recommended to add your own composer.json file to your extension to be on the safe side and follow detailed instructions as TYPO3 will rely more and more on Composer and admin tools to handle dependencies. The file must be located in the root directory of your extension and should be structured as follows:

{
  "name": "vendor-name/my-ext-key",
  "type": "typo3-cms-extension",
  "description": "Write down your description of extension",
  "homepage": "https://yoursite.com",
  "license": ["GPL-2.0+"],
  "keywords": ["TYPO3 CMS", "keyword1 keyword2"],
  "support": {
      "issues": "https://forge.typo3.org/projects/extension-my_ext_key"
  },
  "require": {
      "typo3/cms-core": "^6.2.14 || ^7.6.0"     
  },
  "autoload": {
      "psr-4": {
            "VendorName\\MyExtKey\\": "Classes/"
      }
  },
  "replace": {
      "my_ext_key": "self.version", 
      "typo3-ter/my-ext-key": "self.version"
  } 
}

The vendor name must be one of yours, especially if you are accessing via SSH. It must not be "typo3", which is reserved for core extensions. In the TYPO3 wiki, there are some notes on conventions regarding namespaces, which are a great advantage for developers.

Sample composer.json

{
 "repositories": [
	 { 
	 	"type": "composer", 
	 	"url": "https://composer.typo3.org/"
	 }
 ],

 "name": "NITSAN/composer-example", 
 "description" : "TYPO3 Core & News extensions example composer.json.", 
 "license": "GPL-2.0+", 
 "require": { 
	 	"typo3/cms": "^7.6", 
	 	"typo3-ter/news": "^4.0"
 }, 
 "extra": { 
	"typo3/cms": { 
		"cms-package-dir": "{$vendor-dir}/typo3/cms", 
		"web-dir": "web"
	} 
 } 
 "replace": { 
 	"ext_news": "self.version", 
 	"typo3-ter/ext-news": "self.version" 
 },
 "autoload": { 
	"psr-4": { 
		"GeorgRinger\\ExtNews\\": "Classes" 
	}
 },
}

Contact for Internet agency and TYPO3 projects

Sven Thelemann

Service Partner - Germany

Sven Thelemann

Comments and Responses

×

Name is required!

Enter valid name

Valid email is required!

Enter valid email address

Comment is required!

* These fields are required.

Be the First to Comment