<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matt Sparks</title>
    <description>The latest articles on Forem by Matt Sparks (@mattsparks).</description>
    <link>https://forem.com/mattsparks</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F68777%2F7aaeb224-6b1d-42b8-9703-b7f4de3707eb.jpg</url>
      <title>Forem: Matt Sparks</title>
      <link>https://forem.com/mattsparks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mattsparks"/>
    <language>en</language>
    <item>
      <title>🧠 Learn! 5 Github Repos With Great Free &amp; Open Source Resources</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Wed, 29 May 2019 14:08:06 +0000</pubDate>
      <link>https://forem.com/mattsparks/learn-5-github-repos-with-great-free-open-source-resources-38de</link>
      <guid>https://forem.com/mattsparks/learn-5-github-repos-with-great-free-open-source-resources-38de</guid>
      <description>&lt;p&gt;Things move fast in web development. Here are 5 great Github repos with free and open source resources to fill up your mind grapes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Free Books!
&lt;/h2&gt;

&lt;p&gt;This list of free programming books comes to us from the &lt;a href="https://ebookfoundation.org/"&gt;Free Ebook Foundation&lt;/a&gt;. Subjects range from specific programming languages to topics like Machine Learning and Security.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/EbookFoundation"&gt;
        EbookFoundation
      &lt;/a&gt; / &lt;a href="https://github.com/EbookFoundation/free-programming-books"&gt;
        free-programming-books
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      📚 Freely available programming books
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;This page is available as an easy-to-read website at &lt;a href="https://ebookfoundation.github.io/free-programming-books/" rel="nofollow"&gt;https://ebookfoundation.github.io/&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;
List of Free Learning Resources In Many Languages &lt;a href="https://github.com/sindresorhus/awesome"&gt;&lt;img src="https://camo.githubusercontent.com/abb97269de2982c379cbc128bba93ba724d8822bfbe082737772bd4feb59cb54/68747470733a2f2f63646e2e7261776769742e636f6d2f73696e647265736f726875732f617765736f6d652f643733303566333864323966656437386661383536353265336136336531353464643865383832392f6d656469612f62616467652e737667" alt="Awesome"&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;h2&gt;
Intro&lt;/h2&gt;
&lt;p&gt;This list was originally a clone of &lt;a href="http://web.archive.org/web/20130824154208/http://stackoverflow.com/a/392926" rel="nofollow"&gt;StackOverflow - List of Freely Available Programming Books&lt;/a&gt; with contributions from Karan Bhangui and George Stocker.&lt;/p&gt;
&lt;p&gt;The list was moved to GitHub by Victor Felder for collaborative updating and maintenance. It has grown to become one of &lt;a href="https://octoverse.github.com/"&gt;Github's most popular repositories&lt;/a&gt;, with 160,000+ stars, 6000+ commits, 1600+ contributors, and 39,000+ forks.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://ebookfoundation.org" rel="nofollow"&gt;Free Ebook Foundation&lt;/a&gt; now administers the repo, a not-for-profit organization devoted to promoting the creation, distribution, archiving, and sustainability of free ebooks. &lt;a href="https://ebookfoundation.org/contributions.html" rel="nofollow"&gt;Donations&lt;/a&gt; to the Free Ebook Foundation are tax-deductible in the US.&lt;/p&gt;
&lt;h3&gt;
How To Contribute&lt;/h3&gt;
&lt;p&gt;Please read &lt;a href="https://raw.githubusercontent.com/EbookFoundation/free-programming-books/master//CONTRIBUTING.md"&gt;CONTRIBUTING&lt;/a&gt;. If you're new to GitHub, &lt;a href="https://raw.githubusercontent.com/EbookFoundation/free-programming-books/master//HOWTO.md"&gt;welcome&lt;/a&gt;!&lt;/p&gt;
&lt;h3&gt;
How to Share&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://twitter.com/intent/tweet?text=https://github.com/EbookFoundation/free-programming-books%0AFree%20Programming%20Books" rel="nofollow"&gt;Share on Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.facebook.com/share.php?u=https%3A%2F%2Fgithub.com%2FEbookFoundation%2Ffree-programming-books&amp;amp;p%5Bimages%5D%5B0%5D=&amp;amp;p%5Btitle%5D=Free%20Programming%20Books&amp;amp;p%5Bsummary%5D=" rel="nofollow"&gt;Share on Facebook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.linkedin.com/shareArticle?mini=true&amp;amp;url=https://github.com/EbookFoundation/free-programming-books&amp;amp;title=Free%20Programming%20Books&amp;amp;summary=&amp;amp;source=" rel="nofollow"&gt;Share on LinkedIn&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://t.me/share/url?url=https://github.com/EbookFoundation/free-programming-books" rel="nofollow"&gt;Share on Telegram&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Books&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://raw.githubusercontent.com/EbookFoundation/free-programming-books/master/books/free-programming-books.md"&gt;English&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
Other Languages&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/EbookFoundation/free-programming-books/master/books/free-programming-books-ar.md"&gt;Arabic / al arabiya&lt;/a&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/EbookFoundation/free-programming-books"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Open Source Documents
&lt;/h2&gt;

&lt;p&gt;These documents are all open source and can be modified/redistributed/etc. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/44bits"&gt;
        44bits
      &lt;/a&gt; / &lt;a href="https://github.com/44bits/awesome-opensource-documents"&gt;
        awesome-opensource-documents
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      📘 A curated list of awesome open source or open source licensed documents, guides, books.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Awesome Open Source Documents&lt;/h1&gt;
&lt;p&gt;This is not a list of free programming books. This is a curated list of open source or open source licensed documents, guides, and books which can be read, used, modified, translated, redistributed and even rewritten under their same license.&lt;/p&gt;
&lt;h2&gt;
Document Template&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;[TITLE][repository-url] by AUTHOR ([SITE][site-url], LICENSE) - SHORT DESCRIPTION
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;
Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#subjects"&gt;Subjects&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#computer_science"&gt;Computer Science&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#data_science"&gt;Data Science&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#devops"&gt;DevOps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#mathematics"&gt;Mathematics &amp;amp; Physics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#open_source"&gt;Open Source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#programming"&gt;Programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#database"&gt;Database&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#world_wide_web"&gt;World Wide Web&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#writing_and_documentation"&gt;Writing and Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#journalism_and_visualization"&gt;Journalism and Visualization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#android_development"&gt;Android Development&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#ios_development"&gt;IOS Development&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#subject-etc"&gt;etc.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#programming_languages"&gt;Programming Languages&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#language-c"&gt;C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#coffeescript"&gt;Coffeescript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#css"&gt;CSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#fortran"&gt;Fortran&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#ruby"&gt;Ruby&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#clojure"&gt;Clojure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#erlang"&gt;Erlang&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#elixir"&gt;Elixir&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#forth"&gt;Forth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#go"&gt;Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#haskell"&gt;Haskell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#javascript"&gt;Javascript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#lisp"&gt;Lisp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#objective-c"&gt;Objective-c&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#ocaml"&gt;Ocaml&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#perl"&gt;Perl&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#php"&gt;PHP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#python"&gt;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#rust"&gt;Rust&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#r"&gt;R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#scala"&gt;Scala&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#tools"&gt;Tools&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#editor"&gt;Editor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#git"&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#server"&gt;Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#tool-etc"&gt;etc.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#library-docs"&gt;Library Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#other_languages"&gt;Other Languages&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#korean"&gt;Korean&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#chinese"&gt;Chinese&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#japanese"&gt;Japanese&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/44bits/awesome-opensource-documents/master/#license"&gt;License&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Subjects&lt;/h2&gt;
&lt;h3&gt;
Computer Science&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/crypto101/book"&gt;Crypto 101&lt;/a&gt; (&lt;a href="https://www.crypto101.io/" rel="nofollow"&gt;Site&lt;/a&gt;, cc-nc) - the introductory book on cryptography&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/littleosbook/littleosbook"&gt;The little book about OS development&lt;/a&gt; (&lt;a href="http://littleosbook.github.io/" rel="nofollow"&gt;Site&lt;/a&gt;, cc-nc-sa) - This is the source…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/44bits/awesome-opensource-documents"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Build Your Own X
&lt;/h2&gt;

&lt;p&gt;When I came across this repo I immediately loved it. Want to build your own bot? How about your own programming language? This repo will help you get started.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/danistefanovic"&gt;
        danistefanovic
      &lt;/a&gt; / &lt;a href="https://github.com/danistefanovic/build-your-own-x"&gt;
        build-your-own-x
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🤓 Build your own (insert technology here)
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;strong&gt;[&lt;a href="https://github.com/danistefanovic/build-your-own-x/issues/new"&gt;Submit tutorial&lt;/a&gt;]&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;
&lt;a rel="noopener noreferrer" href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/feynman.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ocARtJsg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/feynman.png" alt="Build your own X"&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;h2&gt;
Table of contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-3d-renderer"&gt;3D Renderer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-augmented-reality"&gt;Augmented Reality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-bittorrent-client"&gt;BitTorrent Client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-blockchain--cryptocurrency"&gt;Blockchain / Cryptocurrency&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-bot"&gt;Bot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-command-line-tool"&gt;Command-Line Tool&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-database"&gt;Database&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-docker"&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-emulator--virtual-machine"&gt;Emulator / Virtual Machine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-front-end-framework--library"&gt;Front-end Framework / Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-game"&gt;Game&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-git"&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-network-stack"&gt;Network Stack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-neural-network"&gt;Neural Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-operating-system"&gt;Operating System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-physics-engine"&gt;Physics Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-programming-language"&gt;Programming Language&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-regex-engine"&gt;Regex Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-search-engine"&gt;Search Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-shell"&gt;Shell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-template-engine"&gt;Template Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-text-editor"&gt;Text Editor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-visual-recognition-system"&gt;Visual Recognition System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-voxel-engine"&gt;Voxel Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-web-search-engine"&gt;Web Search Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#build-your-own-web-server"&gt;Web Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/danistefanovic/build-your-own-x/master/#uncategorized"&gt;Uncategorized&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Tutorials&lt;/h2&gt;
&lt;h4&gt;
Build your own &lt;code&gt;3D Renderer&lt;/code&gt;
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-ray-tracing/how-does-it-work" rel="nofollow"&gt;&lt;strong&gt;C++&lt;/strong&gt;: &lt;em&gt;Introduction to Ray Tracing: a Simple Method for Creating 3D Images&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ssloy/tinyrenderer/wiki"&gt;&lt;strong&gt;C++&lt;/strong&gt;: &lt;em&gt;How OpenGL works: software rendering in 500 lines of code&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://lodev.org/cgtutor/raycasting.html" rel="nofollow"&gt;&lt;strong&gt;C++&lt;/strong&gt;: &lt;em&gt;Raycasting engine of Wolfenstein 3D&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.pbr-book.org/" rel="nofollow"&gt;&lt;strong&gt;C++&lt;/strong&gt;: &lt;em&gt;Physically Based Rendering:From Theory To Implementation&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/overview-rasterization-algorithm" rel="nofollow"&gt;&lt;strong&gt;C++&lt;/strong&gt;: &lt;em&gt;Rasterization: a Practical Implementation&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.davrous.com/2013/06/13/tutorial-series-learning-how-to-write-a-3d-soft-engine-from-scratch-in-c-typescript-or-javascript/" rel="nofollow"&gt;&lt;strong&gt;C# / TypeScript / JavaScript&lt;/strong&gt;: &lt;em&gt;Learning how to write a 3D soft engine from scratch in C#, TypeScript or JavaScript&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://avik-das.github.io/build-your-own-raytracer/" rel="nofollow"&gt;&lt;strong&gt;Java / JavaScript&lt;/strong&gt;: &lt;em&gt;Build your own 3D renderer&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blog.rogach.org/2015/08/how-to-create-your-own-simple-3d-render.html" rel="nofollow"&gt;&lt;strong&gt;Java&lt;/strong&gt;: &lt;em&gt;How to create your own&lt;/em&gt;&lt;/a&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/danistefanovic/build-your-own-x"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Awesome Tools For Junior Devs
&lt;/h2&gt;

&lt;p&gt;A great list of resources for junior devs. Resources include tutorials, blogs, books, podcasts, and tons more.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/stephhappens"&gt;
        stephhappens
      &lt;/a&gt; / &lt;a href="https://github.com/stephhappens/awesome-tools-for-junior-developers"&gt;
        awesome-tools-for-junior-developers
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A curated list of popular tools, tips and tricks for aspiring developers.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Awesome list of tools you might need on your path to senior developer-dom&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://awesome.re" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/64f8905651212a80869afbecbf0a9c52a5d1e70beab750dea40a994fa9a9f3c6/68747470733a2f2f617765736f6d652e72652f62616467652e737667" alt="Awesome"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A curated list of popular tools, tips and tricks for aspiring developers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;To add to the repo simply grab the name, link and a short searchable description of your favorites. Try to keep it to high level products you have personally tried and would recommend to your friends and coworkers. Also tools that you wish you knew about when you were starting as a junior developer are welcomed!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
Index&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#tutorials"&gt;Tutorials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#articles"&gt;Articles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#blogs"&gt;Blogs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#books"&gt;Books&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#news"&gt;News&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#newsletters"&gt;Newsletters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#podcasts"&gt;Podcasts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#popular-tools"&gt;Popular Tools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/#social"&gt;Social&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
Tutorials&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://javascript30.com/" rel="nofollow"&gt;Wes Bos Javascript 30&lt;/a&gt;- Free vanilla Javascript course covering the basics of Javascript.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://egghead.io/" rel="nofollow"&gt;Egghead.io&lt;/a&gt;- A Mix of free and paid courses for Front End Frameworks and Javascript.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/stephhappens/awesome-tools-for-junior-developers/master/www.linkedin.com/learning"&gt;Linkedin Learning&lt;/a&gt;- A library of courses on a full range of a variety of topics. This was Lynda before.&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://guide.bash.academy" rel="nofollow"&gt;The Bash Guide&lt;/a&gt;- Very good guide for…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/stephhappens/awesome-tools-for-junior-developers"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  CS Video Courses
&lt;/h2&gt;

&lt;p&gt;Ever wanted to take a computer science course from Harvard? This repo lists tons of free video courses from some of the best universities in the world.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Developer-Y"&gt;
        Developer-Y
      &lt;/a&gt; / &lt;a href="https://github.com/Developer-Y/cs-video-courses"&gt;
        cs-video-courses
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      List of Computer Science courses with video lectures.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h2&gt;
Computer Science courses with video lectures&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Please check &lt;a href="https://github.com/Developer-Y/cs-video-courses/blob/master/NOTES.md"&gt;NOTES&lt;/a&gt; for general information about this list.&lt;/li&gt;
&lt;li&gt;Please refer &lt;a href="https://github.com/Developer-Y/cs-video-courses/blob/master/CONTRIBUTING.md"&gt;CONTRIBUTING.md&lt;/a&gt; for contribution guidelines.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#introduction-to-computer-science"&gt;Introduction to Computer Science&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#data-structures-and-algorithms"&gt;Data Structures and Algorithms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#systems-programming"&gt;Systems Programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#database-systems"&gt;Database Systems&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#software-engineering"&gt;Software Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#artificial-intelligence"&gt;Artificial Intelligence&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#machine-learning"&gt;Machine Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#web-programming-and-internet-technologies"&gt;Web Programming and Internet Technologies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#computer-networks"&gt;Computer Networks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#math-for-computer-scientist"&gt;Math for Computer Scientist&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#theoretical-cs-and-programming-languages"&gt;Theoretical CS and Programming Languages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#embedded-systems"&gt;Embedded Systems&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#computer-organization-and-architecture"&gt;Computer Organization and Architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#security"&gt;Security&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#computer-graphics"&gt;Computer Graphics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#image-processing-and-computer-vision"&gt;Image Processing and Computer Vision&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#computational-biology"&gt;Computational Biology&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#quantum-computing"&gt;Quantum Computing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#robotics"&gt;Robotics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#computational-finance"&gt;Computational Finance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Developer-Y/cs-video-courses/master/#misc"&gt;Misc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Courses&lt;/h2&gt;
&lt;h3&gt;
Introduction to Computer Science&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.infocobuild.com/education/audio-video-courses/computer-science/cs10-spring2015-berkeley.html" rel="nofollow"&gt;CS 10 - The Beauty and Joy of Computing - Spring 2015 - Dan Garcia - UC Berkeley InfoCoBuild&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/lecture-videos/" rel="nofollow"&gt;6.0001 - Introduction to Computer Science and Programming in Python - MIT OCW&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures" rel="nofollow"&gt;6.001 - Structure and Interpretation of Computer Programs, MIT&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://online-learning.harvard.edu/course/cs50-introduction-computer-science" rel="nofollow"&gt;CS 50 - Introduction to Computer Science, Harvard University&lt;/a&gt; (&lt;a href="http://cs50.tv/2017/fall/" rel="nofollow"&gt;cs50.tv&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cs61a.org/" rel="nofollow"&gt;CS 61A - Structure and Interpretation of Computer Programs [Python], UC&lt;/a&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Developer-Y/cs-video-courses"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  More!
&lt;/h2&gt;

&lt;p&gt;There are some great resources being shared in the comments. Go take a look! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
    <item>
      <title>Get What You Want: Using PHP Collections to easily filter and manipulate data. 😎</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Tue, 28 May 2019 19:06:54 +0000</pubDate>
      <link>https://forem.com/mattsparks/get-what-you-want-using-php-collections-to-easily-filter-and-manipulate-data-59bb</link>
      <guid>https://forem.com/mattsparks/get-what-you-want-using-php-collections-to-easily-filter-and-manipulate-data-59bb</guid>
      <description>&lt;p&gt;You've worked with APIs, right? You make a request, you get some data back, and you do something with it. Pretty standard stuff. This tutorial will show you how you can use the power of PHP collections to easily get the data you want.&lt;/p&gt;

&lt;p&gt;What are PHP collections? Simply put: a collection is a class that allows us to easily work with arrays.&lt;/p&gt;

&lt;p&gt;For this tutorial, we'll be using the &lt;code&gt;tightenco/collect&lt;/code&gt; package. This package allows us to use &lt;a href="https://laravel.com/docs/5.8/collections"&gt;Laravel Collections&lt;/a&gt; without the entire framework.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/tightenco"&gt;
        tightenco
      &lt;/a&gt; / &lt;a href="https://github.com/tightenco/collect"&gt;
        collect
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A Collections-only split from Laravel's Illuminate Support
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a href="https://travis-ci.org/tightenco/collect" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/1889d65244b4c78ada54c0179407c4159b06a962/68747470733a2f2f7472617669732d63692e6f72672f7469676874656e636f2f636f6c6c6563742e7376673f6272616e63683d6c61726176656c2d362d6f6e676f696e67" alt="Travis Status for tightenco/collect"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://raw.githubusercontent.com/tightenco/collect/master/collect-logo.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QxZ_yZFu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/tightenco/collect/master/collect-logo.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
Collect - Illuminate Collections&lt;/h1&gt;
&lt;p&gt;Import &lt;a href="https://laravel.com/docs/collections" rel="nofollow"&gt;Laravel's Collections&lt;/a&gt; into non-Laravel packages easily, without needing to require the entire &lt;code&gt;Illuminate\Support&lt;/code&gt; package. (&lt;a href="https://mattallan.org/posts/dont-use-illuminate-support/" rel="nofollow"&gt;Why not pull &lt;code&gt;Illuminate\Support&lt;/code&gt; in framework-agnostic packages&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Written by Taylor Otwell as a part of Laravel's &lt;a href="https://github.com/illuminate/support"&gt;Illuminate/Support&lt;/a&gt; package, Collect is just the code from Support needed in order to use Collections on their own.&lt;/p&gt;
&lt;p&gt;Lovingly split by Matt Stauffer for &lt;a href="https://tighten.co/" rel="nofollow"&gt;Tighten Co.&lt;/a&gt;, with a kick in the butt to finally do it from &lt;a href="https://github.com/assertchris"&gt;@assertchris&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
Installation&lt;/h2&gt;
&lt;p&gt;With &lt;a href="https://getcomposer.org" rel="nofollow"&gt;Composer&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell"&gt;&lt;pre&gt;composer require tightenco/collect&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
Development&lt;/h2&gt;
&lt;p&gt;If you are a developer working on Collect and you're tasked with upgrading it to mirror a new version of Laravel,  run &lt;code&gt;./upgrade.sh&lt;/code&gt; from the root directory. You can pass a parameter to target a specific Laravel version (e.g. &lt;code&gt;./upgrade.sh 5.7.10&lt;/code&gt;) or, if you don't pass a parameter, the script will find the latest tagged release and run against that.&lt;/p&gt;
&lt;p&gt;The upgrader will pull…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/tightenco/collect"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Data for this tutorial was provided by the &lt;a href="http://www.omdbapi.com/"&gt;OMDb API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Rather than embed the data, &lt;a href="https://gist.github.com/mattsparks/4a0a3520b3ab211854d2caff7ee52f9b"&gt;you can view it here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Simple Example
&lt;/h2&gt;

&lt;p&gt;Before we get into parsing our &lt;a href="https://gist.github.com/mattsparks/4a0a3520b3ab211854d2caff7ee52f9b"&gt;movie data&lt;/a&gt;, let's do a quick example. In this example, we'll grab the first and last item in an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;Tightenco\Collect\Support\Collection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$simpsons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Homer'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Marge'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Bart'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Lisa'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Maggie'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$simpsons&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;first&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Homer&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;last&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Maggie&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Pretty easy, right? We have an array which we use to make a new &lt;code&gt;Collection&lt;/code&gt; instance. From there we use the &lt;code&gt;first()&lt;/code&gt; and &lt;code&gt;last()&lt;/code&gt; methods to grab "Homer" and "Maggie."&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;First, we need to first use Composer to pull in our Collection package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require tightenco/collect
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now for each example, we need to include our dependencies and do a little setup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;Tightenco\Collect\Support\Collection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;file_get_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;__DIR__&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/data.json'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$movies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;json_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movies&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Collection Methods
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Collection&lt;/code&gt; package provides us with a ton of great methods we can use to manipulate our data. Since there are ~110 methods, I won't be going over each one. Instead, I'll highlight a few and explain their functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;.map()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;map()&lt;/code&gt; function loops through the data and passes each item to the given callback. You are then able to return the item to create a new collection. Below we'll create a new collection that contains only each film's title.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$titles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Title'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['The Matrix', 'Blade Runner', 'The Fifth Element', 'Escape From New York']
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You're not limited to just returning a single value. Let's create a collection that includes each film along with the date of release.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$release&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Title'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'releaseDate'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Released'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;]];&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    'The Matrix' =&amp;gt; ['releaseDate' =&amp;gt; '31 Mar 1999'],
    'Blade Runner' =&amp;gt; ['releaseDate' =&amp;gt; '25 Jun 1982'],
    'The Fifth Element' =&amp;gt; ['releaseDate' =&amp;gt; '09 May 1997'],
    'Escape From New York' =&amp;gt; ['releaseDate' =&amp;gt; '10 Jul 1981']            
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, let's format the date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$release&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Title'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'releaseDate'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'F d, Y'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;strtotime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Released'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
    &lt;span class="p"&gt;]];&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    'The Matrix' =&amp;gt; ['releaseDate' =&amp;gt; 'March 31, 1999'],
    'Blade Runner' =&amp;gt; ['releaseDate' =&amp;gt; 'June 25, 1982'],
    'The Fifth Element' =&amp;gt; ['releaseDate' =&amp;gt; 'May 09, 1997'],
    'Escape From New York' =&amp;gt; ['releaseDate' =&amp;gt; 'July 10, 1981']            
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Side note: if this were a real project I would probably use PHP's &lt;a href="https://www.php.net/manual/en/class.datetime.php"&gt;DateTime&lt;/a&gt; or &lt;a href="https://carbon.nesbot.com/docs/"&gt;Carbon&lt;/a&gt; to format the date.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;.filter()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;filter()&lt;/code&gt; method, well, filters the data. Any items that pass a given test will be returned. In the example below, we return any movie whose "Metascore" is at least 70.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$metascore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Metascore'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    [
        'Title' =&amp;gt; 'The Matrix'
        ...
    ], 
    [
        'Title' =&amp;gt; 'Blade Runner'
        ...
    ],     
    [
        'Title' =&amp;gt; 'Escape From New York'
        ...
    ]   
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;.sum()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;.sum()&lt;/code&gt; method is handy when you want to total values. In this example, I use the &lt;code&gt;map()&lt;/code&gt; method to return each movie's runtime and then total them to see how long it would take to watch all four films.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$runtime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * Breakdown:
     *
     * 1. Remove " min" from the string.
     * 2. Cast the string to an integer so we can add them
     */&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;str_replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;' min'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$movie&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Runtime'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;478
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;.count()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Like &lt;code&gt;.sum()&lt;/code&gt;, &lt;code&gt;.count()&lt;/code&gt; is a very simple method that can really come in handy when you want to know how many items are in your collection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;There are ~106 other methods available with this specific package. I encourage you to &lt;a href="https://laravel.com/docs/5.8/collections"&gt;read the documentation&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Laravel's Collection package isn't the only game in town. &lt;a href="https://github.com/doctrine/collections"&gt;Doctrine&lt;/a&gt; has a great one and there are &lt;a href="https://packagist.org/?query=collection"&gt;many others availble&lt;/a&gt;, too! Go find one you like!&lt;/p&gt;

&lt;p&gt;Also, Adam Wathan has a great book called &lt;a href="https://adamwathan.me/refactoring-to-collections/"&gt;Refactoring to Collections&lt;/a&gt; that I highly recommend. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Full disclosure, I'm not being compensated in any way for linking to this book. I just think it's great. That said, Adam, if you're reading this and would like me to become a paid endorser, just get in touch 😆]&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Tips For Landing Your First Web Development Job</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Thu, 23 May 2019 19:35:54 +0000</pubDate>
      <link>https://forem.com/mattsparks/tips-for-landing-your-first-web-development-job-416o</link>
      <guid>https://forem.com/mattsparks/tips-for-landing-your-first-web-development-job-416o</guid>
      <description>&lt;p&gt;So, you've learned how to code and you're ready to land that first job? Great! Over the years, I've held a number of development jobs and hired a number of developers. Here are some tips, from my personal experience, that might be helpful in your job search.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technical
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Understand Git/version control
&lt;/h4&gt;

&lt;p&gt;In modern development, you'll be hard-pressed to find a development team that doesn't utilize some type of version control. Nowadays Git is the king of VC, but Subversion and others are still in use. &lt;/p&gt;

&lt;p&gt;A lot of junior developers I've interviewed have simply "known of" Git. While that's not a deal breaker, knowing the basics of Git can definitely give you a leg up on the competition.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://try.github.io/"&gt;Resources to Learn Git&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Show Your Work
&lt;/h4&gt;

&lt;p&gt;If you're just starting out, you likely haven't worked on very many projects. No worries! A junior developer isn't (or at least shouldn't be) expected to have a crazy-impressive resume.&lt;/p&gt;

&lt;p&gt;That being said, you'll still need to demonstrate your knowledge and abilities.&lt;/p&gt;

&lt;p&gt;This can be accomplished a few different ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Work on personal projects – a blog, a package/library, some random fun idea.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://opensource.com/life/16/1/6-beginner-open-source"&gt;Contribute to Open Source&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;School assignments.&lt;/li&gt;
&lt;li&gt;See if any friends or family could use your skills (for a free or otherwise)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Research The Company
&lt;/h4&gt;

&lt;p&gt;Find out as much as you can about your potential new employer. This will give you a better idea of what they do, what they use, and what you can expect during the interview.&lt;/p&gt;

&lt;p&gt;For example, if you find through your research that most of their apps are built using Laravel – then it would be a good idea to make sure you're up-to-speed with that framework.&lt;/p&gt;

&lt;h4&gt;
  
  
  Continue to Learn
&lt;/h4&gt;

&lt;p&gt;This isn't just a tip for getting a job. This is a life tip. Put new things in your brain as often as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Non-Technical
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Be Yourself
&lt;/h4&gt;

&lt;p&gt;Don't try to be the person you think the interviewer wants you to be. If you don't know what something is or how to do something, don't try to fake it. You'll show up on your first day of work and be assigned to a task that you have no idea how to complete. That's not fun.&lt;/p&gt;

&lt;p&gt;If you try to be something you're not, you're doing a disservice to yourself and the company.&lt;/p&gt;

&lt;p&gt;You're awesome, so don't sweat it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“We are what we pretend to be, so we must be careful about what we pretend to be.” ― Kurt Vonnegut&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Try to Relax
&lt;/h4&gt;

&lt;p&gt;I know that this tip is easier said than done. I struggle with anxiety and I've literally shaken through entire interviews. Take a deep breath and try to calm yourself. You'll be able to answer questions more thoughtfully and with more confidence. Just remember: that person interviewing you is just another human – with all the same human things going on in their head. If you don't get this job, there will be other opportunities.&lt;/p&gt;




&lt;p&gt;I hope you find these tips useful. In an upcoming post, I'll share some tips on landing your first freelance client.&lt;/p&gt;

&lt;p&gt;I'd love to know your tips for getting that first development job. Let me know in the comments!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>career</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Quick JavaScript Tip: the some() method</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Wed, 22 May 2019 18:23:02 +0000</pubDate>
      <link>https://forem.com/mattsparks/quick-javascript-tip-the-some-method-207j</link>
      <guid>https://forem.com/mattsparks/quick-javascript-tip-the-some-method-207j</guid>
      <description>&lt;p&gt;I recently learned of a great JavaScript method I'd never used. It was brought to my attention by &lt;a href="https://wesbos.com"&gt;Wes Bos&lt;/a&gt;. The &lt;code&gt;some()&lt;/code&gt; method is a convenient way to test the values of an array and see if at least one value returns &lt;code&gt;true&lt;/code&gt;. &lt;code&gt;some()&lt;/code&gt; was implemented before ES6 and its support is &lt;a href="http://kangax.github.io/compat-table/es5/#test-Array.prototype.some"&gt;wide-spread&lt;/a&gt; (Internet Explorer 11 supports it).&lt;/p&gt;

&lt;p&gt;It's important to note that this method only works on true &lt;code&gt;Array&lt;/code&gt;s. Other iterable types do not implement this method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; You have an array containing the types of animals your hotel allows. How can you determine if your pet snake, Mr. Slithers, can come along on your trip?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An Older Way:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;animals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dogs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cats&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;snakes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;birds&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pandas&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;snakesAllowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;snakes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;snakesAllowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;snakesAllowed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using &lt;code&gt;.some()&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using arrow functions&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dogs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cats&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;snakes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;birds&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pandas&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;snakesAllowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;some&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;snakes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;snakesAllowed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;

&lt;span class="c1"&gt;// Using normal functions&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dogs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cats&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;snakes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;birds&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pandas&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;snakesAllowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;snakes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;snakesAllowed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Addendum:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a class="comment-mentioned-user" href="https://dev.to/attacomsian"&gt;@attacomsian&lt;/a&gt;
 mentioned in the comments that &lt;code&gt;.includes()&lt;/code&gt; would be a better fit for the problem above. I completely agree. The example above was just to illustrate how &lt;code&gt;.some()&lt;/code&gt; works rather than solve the problem in the most efficient way.&lt;/p&gt;

&lt;p&gt;For another example to illustrate &lt;code&gt;.some()&lt;/code&gt;'s functionality, let's say we have an array of comic book prices and we want to know if any cost more than $10.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;aboveTen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;some&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;aboveTen&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some"&gt;MDN web docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tips</category>
    </item>
    <item>
      <title>Yet Another Resources List!</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Tue, 21 May 2019 21:14:29 +0000</pubDate>
      <link>https://forem.com/mattsparks/yet-another-resources-list-38k8</link>
      <guid>https://forem.com/mattsparks/yet-another-resources-list-38k8</guid>
      <description>&lt;p&gt;Recently, I did an &lt;a href="https://dev.to/mattsparks/i-ve-been-coding-for-20-years-ask-me-anything-4l54"&gt;AMA&lt;/a&gt;. It was a ton of fun and I hope those who participated got something out of it. A few of the questions centered around resources for web development. Because of that, I thought it might be useful to compile a list of tools, blogs, and tips. &lt;/p&gt;

&lt;p&gt;Without further ado, I give you my list of resources that you've probably seen a billion times on other "list of resources." These are completely random and not very organized. Enjoy!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Note: If a resource isn't free, I've marked it with an *]&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  API Related
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://apisyouwonthate.com/"&gt;APIs You Won't Hate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.getpostman.com/"&gt;Postman&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Blogs/News
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.aaron-gustafson.com/"&gt;Aaron Gustafson&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://adamwathan.me/"&gt;Adam Wathan&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bram.us"&gt;Bram.us&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.brucelawson.co.uk"&gt;Bruce Lawson&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://catswhocode.com/"&gt;Cats Who Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/"&gt;CSS Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ericlbarnes.com/"&gt;Eric L. Barnes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://fabien.potencier.org/"&gt;Fabien Potencier&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://murze.be/"&gt;murze.be&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://phpdeveloper.org"&gt;PHPDeveloper.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://sebastiandedeyne.com/"&gt;Sebastian De Deyne&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.yegor256.com/"&gt;Yegor Bugayenko&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://laravelnews.com"&gt;Laravel News&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.phparch.com/"&gt;php[architect]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://news.ycombinator.com/"&gt;Hacker News&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Error/Bug Tracking
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://sentry.io/welcome/"&gt;Sentry&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Git/Deployment/Continuous Development
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://git-scm.com/"&gt;git-scm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bocoup.com/blog/git-workflows-for-successful-deployment"&gt;Git Workflows For Successful Deployment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nvie.com/posts/a-successful-git-branching-model/"&gt;A Successful Git Branching Model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://styleci.io/"&gt;StyleCI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jenkins.io/"&gt;Jenkins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modess.io/jenkins-php/"&gt;Jenkins &amp;amp; PHP, continuous integration tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  JavaScript
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://exploringjs.com/es6/"&gt;Exploring ES6&lt;/a&gt;(online book)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript30.com/"&gt;JavaScript 30&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Newsletters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.phpweekly.com/"&gt;PHP Weekly&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Planning/Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://noteplan.co/"&gt;NotePlan&lt;/a&gt;*&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Random
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://sourcemaking.com/design_patterns"&gt;Design Patterns&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/"&gt;MDN Web Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/"&gt;W3Schools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://caniuse.com/#home"&gt;Can I Use...&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  RegEx
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.regular-expressions.info/"&gt;Regular-Expressions.info&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://regexr.com/"&gt;RegExr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Text Editors
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://atom.io/"&gt;Atom&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sublimetext.com/"&gt;Sublime Text&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.jetbrains.com/phpstorm/"&gt;PHP Storm&lt;/a&gt;*&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Video Tutorials
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://laracasts.com"&gt;Laracasts&lt;/a&gt;*&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://es6.io/"&gt;ES6 For Everyone&lt;/a&gt;*&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://serversforhackers.com/"&gt;Servers For Hackers&lt;/a&gt;*&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Some Awesome Dev Folks on Twitter
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;in no particular order&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/grmpyprogrammer"&gt;@grmpyprogrammer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/coderabbi"&gt;@coderabbi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/matthewtrask"&gt;@matthewtrask&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/manchuck"&gt;@manchuck&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/philsturgeon"&gt;@philsturgeon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/JoePFerguson"&gt;@JoePFerguson&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/christophrumpel"&gt;@christophrumpel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/jeffrey_way"&gt;@jeffrey_way&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/funkatron"&gt;@funkatron&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/saldaek"&gt;@saldaek&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/taylorotweel"&gt;@taylorotweel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/shocm"&gt;@shocm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/SammyK"&gt;@SammyK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/GeeH"&gt;@GeeH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/freekmurze"&gt;@freekmurze&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/ramsey"&gt;@ramsey&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/benedmunds"&gt;@benedmunds&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/ericlbarnes"&gt;@ericlbarnes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/marcelpociot"&gt;@marcelpociot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/youyuxi"&gt;@youyuxi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/stauffermatt"&gt;@stauffermatt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/dhh"&gt;@dhh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/zeevs"&gt;@zeevs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/andy_huggins"&gt;@andy_huggins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/mamund"&gt;@mamund&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/s_bergmann"&gt;@s_bergmann&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/PovilasKorop"&gt;@PovilasKorop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/AaronGustafson"&gt;@AaronGustafson&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/LeaVerou"&gt;@LeaVerou&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/davidwalshblog"&gt;@davidwalshblog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/stellarcowboy"&gt;@stellarcowboy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/rasmus"&gt;@rasmus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/SaraMG"&gt;@SaraMG&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/auroraosrose"&gt;@auroraosrose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/fideloper"&gt;@fideloper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/dead_lugosi"&gt;@dead_lugosi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/SatchKat"&gt;@SatchKat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/SagnewShreds"&gt;@SagnewShreds&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Oh, you can follow me too if you'd like 🙃 &lt;a href="https://twitter.com/DevelopmentMatt"&gt;@DevelopmentMatt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please add any resources you use in the comments!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>resources</category>
      <category>javascript</category>
      <category>php</category>
    </item>
    <item>
      <title>I've been coding for 20 years, Ask Me Anything!</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Thu, 16 May 2019 20:11:46 +0000</pubDate>
      <link>https://forem.com/mattsparks/i-ve-been-coding-for-20-years-ask-me-anything-4l54</link>
      <guid>https://forem.com/mattsparks/i-ve-been-coding-for-20-years-ask-me-anything-4l54</guid>
      <description>&lt;p&gt;My first website was built on GeoCities! I remember the original browser wars! I may or may not belonged to a webring or two.&lt;/p&gt;

&lt;p&gt;I've worked for successful start up's, failed start up's, large companies, freelance, and everything in between.&lt;/p&gt;

&lt;p&gt;Today I'm primarily a PHP developer, but I've written code in many different languages using many different tools and philosophies. &lt;/p&gt;

</description>
      <category>ama</category>
    </item>
    <item>
      <title>Building a PHP Framework: Part 8 - Routing</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Fri, 10 Aug 2018 00:11:51 +0000</pubDate>
      <link>https://forem.com/mattsparks/building-a-php-framework-part-8---routing-4jgf</link>
      <guid>https://forem.com/mattsparks/building-a-php-framework-part-8---routing-4jgf</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="http://developmentmatt.com/building-a-php-framework-part-7-the-container/"&gt;Originally posted on DevelopmentMatt.com&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://developmentmatt.com/building-a-php-framework-part-7-the-container/"&gt;Part 7&lt;/a&gt; got us up to speed on the container that will be used in the Analyze PHP Framework. In this post we'll cover how routing works in general and specifically within PHP.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Routing Works
&lt;/h2&gt;

&lt;p&gt;Routing is the process of parsing a URI and determining the appropriate action to take.&lt;/p&gt;

&lt;p&gt;For example, consider the following URI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com/login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How does a request like the one above result in a response to the user? Let's break it down:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The request is received by the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application breaks down the request into its components. Things like: the method (ex: GET), host, path, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application looks for a defined route that matches this request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once found, it takes the defined action and returns a response.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  A Laravel Example
&lt;/h3&gt;

&lt;p&gt;For a real-world example, here's one way the above example could be implemented in Laravel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/login'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'login'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We define a GET route for the /login URI. When that route is requested we return a response – in this case, HTML for the login page.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Routers Work
&lt;/h2&gt;

&lt;p&gt;There are a number of routers in the PHP ecosystem. They range from the more simplistic to feature-packed behemoths. Although they differ in size and complexity, they generally employ the same fundamental steps: parse the request, match the pattern, run some code, return a response.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/symfony/routing"&gt;Symfony router&lt;/a&gt; (probably the most widely used PHP router) does this.&lt;/p&gt;

&lt;p&gt;As does &lt;a href="https://github.com/bramus/router"&gt;this one&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And &lt;a href="https://github.com/nikic/FastRoute"&gt;this one&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Very Simple PHP Router
&lt;/h2&gt;

&lt;p&gt;To demonstrate these concepts let's create a stupid simple, not at all useful, PHP router.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="cd"&gt;/**
 * First, let's define our Router object.
 */&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Router&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * The request we're working with.
     *
     * @var string
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * The $routes array will contain our URI's and callbacks.
     * @var array
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * For this example, the constructor will be responsible
     * for parsing the request.
     *
     * @param array $request
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="cd"&gt;/**
         * This is a very (VERY) simple example of parsing
         * the request. We use the $_SERVER superglobal to
         * grab the URI.
         */&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'REQUEST_URI'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Add a route and callback to our $routes array.
     *
     * @param string   $uri
     * @param Callable $fn
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;addRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nc"&gt;Closure&lt;/span&gt; &lt;span class="nv"&gt;$fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;void&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$fn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Determine is the requested route exists in our
     * routes array.
     *
     * @param  string  $uri
     * @return boolean
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;hasRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;array_key_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Run the router.
     *
     * @return mixed
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cd"&gt;/**
 * Create a new router instance.
 */&lt;/span&gt;
&lt;span class="nv"&gt;$router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_SERVER&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cd"&gt;/**
 * Add a "hello" route that prints to the screen.
 */&lt;/span&gt;
&lt;span class="nv"&gt;$router&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;addRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'hello'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'Well, hello there!!'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="cd"&gt;/**
 * Run it!
 */&lt;/span&gt;
&lt;span class="nv"&gt;$router&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run The Code
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Save this code locally as index.php.&lt;/li&gt;
&lt;li&gt;In your terminal navigate to the directory where you saved the script.&lt;/li&gt;
&lt;li&gt;Start the built-in PHP web server: &lt;code&gt;php -S localhost:1234&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In your browser go to: &lt;code&gt;http://localhost:1234/hello&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I've touched on the very basics of routing, shared some routing examples from the PHP world, and built a extremely simple router. On a related note, I've started work on the router that will be used in the Analyze PHP framework. To keep up to speed on it, be sure to follow &lt;a href="https://twitter.com/AnalyzePHP"&gt;@AnalyzePHP&lt;/a&gt; on Twitter.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One last thing, be sure to checkout my newsletter! Each week I'll send you a great email filled with updates, great links, tips &amp;amp; tricks, and other non-dev randomness. If you're interested you can sign up by &lt;a href="http://eepurl.com/dvwlM5"&gt;following this link&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>routing</category>
      <category>frameworks</category>
    </item>
    <item>
      <title>I Want Scalar Objects in PHP</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Wed, 18 Jul 2018 12:03:49 +0000</pubDate>
      <link>https://forem.com/mattsparks/i-want-scalar-objects-in-php-2o6b</link>
      <guid>https://forem.com/mattsparks/i-want-scalar-objects-in-php-2o6b</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="http://developmentmatt.com/i-want-scalar-objects-in-php/" rel="noopener noreferrer"&gt;Originally Posted on DevelopmentMatt.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recently, I read an interesting article from Andrew Carter entitled &lt;a href="http://andrew.carterlunn.co.uk/programming/2018/06/25/make-php-great-again.html" rel="noopener noreferrer"&gt;Make PHP Great Again&lt;/a&gt; &lt;em&gt;[cheap plug: this link was included in my most recent &lt;a href="http://developmentmatt.com/newsletter/" rel="noopener noreferrer"&gt;Newsletter&lt;/a&gt;]&lt;/em&gt;. In it Andrew brought up the topic of scalar objects. If you're not familiar with scalar objects, they represent a single value (integer, boolean, string, etc.) that you can perform operations on*. In PHP this could look something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Matt'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;length&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// int(4)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;* It's important to note that, as far as I've been able to ascertain, the context in which you use the term "scalar" is important. Different languages implement and define scalar differently.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Soon after scalar objects were brought to the forefront of my mind, I came across the following tweet:&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1018966511388647429-620" src="https://platform.twitter.com/embed/Tweet.html?id=1018966511388647429"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1018966511388647429-620');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1018966511388647429&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;To which I replied:&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1018971564287713281-488" src="https://platform.twitter.com/embed/Tweet.html?id=1018971564287713281"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1018971564287713281-488');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1018971564287713281&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  The Case For Scalar Objects in PHP
&lt;/h2&gt;

&lt;p&gt;If you read Andrew's post he discusses how PHP's core functions are inconsistent. This topic isn't new:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/#standard-library" rel="noopener noreferrer"&gt;PHP: a fractal of bad design&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.php.net/rfc/consistent_function_names" rel="noopener noreferrer"&gt;PHP RFC: Consistent Function Names&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PHP 8 is a great opportunity to cleanup these inconsistencies. Introducing scalar objects would provide a consistent API that would be more fluent and much more enjoyable to work with. Which of the following is more intuitive to you?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$hello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;str_replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Matt'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Bob'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Hello Matt!'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hello&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Hello Bob!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$hello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Hello Matt!'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hello&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Matt'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Bob'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Hello Bob!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I know this is a silly example, but doesn't the second bit of code just feel better?&lt;/p&gt;

&lt;p&gt;Let's get scalar objects in PHP 8! Who's with me?!?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/hashtag/ScalarIn8?src=hash" rel="noopener noreferrer"&gt;&lt;code&gt;#ScalarIn8&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building a PHP Framework: Part 7 - The Container</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Sun, 08 Jul 2018 21:52:29 +0000</pubDate>
      <link>https://forem.com/mattsparks/building-a-php-framework-part-7---the-container-1edc</link>
      <guid>https://forem.com/mattsparks/building-a-php-framework-part-7---the-container-1edc</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="http://developmentmatt.com/building-a-php-framework-part-7-the-container/"&gt;Orginially Posted on DevelopmentMatt.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://developmentmatt.com/building-a-php-framework-part-6-dependency-inversion-inversion-of-control-oh-my/"&gt;Part 6&lt;/a&gt; began our discussion of PHP containers. Today, I'll be going into greater detail of the subject and, along with that, I'll run down the work done so far on the Analyze container.&lt;/p&gt;

&lt;p&gt;A huge debt of gratitude goes how to the folks behind the &lt;a href="http://container.thephpleague.com/"&gt;PHP League Container&lt;/a&gt; and others. I've learned a ton studying their code.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Quick Recap
&lt;/h2&gt;

&lt;p&gt;What are containers and why do we use them? A container is both a registry composed of objects and a mechanism for retrieving them. It's the library and the librarian, so to speak. Containers provide developers a tool to more easily manage dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Analyze Container
&lt;/h2&gt;

&lt;p&gt;Work has begun on the container that will be used in the Analyze framework and, as of this writing, the foundation is essentially complete. Keep in mind that it's not finished, but it is far enough along to discuss it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/AnalyzePHP/framework/tree/master/src/Analyze/Container"&gt;All of the code for the container can be found on Github.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  A Simple Example
&lt;/h3&gt;

