{"id":1433,"date":"2015-10-03T16:51:12","date_gmt":"2015-10-03T14:51:12","guid":{"rendered":"https:\/\/www.robinglauser.ch\/blog\/?p=1433"},"modified":"2015-10-04T18:44:23","modified_gmt":"2015-10-04T16:44:23","slug":"design-patterns-in-php","status":"publish","type":"post","link":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/","title":{"rendered":"Design Patterns in PHP"},"content":{"rendered":"<p>The Github repository\u00a0<a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\" target=\"_blank\">domnikl\/DesignPatternsPHP<\/a>\u00a0has a list of design patterns and their implementation in PHP.<\/p>\n<p>It shows the UML diagram for the pattern and explains the purpose of the pattern.<\/p>\n<h2>AbstractFactory<\/h2>\n<blockquote><p>To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care about how these objects are created, he just knows how they go together.<\/p><\/blockquote>\n<figure style=\"width: 482px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\/tree\/master\/Creational\/AbstractFactory\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/domnikl\/DesignPatternsPHP\/master\/Creational\/AbstractFactory\/uml\/uml.png\" alt=\"\" width=\"482\" height=\"316\" \/><\/a><figcaption class=\"wp-caption-text\">AbstractFactory<\/figcaption><\/figure>\n<p>Some examples are the <a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\/tree\/master\/Structural\/Composite\" target=\"_blank\">Composite<\/a>, the <a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\/tree\/master\/Structural\/FluentInterface\" target=\"_blank\">FluentInterface<\/a>, the <a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\/tree\/master\/Behavioral\/Observer\" target=\"_blank\">Observer<\/a>,\u00a0the <a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\/tree\/master\/More\/Repository\" target=\"_blank\">Repository<\/a>\u00a0or the famous <a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\/tree\/master\/Creational\/Singleton\" target=\"_blank\">Singleton<\/a>\u00a0anti-pattern.<\/p>\n<p><a href=\"https:\/\/github.com\/domnikl\/DesignPatternsPHP\" target=\"_blank\">https:\/\/github.com\/domnikl\/DesignPatternsPHP<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">The Github repository\u00a0domnikl\/DesignPatternsPHP\u00a0has a list of design patterns and their implementation in PHP. It shows the UML diagram for the pattern and explains the purpose of the pattern. AbstractFactory To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care &#8230; <a class=\"read-more\" href=\"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":1435,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[45],"tags":[161,159,77,160,56,162,163],"class_list":["post-1433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-composite","tag-design","tag-interface","tag-patterns","tag-php","tag-repository","tag-singleton"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Design Patterns in PHP - Robin Glauser<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Design Patterns in PHP - Robin Glauser\" \/>\n<meta property=\"og:description\" content=\"The Github repository\u00a0domnikl\/DesignPatternsPHP\u00a0has a list of design patterns and their implementation in PHP. It shows the UML diagram for the pattern and explains the purpose of the pattern. AbstractFactory To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care ... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Robin Glauser\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-03T14:51:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-10-04T16:44:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"825\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Robin Glauser\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@robinglauser\" \/>\n<meta name=\"twitter:site\" content=\"@robinglauser\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Robin Glauser\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/\"},\"author\":{\"name\":\"Robin Glauser\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/#\\\/schema\\\/person\\\/e1a94504a6ff5171fa13670932514b19\"},\"headline\":\"Design Patterns in PHP\",\"datePublished\":\"2015-10-03T14:51:12+00:00\",\"dateModified\":\"2015-10-04T16:44:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/\"},\"wordCount\":108,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/#\\\/schema\\\/person\\\/e1a94504a6ff5171fa13670932514b19\"},\"image\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg\",\"keywords\":[\"composite\",\"design\",\"interface\",\"patterns\",\"php\",\"repository\",\"singleton\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/\",\"url\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/\",\"name\":\"Design Patterns in PHP - Robin Glauser\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg\",\"datePublished\":\"2015-10-03T14:51:12+00:00\",\"dateModified\":\"2015-10-04T16:44:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg\",\"width\":1920,\"height\":825},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/2015\\\/10\\\/03\\\/design-patterns-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Design Patterns in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/\",\"name\":\"Robin Glauser\",\"description\":\"My Blog about Development, Design and my random thoughts.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/#\\\/schema\\\/person\\\/e1a94504a6ff5171fa13670932514b19\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/#\\\/schema\\\/person\\\/e1a94504a6ff5171fa13670932514b19\",\"name\":\"Robin Glauser\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/DSC_1244_small.jpg\",\"url\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/DSC_1244_small.jpg\",\"contentUrl\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/DSC_1244_small.jpg\",\"width\":800,\"height\":530,\"caption\":\"Robin Glauser\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/DSC_1244_small.jpg\"},\"description\":\"I'm a web developer.\",\"sameAs\":[\"https:\\\/\\\/www.robinglauser.ch\",\"https:\\\/\\\/www.instagram.com\\\/robinglauser\\\/\",\"https:\\\/\\\/x.com\\\/robinglauser\"],\"url\":\"https:\\\/\\\/www.robinglauser.ch\\\/blog\\\/author\\\/robin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Design Patterns in PHP - Robin Glauser","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/","og_locale":"en_US","og_type":"article","og_title":"Design Patterns in PHP - Robin Glauser","og_description":"The Github repository\u00a0domnikl\/DesignPatternsPHP\u00a0has a list of design patterns and their implementation in PHP. It shows the UML diagram for the pattern and explains the purpose of the pattern. AbstractFactory To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care ... Read More","og_url":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/","og_site_name":"Robin Glauser","article_published_time":"2015-10-03T14:51:12+00:00","article_modified_time":"2015-10-04T16:44:23+00:00","og_image":[{"width":1920,"height":825,"url":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg","type":"image\/jpeg"}],"author":"Robin Glauser","twitter_card":"summary_large_image","twitter_creator":"@robinglauser","twitter_site":"@robinglauser","twitter_misc":{"Written by":"Robin Glauser","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#article","isPartOf":{"@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/"},"author":{"name":"Robin Glauser","@id":"https:\/\/www.robinglauser.ch\/blog\/#\/schema\/person\/e1a94504a6ff5171fa13670932514b19"},"headline":"Design Patterns in PHP","datePublished":"2015-10-03T14:51:12+00:00","dateModified":"2015-10-04T16:44:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/"},"wordCount":108,"commentCount":0,"publisher":{"@id":"https:\/\/www.robinglauser.ch\/blog\/#\/schema\/person\/e1a94504a6ff5171fa13670932514b19"},"image":{"@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg","keywords":["composite","design","interface","patterns","php","repository","singleton"],"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/","url":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/","name":"Design Patterns in PHP - Robin Glauser","isPartOf":{"@id":"https:\/\/www.robinglauser.ch\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#primaryimage"},"image":{"@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg","datePublished":"2015-10-03T14:51:12+00:00","dateModified":"2015-10-04T16:44:23+00:00","breadcrumb":{"@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#primaryimage","url":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg","contentUrl":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/hhlra7w2T1bPb3Ymth2Q_DSC_0357-e1443883456582.jpeg","width":1920,"height":825},{"@type":"BreadcrumbList","@id":"https:\/\/www.robinglauser.ch\/blog\/2015\/10\/03\/design-patterns-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robinglauser.ch\/blog\/"},{"@type":"ListItem","position":2,"name":"Design Patterns in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.robinglauser.ch\/blog\/#website","url":"https:\/\/www.robinglauser.ch\/blog\/","name":"Robin Glauser","description":"My Blog about Development, Design and my random thoughts.","publisher":{"@id":"https:\/\/www.robinglauser.ch\/blog\/#\/schema\/person\/e1a94504a6ff5171fa13670932514b19"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robinglauser.ch\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.robinglauser.ch\/blog\/#\/schema\/person\/e1a94504a6ff5171fa13670932514b19","name":"Robin Glauser","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/DSC_1244_small.jpg","url":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/DSC_1244_small.jpg","contentUrl":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/DSC_1244_small.jpg","width":800,"height":530,"caption":"Robin Glauser"},"logo":{"@id":"https:\/\/www.robinglauser.ch\/blog\/wp-content\/uploads\/2015\/10\/DSC_1244_small.jpg"},"description":"I'm a web developer.","sameAs":["https:\/\/www.robinglauser.ch","https:\/\/www.instagram.com\/robinglauser\/","https:\/\/x.com\/robinglauser"],"url":"https:\/\/www.robinglauser.ch\/blog\/author\/robin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/posts\/1433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/comments?post=1433"}],"version-history":[{"count":7,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/posts\/1433\/revisions"}],"predecessor-version":[{"id":1441,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/posts\/1433\/revisions\/1441"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/media\/1435"}],"wp:attachment":[{"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/media?parent=1433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/categories?post=1433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robinglauser.ch\/blog\/wp-json\/wp\/v2\/tags?post=1433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}