Zum Inhalt springen

Composer

What is Composer and how can I use Composer at jweiland.net?

What is Composer?

Composer is a manager that can resolve dependencies between different software packages. However, the package to be installed is not installed globally on the operating system, but only in a desired project directory. This means that if you have several projects that require the same package, this package is downloaded again for each project directory.

Composer can also distinguish between different versions. For example, the same package may be required in a different version in directory X than in directory Y.

Composer and TYPO3

As an end user of TYPO3, you won't notice much about Composer. The download version of TYPO3 as a tar.gz or zip file already contains all the required packages, such as the SwiftMailer and the Symfony Console.

If you are a developer or interested in TYPO3 and want to have a look at the current development status of TYPO3, you have to download the TYPO3 source code from the GIT repository. However, the packages mentioned above are not included here and, since TYPO3 6.2, must be installed using Composer.

Here we have a Instructions for installing TYPO3 with Composer.

Composer at jweiland.net

In our cloud hosting plansand on the Classic hosting plans, Composer version 2 is already pre-installed and can be used directly.

Change default PHP version for the entire package

For current TYPO3 versions (11.5.x, 12.4.x), the default PHP version must be changed so that Composer can be called with 'composer' on the shell for the above-mentioned TYPO3 versions.

Connect to the web server via SSH and then carry out the following steps:

1. create the .local/bin directory in your hosting package root directory:

mkdir -p $HOME/.local/bin

2. navigate to the directory you have just created:

cd $HOME/.local/bin

3. change the default PHP version on the console

# for PHP 8.0
ln -s /usr/bin/php80 $HOME/.local/bin/php

# for PHP 8.1
ln -s /usr/bin/php81 $HOME/.local/bin/php

# for PHP 8.2
ln -s /usr/bin/php82 $HOME/.local/bin/php

# for PHP 8.3
ln -s /usr/bin/php83 $HOME/.local/bin/php

The easiest way to use Composer in the entire hosting package is to add the current folder to the PATH variable. This variable contains the locations where executable files are located. This means that the composer and php commands can be called later as we wish.

4. extend PATH variable

Create a .bash_profile file in the root directory of the hosting package, for example with the nano editor:

nano $HOME/.bash_profile

Add the following line to this file. This adds the previously created directory to the PATH variable.

export PATH=$HOME/.local/bin:$PATH

Then save the file and exit the editor.

For these changes to take effect, the .bash_profile file must be reloaded with the following command:

source $HOME/.bash_profile

Composer can then be called up directly in the entire hosting package with the command "composer".

This page contains automatically translated content.

Updated: 12.09.2024