&lt;p&gt;Currently, there are two ways to register an object with the container. The first is by using a factory. A factory uses a Closure to build the object upon retrieval.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$container&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$container&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;addFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Carbon'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nc"&gt;Carbon\Carbon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nv"&gt;$carbon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$container&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Carbon'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$carbon&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 2018&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second option is to register a class using it's fully qualified name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$container&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$container&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;addClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Carbon'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'\Carbon\Carbon'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nv"&gt;$carbon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$container&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Carbon'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$carbon&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 2018&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both methods take an alias as their first parameter.&lt;/p&gt;

&lt;h2&gt;
  
  
  How The Container Works
&lt;/h2&gt;

&lt;p&gt;At its most basic core, the container is simply an object with a parameter – an array – that holds object definitions. When we ask for a dependency (&lt;code&gt;get('Carbon')&lt;/code&gt;), the container looks for it in that array. If it's found, the object is built and returned. If not, an exception is thrown. Specifically, a &lt;code&gt;NotFoundException&lt;/code&gt; exception.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; 

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Container&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;ContainerInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Definitions
     * @var array
     */&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$definitions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Get
     *
     * Returns the passed alias.
     *
     * @param  string $id
     * @return mixed
     * @throws NotFoundException
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'%s is not defined.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nv"&gt;$definition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;definitions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="nv"&gt;$definition&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;addArguments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$definition&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Definitions
&lt;/h3&gt;

&lt;p&gt;Definitions are the most important aspect of the container. They define how to build objects and without that functionality there's no use having a container. Each definition must implement the &lt;code&gt;DefinitionInterface&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;DefinitionInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * Build
     *
     * @return object
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means, each definition must have a &lt;code&gt;build&lt;/code&gt;  method that returns an object.&lt;/p&gt;

&lt;p&gt;Each definition should, but aren't technically required to, extend the &lt;code&gt;AbstractDefinition&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AbstractDefinition&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;DefinitionInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * Arguments
     * @var array
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Add Arguments
     *
     * @param array $args
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;addArguments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$args&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Has Arguments
     *
     * @return bool
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;hasArguments&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This class provides properties and methods that are used across definitions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FactoryDefinition&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AbstractDefinition&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * Callback
     * @var Closure
     */&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$callback&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Constructor
     *
     * @param Closure $callback
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Closure&lt;/span&gt; &lt;span class="nv"&gt;$callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;callback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$callback&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Build
     *
     * @return object
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;call_user_func_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ClassDefinition&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AbstractDefinition&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * Concrete
     * @var string
     */&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$concrete&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Constructor
     *
     * @param string $concrete
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$concrete&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;concrete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$concrete&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Build
     *
     * @return object
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasArguments&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$reflection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ReflectionClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;concrete&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$reflection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;newInstanceArgs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;concrete&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, both types of definition describe how to build an object.&lt;/p&gt;

&lt;h3&gt;
  
  
  Arguments
&lt;/h3&gt;

&lt;p&gt;I'm sure you've noticed in the code above that arguments can be used when building an object. For example, let's say you can to pass a date and time when building a Carbon instance. Here's what that would look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$container&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;withArguments&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'2010-05-16 22:40:10'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Carbon'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What's Left to do
&lt;/h2&gt;

&lt;p&gt;There's still quite a bit of work to be done on the container, but I'm pretty happy with where things are. The most pressing features left are implementing a &lt;code&gt;SetterDefinition&lt;/code&gt; and, related to that, the ability to call methods. I'll also be using reflection to automatically inject dependencies. I'm not entirely sure how that's going to look, but I'm excited to get started on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feedback
&lt;/h2&gt;

&lt;p&gt;I'd love to hear from you. If you have suggestions or whatever else, hit me up on my &lt;a href="https://twitter.com/DevelopmentMatt"&gt;Twitter machine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One last thing, be sure to checkout my newsletter! Each week I'll send you a great email filled with updates, great links, tips &amp;amp; tricks, and other non-dev randomness. If you're interested you can sign up by following this &lt;a href="http://eepurl.com/dvwlM5"&gt;link&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>PHP Reflection</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Wed, 27 Jun 2018 22:22:25 +0000</pubDate>
      <link>https://forem.com/mattsparks/php-reflection-47ne</link>
      <guid>https://forem.com/mattsparks/php-reflection-47ne</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted on &lt;a href="https://developmentmatt.com/php-reflection/"&gt;DevelopmentMatt&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Beginning work on the Analyze PHP framework, specifically the container, brought reflection to my awareness. Before that I had maybe heard the term, but I definitely hadn't used it intentionally. Although it sounds like a scary computer science concept, it's not. It's actually quite simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Reflection is the ability of a computer program to examine, introspect, and modify its own structure...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's it. (Thanks, &lt;a href="https://en.wikipedia.org/wiki/Reflection_(computer_programming)"&gt;Wikipedia&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Reflection in PHP
&lt;/h2&gt;

&lt;p&gt;PHP provides a complete &lt;a href="http://php.net/manual/en/book.reflection.php"&gt;reflection API&lt;/a&gt; and multiple functions right out of the box. This provides an object the ability to examine itself and report back things like its methods and properties. With that functionality, we can automatically create documentation, inject dependencies, and a lot more.&lt;/p&gt;

&lt;p&gt;It's possible that you have used reflection and didn't realize it. If you've ever used the get_class()  or method_exists()  functions, you've used reflection.&lt;br&gt;
Examples of PHP Reflection&lt;/p&gt;

&lt;p&gt;Here's the class we'll be working with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Springfield\Characters&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Simpson&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start off, let's use some of PHP's built in functions to print out information about the class. First, we'll print out the class methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$homer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Simpson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Homer'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;get_class_methods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$homer&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// array(2) { [0]=&amp;gt; string(11) "__construct" [1]=&amp;gt; string(7) "getName" }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let's just get the name of the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$homer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Simpson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Homer'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;get_class&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$homer&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Springfield\Characters\Simpson&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As I mentioned above, PHP provides a complete API. The PHP Reflection class provides us with a lot of powerful tools to inspect our objects. Using the class is simple, just instantiate the class passing along the object you'd like to inspect. Like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$reflection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nf"&gt;ReflectionClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$homer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can get the class' properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$reflection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getProperties&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="c1"&gt;// array(1) { [0]=&amp;gt; object(ReflectionProperty)#3 (2) { ["name"]=&amp;gt; string(4) "name" ["class"]=&amp;gt; string(30) "Springfield\Characters\Simpson"  }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or get the constructor and learn about its parameters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$constructor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$reflection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getConstructor&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$constructor&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getParameters&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="c1"&gt;// array(1) { [0]=&amp;gt; object(ReflectionParameter)#4 (1) { ["name"]=&amp;gt; string(4) "name" } }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;While you may not use reflection daily, there are times it can come in very handy – working with other people's code, for example. I encourage you to checkout the links in the Further Reading section below to learn more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://php.net/manual/en/book.reflection.php"&gt;Reflection (PHP Docs)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/tech-tajawal/introduction-to-php-reflection-api-4af07cc17db4"&gt;What is Reflection in PHP?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/tech-tajawal/introduction-to-php-reflection-api-4af07cc17db4"&gt;Introduction to PHP Reflection API&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building a PHP Framework: Part 6 - Dependency Inversion, Inversion of Control, oh my!</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Thu, 07 Jun 2018 23:12:41 +0000</pubDate>
      <link>https://forem.com/mattsparks/building-a-php-framework-part-6---dependency-inversion-inversion-of-control-oh-my-58</link>
      <guid>https://forem.com/mattsparks/building-a-php-framework-part-6---dependency-inversion-inversion-of-control-oh-my-58</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/mattsparks/building-a-php-framework-part-5---test-driven-development-1gib"&gt;Part 5&lt;/a&gt; of this series discussed test driven development (TDD). Today, I'll be talking about Dependency Inversion, Inversion of Control, Dependency Injection, and other related topics.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Dependency Injection?
&lt;/h2&gt;

