Table of content
Manually install & Update TYPO3 Extension and TYPO3 Core
Are you still working the old-school way to setup TYPO3 & extensions? Suppose you want to start any new TYPO3 project then how do you that? Go to typo3.org & download latest package (of TYPO3 core & extensions), Unzip the package, Copy/Paste folder to your server directory, install, run, configure, setup, & so on.. Yuck, too time consuming and inefficient for just setting up TYPO3. And then also ask you self about the following points.
- What about version dependencies of TYPO3 core & extensions?
- What if you want to install lot of TYPO3 Extensions? Then again you’ll be continuously checking the dependencies, downloading, installing, configuring & so on..
- How to upgrade/updates TYPO3 core & many TYPO3 extensions - Again long journey of checking dependencies, downloading, installing/updating etc etc etc….the list is long!!
There is a way to overcome this bad workflow. Let us introduce to you: The Composer. All you have to do is applying few commands to terminal & configuring one file - Composer will take care of the rest.
Do you know the Composer Repository?
Composer - The dependency manager for PHP. Have you ever heard about https://getcomposer.org/? Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
System Requirements:
- OS: Linux/Unix/OSX/Windows
- Version: PHP 5.3.2 +
- PHP settings: A few sensitive php settings and compiling flags are also required
- Versioning System: git, svn, fossil or hg depending on how the package is version-controlled.
How to setup Composer?
Let’s install & configure Composer with below steps:
Step 1: Install composer
Download & install composer by following the instructions on https://getcomposer.org/download/
Step 2: Define composer.json
Create a composer.json defining your dependencies. Note that this example is just a short version for applications that are not meant to be published as packages themselves. To create libraries/packages please read the documentation.
{ "require":{ "monolog/monolog": ">=1.0.0" } }
Step 3: Run
Run Composer Command: php composer.phar install
Step 4: Browse
Browse for more packages on Packagist.
Checkout more details like Global installation of Composer, Updating composer & more at getcomposer.org/doc/00-intro.md
What is TYPO3 CMS Composer Repository?
getcomposer.org is a composer repository, enabling you to install TYPO3 CMS core and extensions including dependencies via Composer. Search for available TYPO3 Extensions Packages at https://composer.typo3.org/ satis.html
How to use TYPO3 CMS Composer for TYPO3 Core & Extensions?
Let us show you a quick way to use Composer, the TYPO3 Core - Base Distribution can be downloaded by following these steps:
Step 1: Download the TYPO3 CMS Base Distribution
the latest "stable" release (7.6)
Command: composer create-project typo3/cms-base-distribution CmsBaseDistribution
the "dev" branch (8.1)
Command: composer create-project typo3/cms-base-distribution CmsBaseDistribution dev-master
the "dev" 7.6 branch
Command: composer create-project typo3/cms-base-distribution CmsBaseDistribution 7.6.x-dev
Step 2: Add additional TYPO3 packages/extensions
Now, let’s add TYPO3 extensions too through composer. The commands must run inside 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 CMS is fairly simple, you just need to include the custom composer repository into your composer.json. After you have done this, you can require the Core and / or extensions with the usual composer versioning format. In the example below, this will always get you the current 7.6.x core of TYPO3 CMS, the current version of news (including possible dependency!).
Note: Pay attention to replacing the underscores "_" with a dash "-" in the extension key. For example, the extension "tt_products" will be 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 custom made TYPO3 extension? It is encouraged to add your own composer.json file in your extension to be on the safe side, as TYPO3 CMS will rely more and more on Composer to handle dependencies. The file must be placed at the root of your extension and must look like the following:
{ "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. It must not be "typo3" which is reserved for Core extensions. There are some conventions notes available in the TYPO3 Wiki related to namespaces.
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" } }, }
References for TYPO3 Composer:
- https://getcomposer.org/
- https://usetypo3.com/typo3-and-composer.html
- http://insight.helhum.io/post/130812561790/changes-in-class-loading-in-typo3-7lts
- https://typo3.slack.com/messages/typo3-cms-composer/
- http://insight.helhum.io/post/130876393595/how-to-configure-class-loading-for-extensions-in
Go with Composer, To setup Quick & Smart TYPO3 Projects.
Contact for Internet agency and TYPO3 projects
Sven Thelemann
Service Partner - Germany
Be the First to Comment