Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Increase your Productivity with TYPO3 Console

Increase your Productivity with TYPO3 Console

I'll show a set of TYPO3 Commands, that helps you automate TYPO3 installation and deployment and therefore let's you achieve more with doing less, hence increase your productivity.

Helmut Hummel

July 14, 2017
Tweet

More Decks by Helmut Hummel

Other Decks in Technology

Transcript

  1. Increase your Productivity with TYPO3 Console Helmut Hummel <[email protected]> Increase

    your Productivity with TYPO3 Console Inspiring people to share
  2. TYPO3 Console TYPO3 Console TYPO3 Console in a nutshell •

    Command line interface for TYPO3 • Built for humans • Usable by robots • Powerful • Extendable • Comes as composer package with CLI binary 3
  3. 9

  4. Productivity Productivity is expressed as the ratio of output to

    inputs https://en.wikipedia.org/wiki/Productivity 10
  5. 13

  6. 14

  7. 17

  8. 43

  9. 44

  10. 45

  11. TYPO3 Console Set up dev system 47 $ composer create-project

    vendor/project $ project/vendor/bin/typo3cms server:run
  12. TYPO3 Console Complete development cycle 55 $ # Set up

    dev system $ composer create-project vendor/project $ # Change code $ composer require vendor/ext $ # Commit to VCS $ git commit -a $ # Deploy $ surf deploy
  13. TYPO3 Console Little helpers Composer binaries in PATH • Mind

    the potential security impact • Malicious composer packages might ship „ls“ • Make sure composer binaries can’t override global binaries 61
  14. TYPO3 Console Building blocks Composer • Builds a project package

    from set of requirements • Provides several extension points to execute additional code • Better performance with optimized class loading 67
  15. TYPO3 Console Building blocks PackageStates.php • Tracks which extensions should

    be active • Is changed when (de-)activating extensions in EM • Bad for automated processes • What to do for automated deployment? • typo3/cli_dispatch.phpsh extbase extension:install <extkey> • typo3cms extension:activate <extkey> • Merge conflicts during a project lifetime 69
  16. TYPO3 Console Building blocks Generate PackageStates.php • Add PackageStates.php to

    your .gitignore • typo3cms install:generatepackagestates • Everything in typo3conf/ext/ is marked active • Every required TYPO3 core extension is marked active • Why would you install code, but mark it as inactive? • Each line of code is one line with potential security issues or bugs 71
  17. TYPO3 Console PackageStates.php 72 "require": { "typo3/cms-belog": "^8.7", "typo3/cms-beuser": "^8.7",

    "typo3/cms-context-help": "^8.7", "typo3/cms-fluid-styled-content": "^8.7", "typo3/cms-felogin": "^8.7", "typo3/cms-filelist": "^8.7", "typo3/cms-impexp": "^8.7", "typo3/cms-info": "^8.7", "typo3/cms-info-pagetsconfig": "^8.7", "typo3/cms-lowlevel": "^8.7", "typo3/cms-reports": "^8.7", "typo3/cms-rte-ckeditor": "^8.7", "typo3/cms-setup": "^8.7", "typo3/cms-tstemplate": "^8.7", "typo3/cms-viewpage": "^8.7" }
  18. 74

  19. TYPO3 Console Building blocks Create TYPO3 folder structure • Creates

    all required folders • Including ones defined by (active) extensions • Perfect for creating typo3temp/** • Makes it possible to start with empty typo3temp/ for every deployment • (Reconsider clean start when using gifbuilder or similar) • (Maybe reconsider using gifbuilder) 77
  20. TYPO3 Console Create TYPO3 folder structure 78 "scripts": { "package-states":

    [ "typo3cms install:generatepackagestates" ], "folder-structure": [ "typo3cms install:fixfolderstructure" ], "post-autoload-dump": [ "@package-states", "@folder-structure" ] }
  21. 79

  22. TYPO3 Console Building blocks Set up active extensions • One

    command • Same as activating every single extension in EM manually • Idempotent • Executing once or multiple times leads to same result • Fast • Does not flush caches • Groups DB schema update 82
  23. TYPO3 Console Building blocks Set up TYPO3 from CLI •

    Completely automatable • No more manual clicking in web installer • Sets up active extensions as last step • Ideal for dev setup • Local LAMP • Vagrant • Docker 85
  24. TYPO3 Console Building blocks Set up TYPO3 from CLI •

    NOT idempotent • Needs LocalConfiguration.php to be absent • Writes its own LocalConfiguration.php during setup • Only useful for INITIAL deployment 87
  25. TYPO3 Console Building blocks Update database schema • Can be

    used WITHOUT any tables in database • By default not destructive* • Adds tables and fields • Changes tables and fields • * Be careful with type and size changes • Works great for initial and subsequent deployments 90
  26. TYPO3 Console Building blocks Extension setup if possible • Combines

    DB schema update with extension setup • typo3cms database:updateschema • typo3cms cache:fush • typo3cms extension:setup • Gracefully exits in failure case • Ideal as composer post autoload dump script 93
  27. TYPO3 Console Extension setup if possible 94 "scripts": { "package-states":

    [ "typo3cms install:generatepackagestates" ], "folder-structure": [ "typo3cms install:fixfolderstructure" ], "ext-setup": [ "typo3cms install:extensionsetupifpossible" ], "post-autoload-dump": [ "@package-states", "@folder-structure", "@ext-setup" ] }
  28. 97

  29. TYPO3 Console Building blocks Create your own commands • As

    composer package • As TYPO3 extension • Configuration/Console/Commands.php • Classes/Command/YourCommandController.php • Every public function with suffix „Command“ • https://github.com/TYPO3-Console/php-server-command • PHPDoc extracted as help text 99
  30. TYPO3 Console Upgrade TYPO3 from CLI 104 $ composer require

    typo3/cms ^8.7 $ typo3cms upgrade:all
  31. TYPO3 Console Bonus Upgrade TYPO3 from CLI • Fast •

    Unattended • Idempotent • Can be executed for every deployment • Write your own upgrade wizards for migrations • Prepare everything locally and lean back during deploy 105
  32. 106

  33. TYPO3 Console One more thing helhum/typo3-distribution • Multiple environment support

    • One or more configuration files depending on context • Merged in LocalConfiguration.php for production • Reasonable default dev and prod config • Yaml or PHP file support • Extension configuration as plain arrays • Overridable with environment specific config 109
  34. TYPO3 Console One more thing helhum/typo3-distribution • Auto setup on

    composer install • Fully automatable for defined environments • Prompts for user input for setup if required/ wanted • Ready for dev and deploy • Easy to customize 110
  35. 111

  36. 112