简体   繁体   中英

Setup TYPO3 locally for extension development

I would like to setup TYPO3 locally for extension development.

I work on Linux (but let's assume the answer should be helpful for Mac and Windows, because that is what is most commonly used).

I can easily setup my system for TYPO3 core development (with DDEV or without) because that is very well documented . However, that method clones the TYPO3 core and works on current development master. I would prefer to just install the last TYPO3 release.

What is a good approach here? I want to have as little external dependencies as possible. Also, should I install TYPO3 with Composer or not? While generally, using Composer is recommended, is this recommended for developing an extension locally?

Since I will be developing an extension on that system, I want the changes made to be immediately active (and not have to go via roundtrip of external git repository or packagist).

Using TYPO3 9.5.

However, that method clones the TYPO3 core and works on current development master. I would prefer to just install the last TYPO3 release.

If you want to save space or do not need the history provided by the git repository for TYPO3 you can do a so called shallow clone by providing the --depth option and specify which branch to check out using --branch followed by the name, eg 9.5 if you want to check out the latest 9.5 branch. This will also work with tags instead of branch names if you want to check out a release rather than the latest development version. In case your reference repository also uses submdodules you might also want to add --shallow-submodules as an additional option.

git clone --depth 1 --branch 9.5 ...

This will provide a very minimal clone to work with and should speed up the initial download process for the main installation.

Also, should I install TYPO3 with Composer or not? While generally, using Composer is recommended, is this recommended for developing an extension locally?

Yes, I would suggest doing so, or at least have the composer.json available. You should then install your extension just as you would any other using composer require as this is the way your extension will be installed later on and you should make sure it works. This can also help with identifying incompatible dependencies when you have an installation with other extensions that are commonly used together with yours.

The one thing I would suggest is have an additional repository set up in your composer.json pointing to your extension, instead of registering it at packagist right away. You might either want to set up a VCS-repository if you want to download the extension from git repository, eg github, or you can use a path-repository if you just want to symlink your extension from the directory where you develop it on the same machine. Both ways are good for when you don't want to publish the extension quite yet, but want to make sure they behave correctly when being installed in any other TYPO3 installation.

Especially in early development I prefer the path repository as you can develop the extension in its own repository and each change you make will still be instantly available in the reference project as the files are symlinked (by default).

With DDEV and Composer you can easily install your local extension.

In the composer.json you have to declare another repository of type "path" like this:

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

Putting your extension inside that folder, you can composer require your extension. (Your extension needs its own composer.json). Composer will find your extension in the packeges-folde in symlink it into your installation.
Any changes in your extension will immediately active.

It is described here: https://docs.typo3.org/m/typo3/guide-installation/master/en-us/MigrateToComposer/BestPractices.html

If you want to use DDEV and Composer (and you should do this) there is an easy way to setup your TYPO3:
TYPO3 Quickstart Guide for DDEV

The guide you have posted is the TYPO3 Contribution Guide which is needed to contribute to TYPO3, but checking out the core might be a little to much to just develop an extension.

Using TYPO3 with composer is always recommended as it saves you a lot of pain when it comes to updating dependencies and gives you a bunch of nice features like scripts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM