Table of content
Our App Store is Called TER - and It's Free! ~ TYPO3 GmbH
Why Composer + Git + Packagist
According to the current trend of product and extension development, the Composer is one of the most popular dependencies techniques in PHP Open Source that will help you to develop, publish and maintain your extension easily.
Advantages like; Release management, Accurate dependencies, Easy installation, and upgradation, etc.,
Nowadays, most of the OpenSource CMS and Frameworks are used as the “ideal model”.
Prepare your extension for Composer
Do you want your TYPO3 extension to be easily installed with magic composer command?
No need to go TER site, download the extension, install from Extension manager, etc., Just write simple command eg.,
composer require nitsan/ns-news-comments
Once you complete your extension with well QA testing and code review. Setup composer.json at the root of your extension.
You must consider the following most important things:
- Name: vendor-name/extension-name
- Type: typo3-cms-extension
- Must requirement: Make sure to define exact dependencies of your extension, for eg., TYPO3 CMS core, Other TER extensions, PHP version dependencies, etc.,
- Autoload: It is highly recommended to set it up because your extension should run without composer mode too. VendorName\\ExtensionsName (you may find exact words from your any controller file from \Controller\ folder.
Sample composer.json of our popular TYPO3 EXT:ns_news_comments. Composer at Step by step guide to TYPO3 Composer and dedicated TYPO3 site.
{
"name": "nitsan/ns-news-comments",
"type": "typo3-cms-extension",
"description": "This extension allows user to post comment on particular news, reply to the comments. This extension is compatible only with News system Extension.",
"homepage": "https://extensions.typo3.org/extension/ns_news_comments/",
"license": "GPL-3.0+",
"keywords": [
"TYPO3 CMS",
"News Comment"
],
"support": {
"issues": "https://github.com/nitsan-technologies/ns_news_comments/issues"
},
"require": {
"typo3/cms-core": ">=6.2.0",
"georgringer/news": ">=3.0.0"
},
"autoload": {
"psr-4": {
"Nitsan\\NsNewsComments\\": "Classes/"
}
},
"replace": {
"ns_news_comments": "self.version",
"nitsan/ns-news-comments": "self.version"
},
"extra": {
"typo3/cms": {
"extension-key": "ns_news_comments"
}
}
}
Version your code with Git
As you are aware of the power of Git, Choose your favorite Git platform like Gitlab, Github, BitBucket, etc.,
We prefer Gitlab, but since a long time we are maintaining our extension at Github so let us give you an overview of it.
Initiate your Git repository
Step 1: Register and log-in at https://github.com/
Step 2: You will have your personal landing page like https://github.com/nitsan-technologies
Step 3: Go to Dashboard > Repositories tab > Click on “New” button. Or, you may simply go here https://github.com/new to create a new repository.
Step 4: Create a new repository by filling-up details in the form, and your public repository will be ready.
You’ll have to fill up the following fields:
- Repository name: Enter your extension key
- Description: You can simply put a description from your ext_emconf.php
- Permission: Choose Public, because it’s TER.
Connecting code with Git
Now, let’s setup Git repository to your local environment and maintain & upload code only through “Git”.
# Git global configuration
git config --global user.name "YOUR_USERNAME" git config --global user.email "your_email_address@example.com"
# Clone your repository
git clone https://github.com/nitsan-technologies/ns_news_comments/issues
# Checkout, pull and see a status
git checkout master git pull origin master git status
# Push your code
Move your extension’s code at git this repository folder.
git diff git add. git commit -m "Initial TYPO3 alpha version" git push origin master/develop
Now you’ll have an up-to-date repository at your local and Github. Now onwards, keep maintaining code and changes between your local Git and Github.
The connection between Packagist and Git
Now it is time to configure composer, Packagist.org provides very easy configuration to connect between your Git repository and Composer. Of course, Packagist also support other Git platform like Gitlab ;)
Submit Git repo at Packagist
Step 1: Go to https://packagist.org/
Step 2: To sign-up, you may use either https://packagist.org/register/ or use “Login with Github” at https://packagist.org/login/
Step 3: Now, Let’s submit our package/extension, Click on “Submit” https://packagist.org/packages/submit
Step 4: Enter your Github repository URL, and click on the “Check” button. Verify it once and then submit your package.
If you are getting some errors, then cross-verify your composer.json at your Git repository.
Step 5: Now you will be redirected to your package landing page eg., https://packagist.org/packages/nitsan/ns-news-comments Here you can see, all the information is grabbing from your Github’s composer.json file.
Tips:
Packagist also provide paid-services for your private projects, Checkout https://packagist.com/pricing
How Packagist and Git will communicate?
Whenever you’ll make any change or release a new version at Github, how they will communicate to take the latest code at composer? Perform the following steps.
Get API Token from Packagist
Step 1: Go to your profile https://packagist.org/profile/
Step 2: Click on “Show Token API” button
Publishing extension at TER
Finally, it’s time to publish it to TYPO3 Extensions Repository TER - An app store for TYPO3. You can easily do it by following any one of the following ways:
Option 1: Directly publishing to TYPO3.org
Step 1: Landing to https://extensions.typo3.org/ and Login with your user id.
Step 2: Go to My Extensions.
Step 3: Click on Register extension key and it is highly recommended to do it before you start the development to make sure you have a unique key.
Option 2: TYPO3 Extension Utils
T3EXT Utils is a collection of CLI utilities for TYPO3 CMS Extension.
Step 1: Install and configure through Git at https://github.com/etobi/Typo3ExtensionUtils#installation-with-git
Step 2: Upload extension to TER through https://github.com/etobi/Typo3ExtensionUtils#upload-extension-to-ter
Option 3: Automatic publishing from Github to TER
One of the most awesome solution by @NamelessCoder to automatic upload your extension from Github repository to TER. Recommend to see a complete solution at http://release.namelesscoder.net/ (It’s free and secure).
Option 4: Automatic publish through Travis CI
Check out detail solution and article by @helhum at https://insight.helhum.io/post/140850737265/automatically-upload-typo3-extensions-to-ter-with
Tips:
To display composer support and command, Go to My Extension and click on the “Edit” button for your particular extension. Tick “Published to Packagist” checkbox and set your composer name of the extension.
Hurray!
Your TYPO3 Extension now be easily installed with simple composer command eg.,
composer req nitsan/ns_ext_compatibility
Maintaining proper versions and dependencies
Do you know Semantic Versioning?
Example extension version: 1.1.2.
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backward-compatible bug fixes.
Additional labels for pre-release and to build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Read more details at https://semver.org/
Dependency Management
One of the important things is, We need to create and well-defined the dependencies at each release of our extension. There could be multiple dependencies like:
- TYPO3 core version
- Other TYPO3 extensions
- PHP version
At ext_emconf.php
Setup proper dependency versions at constraints with defining TYPO3 and other extensions version.
'constraints' => array( 'depends' => array( 'typo3' => '6.2.0-9.5.5', 'news' => '3.0.0-7.1.0', ), 'conflicts' => array( ), 'suggests' => array( ), ),
At composer.json
Similar way, you will need to define dependencies at composer.json
"require": { "typo3/cms-core": ">=6.2.0 || <=9.5.5", "georgringer/news": ">=3.0.0" },
Read more about dependency version management with composer at https://getcomposer.org/doc/articles/versions.md
Pro-tips for Extension Development
Setup Local Environment
To initiate and develop TYPO3 extensions, we would highly recommend using the following tools and techniques;
- Practice with Docker and DDEV
- Install Composer
- Setup Git
- Use PHPStorm IDE
TYPO3 Extension Development
To contribute the best quality of extension to the TYPO3 community, make sure you do your best to develop TYPO3 extension following all the industrial standards like:
- Read and go throughcreating a first extensionfrom TYPO3 docs.
- To start-up your extension quickly, You can use the most popularEXT:extension_builder.
- ReadExtbaseFluid bookfrom TYPO3 docs.
- State-of-the-art work and code review with industrial standards like PHP PSR standards, Unit testing, etc.,
Conclusion
As you know, “TER” is our app-store so, let’s do our best to keep it healthy and give back well to the community - let’s do our best to make well developed, smooth publishing and healthy maintenance our TYPO3 extensions.
Here is the quick sum up:
Understand the importance as well as the power of the Composer. Keep using it for the community and your private projects.
Develop and well test your work and code.
Understand versioning and dependencies.
Setup composer.json
Initiate Git and push it to your favorite git tool like Github, Gitlab, BitBucket, etc.,
Create a connection between Packagist and Git
Publish extension to TER
Feel proud for your contribution and take beer to celebrate it :)
Have a Happy Coding and Keep Contributing to the great TYPO3 Community!
Inspiring People To Code!
Comments and Responses
Be the First to Comment