Skip to content

Instantly share code, notes, and snippets.

@smichaelsen
Last active October 12, 2020 11:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smichaelsen/f1f66624b64e71835b3319f92e2f5092 to your computer and use it in GitHub Desktop.
Save smichaelsen/f1f66624b64e71835b3319f92e2f5092 to your computer and use it in GitHub Desktop.
Goodbye PackageStates.php

Getting PackageStates.php out of your TYPO3 project's git

Why?

Ideally your git repository only contains code that you and your team wrote yourself by hand.

  • 3rd party code should be included via a dependency manager (like composer)
  • Generated files (like compiled stylesheets) should be excluded and be regenerated whenever needed (for example when you deploy your code to a server).

PackageStates.php contains the information which TYPO3 extensions are available and loaded in the system and is typically generated when you use the extension manager to (un)install extensions.

In the past we ran into problems when we locally used extensions which we didn't use in production (via composer's require-dev). You always end up having a changed PackageStates.php file lying around which you have to care about not comitting it.

How to get rid of it

1. List all system extensions you need in your project's root composer.json. You can look up the package keys in the PackageStates.php file.

{
    "require": {
        "typo3/cms": "7.6.*",
        "helhum/typo3-console": "3.*",
        // ...
        
        "typo3/cms-core": "*",
        "typo3/cms-extbase": "*",
        "typo3/cms-fluid": "*",
        "typo3/cms-info": "*",
        "typo3/cms-info-pagetsconfig": "*",
        "typo3/cms-extensionmanager": "*",
        "typo3/cms-lang": "*",
        "typo3/cms-setup": "*",
        "typo3/cms-rtehtmlarea": "*",
        "typo3/cms-taskcenter": "*",
        "typo3/cms-sys-action": "*",
        "typo3/cms-backend": "*",
        "typo3/cms-belog": "*",
        "typo3/cms-beuser": "*",
        "typo3/cms-cshmanual": "*",
        "typo3/cms-filelist": "*",
        "typo3/cms-fluid-styled-content": "*",
        "typo3/cms-frontend": "*",
        "typo3/cms-indexed-search": "*",
        "typo3/cms-install": "*",
        "typo3/cms-lowlevel": "*",
        "typo3/cms-recordlist": "*",
        "typo3/cms-saltedpasswords": "*",
        "typo3/cms-scheduler": "*",
        "typo3/cms-sv": "*",
        "typo3/cms-t3skin": "*",
        "typo3/cms-tstemplate": "*",
        "typo3/cms-viewpage": "*"
    },
    // ...
}

2. Remove the file using git rm typo3conf/PackageStates.php and exclude it from git in your .gitignore

3. Call bin/typo3cms install:generatepackagestates to generate the file again (locally or during deployment)

Credits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment