Slide 1

Slide 1 text

Break Off A Piece Of That Monolith

Slide 2

Slide 2 text

Break Off A Piece Of That Mono Omni Adams — PHP[Tek] 2024 lith

Slide 3

Slide 3 text

https://commons.wikimedia.org/wiki/File:Spaghetti,_cooked,_in_bowl.jpg

Slide 4

Slide 4 text

https://www. fl ickr.com/photos/wagner-machado-carlos-lemes/2987599021

Slide 5

Slide 5 text

https://www. fl ickr.com/photos/tambako/3589021887 https://www.hyrumslaw.com/

Slide 6

Slide 6 text

https://www. fl ickr.com/photos/nachof/2482912078

Slide 7

Slide 7 text

https://www.pxfuel.com/en/free-photo-ozrrp

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

https://www.geograph.org.uk/photo/5846712

Slide 10

Slide 10 text

–DHH “You don’t want to hear that the reason your monolith is a spaghetti monster is because you let it become that way, one commit at the time, due to weak habits, pressurized deadlines, or simply sheer lack of competence.” https://m.signalvnoise.com/integrated-systems-for-integrated-programmers/

Slide 11

Slide 11 text

It’s REALLY hard

Slide 12

Slide 12 text

Plan of Attack Testing Tools Refactoring

Slide 13

Slide 13 text

https://commons.wikimedia.org/wiki/File:PHPUnit_Logo.svg

Slide 14

Slide 14 text

PHPUnit 8.5.0 by Sebastian Bergmann and contributors. ............................................................... 63 / 281 ( 22%) ............................................................... 126 / 281 ( 44%) ............................................................... 189 / 281 ( 67%) ............................................................... 252 / 281 ( 89%) ............................. 281 / 281 (100%) Time: 2.83 seconds, Memory: 24.00 MB OK (281 tests, 6 assertions) Code Coverage Report: Summary: Classes: 51.72% (15/29) Methods: 75.83% (91/120) Lines: 55.95% (941/1682)

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Testing Unit tests Functional tests

Slide 18

Slide 18 text

Static Analysis php-cs- fi xer PHPStan

Slide 19

Slide 19 text

Style Guides

Slide 20

Slide 20 text

1) src/Nether/Object/Prototype.php (visibility_required, class_attributes_separation, indentation_type, class_de fi nition, single_space_around_construct, method_argument_space, fully_quali fi ed_strict_types, no_spaces_after_function_name, declare_strict_types, blank_line_after_opening_tag, control_structure_braces, constant_case, control_structure_continuation_position, magic_method_casing, ordered_traits, yoda_style, braces_position, statement_indentation, no_useless_return, no_extra_blank_lines, ordered_imports, binary_operator_spaces) ---------- begin diff ---------- --- /home/omni/code/object/src/Nether/Object/Prototype.php +++ /home/omni/code/object/src/Nether/Object/Prototype.php @@ -1,194 +1,202 @@

Slide 21

Slide 21 text

Reading code is at least twice as hard as writing code.

Slide 22

Slide 22 text

Static Analysis php-cs- fi xer PHPStan

Slide 23

Slide 23 text

------ ---------------------------------------------------------------------- Line requisition.edit.php ------ ---------------------------------------------------------------------- 21 Class Error referenced with incorrect case: error. 24 Instantiated class requisition not found. 25 Call to method load_from_database() on an unknown class requisition. 27 Class Error referenced with incorrect case: error. 28 Constant ERR_RECORD_NOT_FOUND not found. 29 Call to an unde fi ned method Error::new_error(). 36 Constant APP_ROOT not found. 199 Constant REQ_TERM_FULL_TIME not found.

Slide 24

Slide 24 text

Refactoring Breaking up big pieces of code Pulling procedural code out to objects Pulling large pieces of functionality out

Slide 25

Slide 25 text

Refactoring: Bigger is better?

Slide 26

Slide 26 text

Refactoring: Small for the win?

Slide 27

Slide 27 text

Refactoring: Just right

Slide 28

Slide 28 text

The Strangler Pattern

Slide 29

Slide 29 text

Example: Calendar PHP3ish code Interspersed PHP and HTML No style guide No composer No tests

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

/calendar.add.php —> {old crusty code} /calendar —> {new framework}

Slide 46

Slide 46 text

https://pixabay.com/vectors/zombie-undead-monster-frankenstein-156055/ https://slides.com/andysnell/zombie-hunt

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Microservices

Slide 50

Slide 50 text

Microservices (+ the monolith)

Slide 51

Slide 51 text

Microservice S

Slide 52

Slide 52 text

"Micro"services

Slide 53

Slide 53 text

/users /customers /sales /weather

Slide 54

Slide 54 text

THANKS TO OUR SPONSORS

Slide 55

Slide 55 text

https://speakerdeck.com/omnicolor/monolith-tek https://phpc.social/@omnicolor Omni Adams [email protected] https://joind.in/talk/3aeec