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.

6c980f722cf236da20f1bb9e9efeb731?s=128

Helmut Hummel

July 14, 2017
Tweet

Transcript

  1. Increase your Productivity with TYPO3 Console Helmut Hummel <typo3@helhum.io> Increase

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

  3. 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
  4. TYPO3 Console TYPO3 Console installation 4 $ composer require helhum/typo3-console

  5. TYPO3 Console TYPO3 Console usage 5 $ vendor/bin/typo3cms help

  6. TYPO3 Console extension (Also installable as extension) 6

  7. 7 @helhum

  8. How to become more productive? 8

  9. 9

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

    inputs https://en.wikipedia.org/wiki/Productivity 10
  11. Increase Productivity Increase output 11

  12. Increase Productivity Lower input 12

  13. 13

  14. 14

  15. Development Cycle 15

  16. Development Cycle 16 Change code Commit to VCS Deploy

  17. 17

  18. Set up dev system 18

  19. Set up dev system Log in to live server 19

  20. Set up dev system Package files 20

  21. Set up dev system Package database 21

  22. Set up dev system Download and unpack 22

  23. Set up dev system Adapt configuration 23

  24. Set up dev system Connect VCS 24

  25. Change code 25

  26. Push to VCS 26

  27. Deploy 27

  28. Deploy Log in to live server 28

  29. Deploy Verify changes 29

  30. Deploy Merge changes 30

  31. Deploy Upload code 31

  32. Deploy …in the right order 32

  33. Deploy Log into install tool 33

  34. Deploy Update database schema 34

  35. Deploy Create missing directories 35

  36. Deploy Activate extensions 36

  37. Deploy Configure extensions 37

  38. Deploy Flush caches 38

  39. Deploy Restart webserver 39

  40. Deploy Pray 40

  41. Deploy Hotfix on live server 41

  42. Deploy Apply hotfix to VCS 42

  43. 43

  44. 44

  45. 45

  46. TYPO3 Console Set up dev system 46

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

    vendor/project $ project/vendor/bin/typo3cms server:run
  48. TYPO3 Console Change code 48

  49. TYPO3 Console Change code 49 $ composer require vendor/ext

  50. TYPO3 Console Commit to VCS 50

  51. TYPO3 Console Commit to VCS 51 $ git commit -a

    $ git push
  52. TYPO3 Console Deploy 52

  53. TYPO3 Console Deploy 53 $ surf deploy

  54. TYPO3 Console Complete development cycle 54

  55. 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
  56. TYPO3 Console Demo 56

  57. TYPO3 Console Meanwhile… 57

  58. TYPO3 Console …little helpers 58

  59. TYPO3 Console Composer binaries in PATH 59

  60. TYPO3 Console Composer binaries in PATH 60 $ export PATH="$PATH:./vendor/bin"

  61. 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
  62. TYPO3 Console Command autocompletion 62

  63. TYPO3 Console Command autocompletion 63 $ eval "$(typo3cms autocomplete)"

  64. TYPO3 Console Do less, achieve more 64

  65. TYPO3 Console Building blocks 65

  66. TYPO3 Console Building blocks 66

  67. 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
  68. TYPO3 Console PackageStates.php 68

  69. 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
  70. TYPO3 Console PackageStates.php 70 $ typo3cms install:generatepackagestates

  71. 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
  72. 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" }
  73. TYPO3 Console PackageStates.php 73 "scripts": { "package-states": [ "typo3cms install:generatepackagestates"

    ], "post-autoload-dump": [ "@package-states" ] }
  74. 74

  75. TYPO3 Console Create TYPO3 folder structure 75

  76. TYPO3 Console Create TYPO3 folder structure 76 $ typo3cms install:fixfolderstructure

  77. 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
  78. 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" ] }
  79. 79

  80. TYPO3 Console Set up active extensions 80

  81. TYPO3 Console Set up active extensions 81 $ typo3cms extension:setupactive

  82. 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
  83. TYPO3 Console Set up TYPO3 from CLI 83

  84. TYPO3 Console Set up TYPO3 84 $ typo3cms install:setup

  85. 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
  86. But… 86

  87. 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
  88. TYPO3 Console Update database schema 88

  89. TYPO3 Console Update database schema 89 $ typo3cms database:updateschema

  90. 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
  91. TYPO3 Console Combining DB schema update and extension setup 91

  92. TYPO3 Console Building blocks 92 $ typo3cms install:extensionsetupifpossible

  93. 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
  94. 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" ] }
  95. TYPO3 Console Building blocks 95 $ composer create-project \ helhum/minimal-typo3-distribution

    \ new-project ^7
  96. TYPO3 Console Building blocks 96 $ composer create-project \ helhum/minimal-typo3-distribution

    \ new-project ^8
  97. 97

  98. TYPO3 Console Create your own commands 98

  99. 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
  100. TYPO3 Console Create your own commands 100

  101. TYPO3 Console Create your own commands 101

  102. TYPO3 Console Bonus 102

  103. TYPO3 Console Upgrade TYPO3 from CLI 103

  104. TYPO3 Console Upgrade TYPO3 from CLI 104 $ composer require

    typo3/cms ^8.7 $ typo3cms upgrade:all
  105. 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
  106. 106

  107. TYPO3 Console One more thing… 107

  108. TYPO3 Console helhum/typo3-distribution 108

  109. 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
  110. 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
  111. 111

  112. 112

  113. TYPO3 Console Questions? 113

  114. TYPO3 Console Workshop at coding night 114

  115. TYPO3 Console Thank you! @helhum http://insight.helhum.io typo3@helhum.io 115