&lt;p&gt;We'll start with Dependency Injection since it will lead us into our other topics. &lt;a href="https://en.wikipedia.org/wiki/Dependency_injection"&gt;Wikipedia&lt;/a&gt; tells us that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In software engineering, dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Have you ever wrote code similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ComicBook&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$mainCharacter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Superhero&lt;/span&gt; &lt;span class="nv"&gt;$superhero&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;mainCharacter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$superhero&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$superhero&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Caffeine Man'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$comic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ComicBook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$superhero&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's Dependency Injection in action. Our &lt;code&gt;ComicBook&lt;/code&gt; object depends on our &lt;code&gt;Superhero&lt;/code&gt; object so we inject it. Get it?&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Dependency Inversion?
&lt;/h2&gt;

&lt;p&gt;Comic books aren't always about superheroes. What if we wanted a comic book whose main character was a dog or a vampire or a vampiric dog? Let's re-write our code to allow any type of character to be used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;CharacterInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * All classes implementing this interface must provide a getName method.
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Character&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;CharacterInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Character&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VampiricDog&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Character&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ComicBook&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$mainCharacter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;CharacterInterface&lt;/span&gt; &lt;span class="nv"&gt;$character&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;mainCharacter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$character&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$superhero&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Superhero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Caffeine Man'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$superheroComic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ComicBook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$superhero&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$superheroComic&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;mainCharacter&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="nv"&gt;$vampireDog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;VampiricDog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Mr. Fangz'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$vampireComic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ComicBook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$vampireDog&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$vampireComic&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;mainCharacter&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because we're coding to an interface we can now create any type of character for use in a comic book. We've completely decoupled our character implementation from our comic book implementation. Think about it – a comic book just wants to be a comic book and to do comic book things. It doesn't care what kind of character you give it, it just knows it needs one. Once the character is in place the comic book can get back to doing the work of a comic book. &lt;a href="https://en.wikipedia.org/wiki/Dependency_inversion_principle"&gt;In other words&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A. High-level modules [ComicBook ] should not depend on low-level modules [Superhero ]. Both should depend on abstractions [CharacterInterface ].&lt;br&gt;
B. Abstractions should not depend on details. Details should depend on abstractions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is Inversion of Control (IoC)?
&lt;/h2&gt;

&lt;p&gt;Inversion of Control is sometimes referred to as "Hollywood's Law." As in, "don't call us, we'll call you." &lt;a href="https://martinfowler.com/articles/dipInTheWild.html"&gt;Brett Schuchert&lt;/a&gt; uses the game Monopoly to explain the concept:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Imagine the Monopoly system created with a number of players. The game orchestrates interaction between players. When it's time to have a player take a turn, the game might ask the player if it has any pre-movement actions such as selling houses or hotels, then the game will move the player based on the roll of the dice (in the real world, a physical player rolls dice and moves his or her token, but that's an artifact of the board game not being a computer - that is, it's a phenomenological description of what's going on rather than an ontological description). Notice that the game knows when a player can make decisions and prompts the player accordingly, rather than the player making the decision.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In traditional procedural programming steps are taken one after the other (do this, then do this, then do this). When a human takes a turn in Monopoly, they're in control:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Buy hotel.&lt;/li&gt;
&lt;li&gt;Roll dice.&lt;/li&gt;
&lt;li&gt;Move to new spot.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If a computer were in control of the game it would look more like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer: Would you like to make a purchase? 
Human: I would like to buy a hotel. 
Computer: Great, here's your hotel. Do you want to make additional purchases? Human: No. 
Computer: Please roll the dice and move to a new spot.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The flow of the game is completely inverted.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an IoC Container?
&lt;/h2&gt;

&lt;p&gt;An IoC Container is a bit of a misnomer. A better and more accurate name is Dependency Injection Container (DiC). The two terms get used interchangeably all the time. Regardless, a DiC is responsible for managing objects – from how they're created to how they're configured. Frameworks use containers to inject dependencies at run-time.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Does This Have to do With a Framework?
&lt;/h2&gt;

&lt;p&gt;A lot, actually. When you use a framework you're essentially giving it control of your application. Additionally, IoC/DiC containers lay the foundation for most frameworks. I've begun work on the Analyze container, feel free to keep up with the progress on &lt;a href="https://github.com/AnalyzePHP/framework"&gt;Github&lt;/a&gt;. Once it's finished I'm going to do a deep dive into how it works and does what it does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.martinfowler.com/articles/injection.html"&gt;Inversion of Control Containers and the Dependency Injection pattern&lt;/a&gt;&lt;br&gt;
&lt;a href="http://fabien.potencier.org/what-is-dependency-injection.html"&gt;What is Dependency Injection?&lt;/a&gt;&lt;br&gt;
&lt;a href="http://ralphschindler.com/2012/10/10/di-dic-service-locator-redux"&gt;DI, DiC, &amp;amp; Service Locator Redux&lt;/a&gt;&lt;br&gt;
&lt;a href="https://martinfowler.com/articles/dipInTheWild.html"&gt;DIP in the Wild&lt;/a&gt;&lt;br&gt;
&lt;a href="https://martinfowler.com/bliki/InversionOfControl.html"&gt;InversionOfControl&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One last thing, be sure to checkout my newsletter! Each week I'll send you a great email filled with updates, great links, tips &amp;amp; tricks, and other non-dev randomness. If you're interested you can sign up by following this &lt;a href="http://eepurl.com/dvwlM5"&gt;link&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://developmentmatt.com/building-a-php-framework-part-6-dependency-inversion-inversion-of-control-oh-my/"&gt;Originally Posted on DevelopmentMatt.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Use PHP Traits</title>
      <dc:creator>Matt Sparks</dc:creator>
      <pubDate>Thu, 31 May 2018 23:33:43 +0000</pubDate>
      <link>https://forem.com/mattsparks/how-to-use-php-traits-459m</link>
      <guid>https://forem.com/mattsparks/how-to-use-php-traits-459m</guid>
      <description>&lt;p&gt;&lt;a href="http://php.net/manual/en/language.oop5.traits.php"&gt;PHP Traits&lt;/a&gt; are a great tool for code reuse. They allow developers to write methods that can be used in any number of classes, keeping your code DRY and more maintainable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Define a PHP Trait
&lt;/h2&gt;

&lt;p&gt;Traits are defined much in the same way as classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;RobotSkillz&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll notice that we're declaring a &lt;code&gt;trait&lt;/code&gt;  rather than a &lt;code&gt;class&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A PHP Trait Example
&lt;/h2&gt;

&lt;p&gt;Let's pretend we have a large number of classes related to film genres. Each class has public properties that we would like to return as either an array or JSON.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HorrorFilm&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$genre&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$rating&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$releaseDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getGenre&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getLength&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getRating&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getReleaseDate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;releaseDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getTitle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setGenre&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$genre&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;genre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$genre&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$minutes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$minutes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setRating&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$rating&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$rating&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setReleaseDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;releaseDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$date&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;setTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we'll create a trait that adds the methods we need and can be reused across all of our classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;ArrayOrJson&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;asArray&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;get_object_vars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;asJson&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;json_encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;asArray&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We add this trait to our class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HorrorFilm&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;ArrayOrJson&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="mf"&gt;...&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Putting it all together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$film&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;HorrorFilm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Kill All Humans!'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setGenre&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Slasher'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;124&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setRating&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'R'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setReleaseDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'November 2, 2019'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;asArray&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$film&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;asJson&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array(5) { ["genre"]=&amp;gt; string(7) "Slasher" ["length"]=&amp;gt; int(124) ["rating"]=&amp;gt; string(1) "R" ["releaseDate"]=&amp;gt; 

string(16) "November 2, 2019" ["title"]=&amp;gt; string(16) "Kill All Humans!" } string(105) "{"genre":"Slasher","length":124,"rating":"R","releaseDate":"November 2, 2019","title":"Kill All Humans!"}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Originally Posted on &lt;a href="https://developmentmatt.com/how-to-use-php-traits/"&gt;DevelopmentMatt&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
