<?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>DEV Community: Akande Joshua</title>
    <description>The latest articles on DEV Community by Akande Joshua (@homezonic).</description>
    <link>https://dev.to/homezonic</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%2F627471%2Fa7ea6f76-3310-48c0-8440-391bfecfb6d2.jpeg</url>
      <title>DEV Community: Akande Joshua</title>
      <link>https://dev.to/homezonic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/homezonic"/>
    <language>en</language>
    <item>
      <title>Understanding Conditional Validation in Laravel with sometimes</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Mon, 19 May 2025 04:38:10 +0000</pubDate>
      <link>https://dev.to/homezonic/understanding-conditional-validation-in-laravel-with-sometimes-h81</link>
      <guid>https://dev.to/homezonic/understanding-conditional-validation-in-laravel-with-sometimes-h81</guid>
      <description>&lt;h2&gt;
  
  
  Understanding &lt;code&gt;sometimes&lt;/code&gt; in Laravel
&lt;/h2&gt;

&lt;p&gt;When building apps with Laravel or even rest-api, validation is a key part of keeping your data clean and reliable. But what happens when you need to apply validation &lt;strong&gt;only under certain conditions&lt;/strong&gt;? That’s where the &lt;code&gt;sometimes&lt;/code&gt; method comes in handy. Let’s break it down with a simple explanation and a real-word example.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is &lt;code&gt;sometimes&lt;/code&gt; in Laravel Validation?
&lt;/h2&gt;

&lt;p&gt;In Laravel, the &lt;code&gt;sometimes&lt;/code&gt; method allows you to conditionally apply validation rules. This is especially useful when you only want to validate a field &lt;strong&gt;if it’s actually present&lt;/strong&gt; in the request or if some other condition is met.&lt;/p&gt;

&lt;p&gt;For example:&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;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="s1"&gt;'field'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'sometimes|required|string'&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;In this case, the field will only be validated if it exists in the request. If the field is not present, it won’t trigger any validation errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Example: Profile Update Form
&lt;/h2&gt;

&lt;p&gt;Let’s say you're building an e-commerce app, and you have a profile update form where users can upload an optional profile picture, not everyone loves uploading pictures, me included. You want to validate the profile picture only if the user uploads one.&lt;/p&gt;

&lt;p&gt;Here’s how you can use &lt;code&gt;sometimes&lt;/code&gt; to make it work:&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;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&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="nv"&gt;$validated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
        &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|string|max:255'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|email|unique:users,email,'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nf"&gt;auth&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;id&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="s1"&gt;'profile_picture'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'sometimes|image|max:2048'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Only validate if provided&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="c1"&gt;// Do your thing and save&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;: &lt;em&gt;In this case, if the user uploads a profile picture, it will be validated as an image and checked that it doesn’t exceed 2MB. But if no picture is uploaded, Laravel will skip the validation for that field altogether.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;Using &lt;code&gt;sometimes&lt;/code&gt; in Laravel gives you the flexibility to apply validation rules only when needed. It’s a simple yet powerful tool for handling dynamic forms or conditional validation. The next time you need to validate something only if it’s provided, just remember the sometimes method!&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Turn
&lt;/h2&gt;

&lt;p&gt;Have you used sometimes in your Laravel projects? Drop a comment and let me know how it’s helped you. Feel free to ask any questions or share your tips on conditional validation!&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>validation</category>
      <category>programming</category>
    </item>
    <item>
      <title>Set Default Values in Laravel with mergeIfMissing: Real-Life Examples</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Wed, 27 Nov 2024 22:25:42 +0000</pubDate>
      <link>https://dev.to/homezonic/set-default-values-in-laravel-with-mergeifmissing-real-life-examples-54ma</link>
      <guid>https://dev.to/homezonic/set-default-values-in-laravel-with-mergeifmissing-real-life-examples-54ma</guid>
      <description>&lt;h2&gt;
  
  
  Hmmm, Let's Understand what it means
&lt;/h2&gt;

&lt;p&gt;When you're building a website, users might skip filling out certain fields in forms. But instead of leaving those fields empty, wouldn’t it be nice to give them some default values? That’s where Laravel's &lt;code&gt;mergeIfMissing&lt;/code&gt; comes in handy!  &lt;/p&gt;

&lt;p&gt;This little helper adds default values to form inputs &lt;strong&gt;only if the user hasn’t provided them.&lt;/strong&gt; Let’s dive into two practical examples, so you can see how it works in action.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example 1: User Profile Form
&lt;/h2&gt;

&lt;p&gt;Let’s say you’re building a profile page where users can:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter their &lt;strong&gt;bio&lt;/strong&gt; (a short description of themselves).
&lt;/li&gt;
&lt;li&gt;Upload a &lt;strong&gt;profile picture&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But what if they leave these fields blank? I know people like me never have anything to write about myself. :-D, You don’t want their profile to look incomplete. Instead, you can set a default bio and profile picture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;updateProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&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="c1"&gt;// We set default values if user leave out bio and profile_picture field&lt;/span&gt;
    &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;mergeIfMissing&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
        &lt;span class="s1"&gt;'bio'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Oh Yeah, I left my bio empty, hehe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'profile_picture'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'megamind-head.png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="c1"&gt;// Use the data filled by user (with defaults applied)&lt;/span&gt;
    &lt;span class="nv"&gt;$userData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&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;response&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;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$userData&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;
  
  
  Real-Life Input and Output
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Akande Joshua"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"profile_picture"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, I have entered my name but left the &lt;strong&gt;bio&lt;/strong&gt; and &lt;strong&gt;profile_picture&lt;/strong&gt; fields blank or as &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Akande Joshua"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Oh Yeah, I left my bio empty, hehe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"profile_picture"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"megamind.png"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;mergeIfMissing&lt;/code&gt;, Laravel automatically fills in the missing values without touching the user’s &lt;code&gt;name&lt;/code&gt; cos its already filled.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example 2: User Preferences Form
&lt;/h2&gt;

&lt;p&gt;Let’s say your app has a &lt;strong&gt;settings page&lt;/strong&gt; where users can choose:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whether to receive newsletters (&lt;code&gt;receive_newsletters&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;Whether to get notifications (&lt;code&gt;receive_notifications&lt;/code&gt;).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the user skips these fields, you might want to assume they don’t want these features (set them to &lt;code&gt;false&lt;/code&gt; by default), Even me don't like newsletters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;updateSettings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&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="c1"&gt;// Provide default values for missing preferences&lt;/span&gt;
    &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;mergeIfMissing&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
        &lt;span class="s1"&gt;'receive_newsletters'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'receive_notifications'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="c1"&gt;// Use the settings data&lt;/span&gt;
    &lt;span class="nv"&gt;$settingsData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&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;response&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;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$settingsData&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;
  
  
  Real-Life Input and Output
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"receive_notifications"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the user wants to get notifications but didn’t specify if they want newsletters.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"receive_newsletters"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"receive_notifications"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Laravel only fills in the &lt;strong&gt;missing newsletter preference&lt;/strong&gt; while keeping the user’s choice for notifications intact.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Use &lt;code&gt;mergeIfMissing&lt;/code&gt;?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User-Friendly Defaults:&lt;/strong&gt; Ensures missing fields have sensible defaults.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean Code:&lt;/strong&gt; You don’t need to write multiple &lt;code&gt;if&lt;/code&gt; checks to see if fields are empty.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexible:&lt;/strong&gt; Doesn’t overwrite what the user has already provided.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Therefore?
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;mergeIfMissing&lt;/code&gt;, you can build smarter, more robust forms in Laravel. Whether it’s filling in default bios or making sure preferences are complete, this method saves time and makes your app feel polished.  &lt;/p&gt;

&lt;p&gt;Next time you're building forms, think about how you can use this to improve the user experience. Your users (and your future self) will thank you! 😊  &lt;/p&gt;




</description>
      <category>tutorial</category>
      <category>opensource</category>
      <category>laravel</category>
      <category>productivity</category>
    </item>
    <item>
      <title>HackerRank: Class vs. Instance Solution using PHP (Day 4 - 30 Days of Code)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Mon, 24 Apr 2023 00:39:44 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-class-vs-instance-solution-using-php-day-4-30-days-of-code-161p</link>
      <guid>https://dev.to/homezonic/hackerrank-class-vs-instance-solution-using-php-day-4-30-days-of-code-161p</guid>
      <description>&lt;h2&gt;
  
  
  Task
&lt;/h2&gt;

&lt;p&gt;Write a Person class with an instance variable, age, and a constructor that takes an integer, &lt;strong&gt;initialAge&lt;/strong&gt;, as a parameter. The constructor must assign &lt;strong&gt;initialAge&lt;/strong&gt; to age after confirming the argument passed as &lt;strong&gt;initialAge&lt;/strong&gt; is not negative; if a negative argument is passed as &lt;strong&gt;initialAge&lt;/strong&gt;, the constructor should set &lt;strong&gt;age&lt;/strong&gt; to 0 and print Age is not valid, setting &lt;strong&gt;age&lt;/strong&gt; to 0. In addition, you must write the following instance methods:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;yearPasses()&lt;/strong&gt; should increase the age instance variable by 1 &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;amIOld()&lt;/strong&gt; should perform the following conditional actions:&lt;/li&gt;
&lt;li&gt;If age &amp;lt; 13, print You are young.&lt;/li&gt;
&lt;li&gt;If age&amp;gt;=13 and age&amp;lt;18, print You are a teenager.&lt;/li&gt;
&lt;li&gt;Otherwise, print You are old.&lt;/li&gt;
&lt;li&gt;To help you learn by example and complete this challenge, much of the code is provided for you, but you’ll be writing everything in the future. The code that creates each instance of your Person class is in the main method. Don’t worry if you don’t understand it all quite yet!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Do not remove or alter the stub code in the editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&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;Person&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;$age&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="nv"&gt;$initialAge&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;$initialAge&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&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="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Age is not valid, setting age to 0.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&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;age&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="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&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;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$initialAge&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;amIOld&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="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;13&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="s2"&gt;"You are young.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&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;else&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="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;18&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="s2"&gt;"You are a teenager.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&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;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"You are old.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;yearPasses&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;age&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&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;$T&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;intval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;fgets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;STDIN&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="nv"&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="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;$T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&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="nv"&gt;$age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;intval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;fgets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;STDIN&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="nv"&gt;$p&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;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$p&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;amIOld&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="nv"&gt;$j&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="nv"&gt;$j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$j&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="nv"&gt;$p&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;yearPasses&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;$p&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;amIOld&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&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 is part of &lt;strong&gt;30 Days of Code - Day 4&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>hackerrank</category>
      <category>hackaton</category>
      <category>programming</category>
      <category>php</category>
    </item>
    <item>
      <title>HackerRank: Birthday Cake Candles Solution using PHP (Algorithm)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Sun, 16 Apr 2023 21:38:54 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-birthday-cake-candles-solution-using-php-algorithm-38j6</link>
      <guid>https://dev.to/homezonic/hackerrank-birthday-cake-candles-solution-using-php-algorithm-38j6</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;candles = [4,4,1,3]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The maximum height candles are 4 units high. There are 2 of them, so return 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function Description&lt;/strong&gt;&lt;br&gt;
Complete the function birthdayCakeCandles in the editor below.&lt;/p&gt;

&lt;p&gt;birthdayCakeCandles has the following parameter(s):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;int candles[n]: the candle heights&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Returns&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;int: the number of candles that are tallest&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first line contains a single integer, n, the size of candles[].&lt;/p&gt;

&lt;p&gt;The second line contains n space-separated integers, where each integer i describes the height of candles[i].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;1 &amp;lt;= n &amp;lt;= 10^5&lt;br&gt;
1 &amp;lt;= candles[i] &amp;lt;= 10^7&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Solution (How i solved it)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$mostFreq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$maxFreq&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="nv"&gt;$size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$candles&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_count_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$candles&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="nv"&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="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;$size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nv"&gt;$countFreq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&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="nv"&gt;$j&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="nv"&gt;$j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;$size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$j&lt;/span&gt;&lt;span class="o"&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;$candles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nv"&gt;$candles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$j&lt;/span&gt;&lt;span class="p"&gt;]){&lt;/span&gt;
            &lt;span class="nv"&gt;$countFreq&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="nv"&gt;$maxFreq&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;$countFreq&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="nv"&gt;$maxFreq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$countFreq&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nv"&gt;$mostFreq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$candles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&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;$maxFreq&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nv"&gt;$countFreq&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="nv"&gt;$mostFreq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$mostFreq&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$candles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&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;array_count_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$candles&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nv"&gt;$mostFreq&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;Link to the HackerRank: &lt;a href="https://www.hackerrank.com/challenges/birthday-cake-candles/problem"&gt;Birthday Cake Candles&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>algorithms</category>
      <category>hackerrank</category>
      <category>hackathon</category>
    </item>
    <item>
      <title>HackerRank: Mini-Max Sum Solution using PHP (Algorithm)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Sun, 16 Apr 2023 13:50:18 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-mini-max-sum-solution-using-php-algorithm-2hd6</link>
      <guid>https://dev.to/homezonic/hackerrank-mini-max-sum-solution-using-php-algorithm-2hd6</guid>
      <description>&lt;h2&gt;
  
  
  Problem Description
&lt;/h2&gt;

&lt;p&gt;In this HackerRank Mini-Max Sum problem solution Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;arr = [1,3,5,7,9]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The minimum sum is 1+3+5+7 = 16 and the maximum sum is 3+5+7+9 = 24. The function prints&lt;/p&gt;

&lt;p&gt;&lt;code&gt;16 24&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function Description&lt;/strong&gt;&lt;br&gt;
Complete the miniMaxSum function in the editor below.&lt;/p&gt;

&lt;p&gt;miniMaxSum has the following parameter(s):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;arr: an array of  integers&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Print&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Print two space-separated integers on one line: the minimum sum and the maximum sum of 4 of 5 elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;br&gt;
A single line of five space-separated integers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;1 &amp;lt;= arr[i] &amp;lt;= 10^9&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Format&lt;/strong&gt;&lt;br&gt;
Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers. (The output can be greater than a 32 bit integer.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution ( My Way)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$minsum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;array_slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nv"&gt;$maxsum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;array_slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&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;$minsum&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$maxsum&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Link to the HackerRank: &lt;a href="https://www.hackerrank.com/challenges/mini-max-sum/problem"&gt;Mini-Max Sum&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>algorithms</category>
      <category>hackerrank</category>
      <category>hackathon</category>
    </item>
    <item>
      <title>HackerRank: Staircase Solution using PHP (Algorithm)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Sun, 16 Apr 2023 13:04:50 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-staircase-solution-using-php-algorithm-59gj</link>
      <guid>https://dev.to/homezonic/hackerrank-staircase-solution-using-php-algorithm-59gj</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;This is a staircase of size n=4:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     #
   ##
  ###
####
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its base and height are both equal to n. It is drawn using # symbols and spaces. The last line is not preceded by any spaces.&lt;/p&gt;

&lt;p&gt;Write a program that prints a staircase of size n.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function Description&lt;/strong&gt;&lt;br&gt;
Complete the staircase function in the editor below.&lt;/p&gt;

&lt;p&gt;staircase has the following parameter(s):&lt;/p&gt;

&lt;p&gt;int n: an integer&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Print&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Print a staircase as described above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;br&gt;
A single integer, n, denoting the size of the staircase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;0 &amp;lt; n &amp;lt;= 100&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Format&lt;/strong&gt;&lt;br&gt;
Print a staircase of size n using # symbols and spaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The last line must have 0 spaces in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution (Based on how i solved it)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;    &lt;span class="nv"&gt;$space&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"#"&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="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nv"&gt;$res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;str_repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$space&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;str_repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;$i&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;$res&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="kc"&gt;PHP_EOL&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;Link to the HackerRank: &lt;a href="https://www.hackerrank.com/challenges/staircase/problem"&gt;Staircase Problem&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hackerrank</category>
      <category>hackathon</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>HackerRank: Plus Minus solution using PHP (Algorithm)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Sat, 15 Apr 2023 23:18:06 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-plus-minus-using-php-algorithm-52l6</link>
      <guid>https://dev.to/homezonic/hackerrank-plus-minus-using-php-algorithm-52l6</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with  places after the decimal.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to  are acceptable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Function Description&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Complete the plusMinus function in the editor below.&lt;/p&gt;

&lt;p&gt;plusMinus has the following parameter(s):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int arr[n]: an array of integers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Print&lt;/strong&gt;&lt;br&gt;
Print the ratios of positive, negative and zero values in the array. Each value should be printed on a separate line with  digits after the decimal. The function should not return a value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;br&gt;
The first line contains an integer, n, the size of the array.&lt;br&gt;
The second line contains n space-separated integers that describe arr[n].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Format&lt;/strong&gt;&lt;br&gt;
Print the following  lines, each to  decimals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;proportion of positive values&lt;/li&gt;
&lt;li&gt;proportion of negative values&lt;/li&gt;
&lt;li&gt;proportion of zeros&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution (How i solved it)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Take three variables named "positive", "negative" and "neutral. Store initial value as zero(0).&lt;/li&gt;
&lt;li&gt;Iterate a for loop through the given array.&lt;/li&gt;
&lt;li&gt;While iterating the array we have to add to either the positive, negative and neutral values.&lt;/li&gt;
&lt;li&gt;Calculate the ratios by dividing with the array length.&lt;/li&gt;
&lt;li&gt;Print the results.
Here is a tricky part, The instruction says, print each result on new line, if you are using echo or print function, it wont go to new line, so my solution is to use PHP_EOF.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$postive = 0;
    $negative = 0;
    $neutral = 0;
    $arrsize  = sizeof($arr);
    for ($i = 0; $i &amp;lt; $arrsize; $i++){
        if ($arr[$i] &amp;gt; 0){
            $positive++;
        }else if ($arr[$i] &amp;lt; 0){
            $negative++;
        }else if ($arr[$i] === 0){
            $neutral++;
        }
    }
$pos_res = number_format($positive / $arrsize, $arrsize);
$neg_res = number_format($negative/ $arrsize, $arrsize);
$neu_res = number_format($neutral / $arrsize, $arrsize);

echo $pos_res . PHP_EOL;
echo $neg_res . PHP_EOL;
echo $neu_res. PHP_EOL;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Link to the HackerRank: &lt;a href="https://www.hackerrank.com/challenges/plus-minus/problem"&gt;Plus Minus Test&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hackathon</category>
      <category>hackerrank</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
    <item>
      <title>HackerRank: Diagonal Difference Solution using PHP (Algorithm)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Fri, 14 Apr 2023 23:35:26 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-diagonal-difference-solution-using-php-algorithm-3en0</link>
      <guid>https://dev.to/homezonic/hackerrank-diagonal-difference-solution-using-php-algorithm-3en0</guid>
      <description>&lt;h2&gt;
  
  
  Diagonal Difference Solution
&lt;/h2&gt;

&lt;p&gt;Given a square matrix, calculate the absolute difference between the sums of its diagonals.&lt;br&gt;
For example, the square matrix is shown below:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;1 2 3&lt;br&gt;
4 5 6&lt;br&gt;
9 8 9&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The left-to-right diagonal =1 + 5 + 9 = 15. The right to left diagonal = 3 + 5+ 9 = 17. Their absolute difference is &lt;strong&gt;|15–17| = 2.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function description&lt;/strong&gt;&lt;br&gt;
Complete the diagonalDifference function in the editor below. It must return an integer representing the absolute diagonal difference.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference takes the following parameter:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;arr: an array of integers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;br&gt;
The first line contains a single integer, n , the number of rows and columns in the matrix arr.&lt;/p&gt;

&lt;p&gt;Each of the next n lines describes a row, arr[i], and consists of n space-separated integers arr[i][j].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraints&lt;/strong&gt;&lt;br&gt;
. — 100 ≤ arr[i][j] ≤ 100&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Format&lt;/strong&gt;&lt;br&gt;
Print the absolute difference between the sums of the matrix’s two diagonals as a single integer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Input&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;11 2 4&lt;br&gt;
4 5 6&lt;br&gt;
10 8 -12&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Sample Output&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;15&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
The primary diagonal is:&lt;/p&gt;

&lt;p&gt;11&lt;br&gt;
  5&lt;br&gt;
   -12&lt;/p&gt;

&lt;p&gt;Sum across the primary diagonal: 11 + 5–12 = 4&lt;/p&gt;

&lt;p&gt;The secondary diagonal is:&lt;/p&gt;

&lt;p&gt;4&lt;br&gt;
  5&lt;br&gt;
10&lt;/p&gt;

&lt;p&gt;Sum across the secondary diagonal: 4 + 5 + 10 = 19&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Difference: |4 –19| = 15&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; |x| is the absolute value of x&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution (Base on how i solved it)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$first = 0;
$second = 0;
$n = sizeof($arr);
for ($i = 0; $i &amp;lt; $n; $i++){
for ($j = 0; $j &amp;lt; $n; $j++){
    if ($i === $j){
        $first += $arr[$i][$j];
    }
        if ($i + $j === $n - 1){
            $second += $arr[$i][$j];
        }
    }
}
return abs($first - $second);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>hackathon</category>
      <category>hackerrank</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
    <item>
      <title>HackerRank: A Very Big Sum problem solution in PHP (Algorithm)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Fri, 14 Apr 2023 11:31:19 +0000</pubDate>
      <link>https://dev.to/homezonic/hackerrank-a-very-big-sum-problem-solution-in-php-3ek4</link>
      <guid>https://dev.to/homezonic/hackerrank-a-very-big-sum-problem-solution-in-php-3ek4</guid>
      <description>&lt;h2&gt;
  
  
  A Very Big Sum
&lt;/h2&gt;

&lt;p&gt;In this &lt;strong&gt;HackerRank&lt;/strong&gt; &lt;strong&gt;A Very Big Sum problem solution&lt;/strong&gt; In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Description
&lt;/h2&gt;

&lt;p&gt;Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements.&lt;/p&gt;

&lt;p&gt;aVeryBigSum has the following parameter(s):&lt;br&gt;
int ar[n]: an array of integers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;long: the sum of all array elements&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first line of the input consists of an integer n.&lt;/p&gt;

&lt;p&gt;The next line contains n space-separated integers contained in the array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return the integer sum of the elements in the array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution (Base on how i solved it)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$bigNum = 0; //variable to hold results
  $myarr = sizeof($ar); //counted how many field i have in the given array
  for($i = 0; $i &amp;lt; $myarr; $i++){ //loop through the given array
     $bigNum += $ar[$i]; //add each field to my result variable
  }
  return $bigNum; //here is my result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Link to HackerRank: &lt;a href="https://www.hackerrank.com/challenges/a-very-big-sum/problem"&gt;A Big Sum Problem Test&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hackerrank</category>
      <category>algorithms</category>
      <category>hackathon</category>
      <category>programming</category>
    </item>
    <item>
      <title>Differences between Nextjs and Nuxtjs (Summary)</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Mon, 03 Apr 2023 11:42:40 +0000</pubDate>
      <link>https://dev.to/homezonic/differences-between-nextjs-and-nuxtjs-summary-18la</link>
      <guid>https://dev.to/homezonic/differences-between-nextjs-and-nuxtjs-summary-18la</guid>
      <description>&lt;p&gt;&lt;strong&gt;Next.js&lt;/strong&gt; and &lt;strong&gt;Nuxt.js&lt;/strong&gt; are two popular server-side rendering (SSR) frameworks for building web applications with React and Vue respectively. Although they share similarities in their features, there are also notable differences between the two. &lt;br&gt;
Here are some of the main differences between &lt;strong&gt;Next.js&lt;/strong&gt; and &lt;strong&gt;Nuxt.js&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Language:&lt;/strong&gt; Next.js is based on React and is written in JavaScript, while Nuxt.js is based on Vue and is written in both JavaScript and TypeScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Routing:&lt;/strong&gt; Next.js uses file-based routing, where each file in the pages directory represents a route. Nuxt.js, on the other hand, uses a file-based routing system, where each file in the pages directory represents a route. However, Nuxt.js also allows for nested routes using folders in the pages directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-side rendering:&lt;/strong&gt; Both Next.js and Nuxt.js support server-side rendering, which enables faster page loads and better SEO. However, Next.js offers more customization options for server-side rendering, including the ability to customize the server-side rendering process for each page. Nuxt.js provides a simpler server-side rendering setup by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plugins and modules:&lt;/strong&gt; Next.js has a large library of plugins and modules available through npm that can be easily integrated into a project. Nuxt.js also has a similar system of modules that can be easily added to a project, but they are specific to Nuxt.js and not interchangeable with other frameworks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Development experience:&lt;/strong&gt; Next.js provides a highly customizable development experience, with tools like hot reloading and automatic code splitting. Nuxt.js provides a more opinionated development experience, with features like automatic page prefetching and code splitting out of the box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Community and ecosystem:&lt;/strong&gt; Next.js has a larger community and ecosystem due to its popularity and maturity, which means there are more resources, tutorials, and plugins available. Nuxt.js is also growing in popularity and has a strong community, but it is not as established as Next.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In summary&lt;/strong&gt;, Next.js and Nuxt.js are both excellent choices for building SSR web applications, and the choice between the two depends on the specific needs of a project and the development team's preferences. If you are familiar with React and prefer a more customizable development experience, then Next.js might be the better choice. If you are familiar with Vue and prefer a more opinionated development experience, then Nuxt.js might be the better choice.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>nuxt</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Git: 20 basic commands to know as a developer</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Mon, 03 Apr 2023 00:02:11 +0000</pubDate>
      <link>https://dev.to/homezonic/git-20-basic-commands-to-know-as-a-developer-4gbh</link>
      <guid>https://dev.to/homezonic/git-20-basic-commands-to-know-as-a-developer-4gbh</guid>
      <description>&lt;h2&gt;
  
  
  What is Git?
&lt;/h2&gt;

&lt;p&gt;Git is a free and open-source distributed version control system designed to help developers manage changes to their code over time. It was created by Linus Torvalds, the creator of the Linux operating system, and first released in 2005.&lt;/p&gt;

&lt;p&gt;With Git, developers can track changes to their codebase, collaborate with others, and revert to previous versions of their code if necessary. Git stores all code changes in a repository, which can be hosted locally on a developer's machine or remotely on a server.&lt;/p&gt;

&lt;p&gt;One of the key benefits of Git is that it allows developers to work independently on their own copies of the code, making it easier to manage complex projects with multiple contributors. Git also makes it easy to merge changes from different contributors into a single, unified codebase.&lt;/p&gt;

&lt;p&gt;Git is widely used by developers across many industries and is supported by a large and active community of contributors. Many popular code hosting platforms, such as GitHub and Bitbucket, use Git as their underlying version control system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components of Git
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Working directory: *&lt;/em&gt;&lt;br&gt;
This is the directory on your local machine where you store your project files. You can modify files in this directory using your favorite text editor or IDE.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Staging area:&lt;/strong&gt;&lt;br&gt;
Also known as the "index", this is an intermediate step between your working directory and your Git repository. When you make changes to your files in the working directory, you can use the &lt;code&gt;git add&lt;/code&gt; command to stage those changes. Once changes are staged, they are ready to be committed to the repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repository:&lt;/strong&gt;&lt;br&gt;
This is where Git stores all of the versions of your project files. The repository is typically hosted on a server, but can also be stored locally on your machine. When you use the &lt;code&gt;git commit&lt;/code&gt; command, Git takes a snapshot of the files in the staging area and stores them in the repository. Git also records metadata about the commit, such as the author, date, and commit message.&lt;/p&gt;

&lt;p&gt;These three components work together to allow you to track changes to your project files over time, collaborate with others, and revert to previous versions of your code if necessary. &lt;/p&gt;

&lt;p&gt;Below are the &lt;strong&gt;20 basic commands&lt;/strong&gt; all developers should familiarize themselves with before starting to work with Git.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. git init:&lt;/strong&gt;  Initializes a new Git repository in your current directory.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Initialized empty Git repository in /Users/username/project/.git/&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. git add:&lt;/strong&gt; Adds changes made to files in the current directory to the staging area, preparing them to be committed.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. git commit:&lt;/strong&gt; Commits changes in the staging area to the local repository, along with a message describing the changes made.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "Added a new feature"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. git status:&lt;/strong&gt; Displays the current state of the repository, including which files have been modified, which files are in the staging area, and which files are not being tracked.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Response will be like &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On branch master&lt;br&gt;
Changes not staged for commit:&lt;br&gt;
  (use "git add ..." to update what will be committed)&lt;br&gt;
  (use "git restore ..." to discard changes in working directory)&lt;br&gt;
  modified:   myfile.txt&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;5. git log:&lt;/strong&gt; Displays a log of all previous commits made to the repository, including the commit message, author, and timestamp.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Response&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;commit 1234abcd5678efgh&lt;br&gt;
Author: John Smith &lt;a href="mailto:john@example.com"&gt;john@example.com&lt;/a&gt;&lt;br&gt;
Date:   Mon Jan 1 12:00:00 2023 -0500&lt;br&gt;
    Added a new feature&lt;br&gt;
commit 5678efgh1234abcd&lt;br&gt;
Author: Jane Doe &lt;a href="mailto:jane@example.com"&gt;jane@example.com&lt;/a&gt;&lt;br&gt;
Date:   Sun Dec 31 23:59:59 2022 -0500&lt;br&gt;
    Initial commit&lt;br&gt;
&lt;strong&gt;6. git pull:&lt;/strong&gt; Fetches and merges changes from a remote repository into the local repository.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. git push:&lt;/strong&gt; Pushes local changes to a remote repository, making them available for others to access.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. git branch:&lt;/strong&gt; Lists all branches in the repository, or creates a new branch.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;master&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;feature-branch&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;9. git checkout:&lt;/strong&gt; Switches to a different branch, or checks out a specific commit.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout feature-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;10. git merge:&lt;/strong&gt; Merges changes from one branch into another.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git merge feature-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;11. git clone:&lt;/strong&gt; Creates a local copy of a remote repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/username/repository.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;12. git diff:&lt;/strong&gt; Shows the differences between the working directory, staging area, and repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git diff myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;13. git reset:&lt;/strong&gt; Unstages changes from the staging area.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;14. git revert:&lt;/strong&gt; Reverts a previous commit, creating a new commit that undoes the changes made.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git revert 1234abcd5678efgh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;15. git rm:&lt;/strong&gt; Removes a file from the repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rm myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;16. git remote:&lt;/strong&gt; Shows a list of remote repositories, or adds a new remote repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Response:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;origin  &lt;a href="https://github.com/username/repository.git"&gt;https://github.com/username/repository.git&lt;/a&gt; (fetch)&lt;br&gt;
origin  &lt;a href="https://github.com/username/repository.git"&gt;https://github.com/username/repository.git&lt;/a&gt; (push)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;17. git fetch:&lt;/strong&gt; Fetches changes from a remote repository, but does not merge them into the local repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch origin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;18. git tag:&lt;/strong&gt; Creates a new tag for a specific commit, such as to mark a release.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git tag v1.0.0 1234abcd5678efgh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;19. git stash:&lt;/strong&gt; Temporarily saves changes made to the working directory, allowing you to switch branches or pull changes from a remote repository without committing the changes.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;20. git branch -d:&lt;/strong&gt; Deletes a branch in the local repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch -d feature-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This command deletes the feature-branch branch from the local repository. If the branch has not been merged into the current branch, Git will prevent you from deleting it. In that case, you can use the -D option instead of -d to force the branch to be deleted.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Keep in mind that when you delete a branch, any commits that were made only to that branch will also be deleted from the repository. So be sure to double-check which branch you're deleting before you run this command.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These are just a few basic Git commands with examples to get you started. As you become more familiar with Git, you'll likely use many more commands and options to manage your codebase.&lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

</description>
      <category>github</category>
      <category>devops</category>
      <category>git</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Why Should I Learn Laravel in 2023?</title>
      <dc:creator>Akande Joshua</dc:creator>
      <pubDate>Wed, 29 Mar 2023 23:01:22 +0000</pubDate>
      <link>https://dev.to/homezonic/why-should-i-learn-laravel-in-2023-part-1-mhc</link>
      <guid>https://dev.to/homezonic/why-should-i-learn-laravel-in-2023-part-1-mhc</guid>
      <description>&lt;h2&gt;
  
  
  What is Laravel
&lt;/h2&gt;

&lt;p&gt;Laravel is a free, open-source web application framework that developers use to build web applications quickly and easily. It provides a set of tools and libraries that simplify common tasks, such as database migrations, authentication, routing, and templating, making it easier to create robust, scalable web applications.&lt;/p&gt;

&lt;p&gt;In simple terms, Laravel helps developers to build web applications faster and more efficiently by providing a set of tools and libraries that make common tasks easier. It's like having a set of Lego blocks that you can use to build a complex structure quickly and easily, without having to start from scratch every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Learning Laravel
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Rapid Development&lt;/strong&gt;&lt;br&gt;
One of the main benefits of using Laravel is its ability to speed up web development. Laravel provides a wide range of pre-built functions and libraries that can help developers save time and effort while building complex web applications. With Laravel, developers can easily create authentication systems, routing systems, and database migrations, among other things.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Robust Features&lt;/strong&gt;&lt;br&gt;
Laravel comes with a wide range of powerful features that make it an ideal choice for building complex web applications. These features include an expressive ORM, easy-to-use routing, and built-in support for task scheduling, caching, and email sending, among others. With Laravel, developers can focus on building great web applications without worrying about the underlying infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strong Community Support&lt;/strong&gt;&lt;br&gt;
Laravel has a large and active community of developers who are constantly working to improve the framework and provide support to other developers. This means that developers can easily find answers to their questions, share their experiences, and get help with any issues they encounter while using Laravel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Laravel in a more understanding terms&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Easy to learn: Laravel is a beginner-friendly framework with an elegant and simple syntax, making it easier for developers to learn and understand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Saves time: Laravel provides a set of pre-built tools and libraries that simplify common web development tasks, reducing the amount of time and effort required to build web applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: Laravel's modular structure allows developers to easily add new features and scale their applications as needed, making it an ideal framework for both small and large-scale projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secure: Laravel comes with built-in security features such as password hashing and CSRF protection, making it more secure against common web attacks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Community support: Laravel has a large and active community of developers who contribute to its development, offer support and share knowledge, making it easier to find solutions to common problems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Versatile: Laravel can be used to build a wide range of web applications, from simple blogs to complex e-commerce sites, making it a versatile framework that can be used for different types of projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In simple terms, learning Laravel can make web development easier, faster, and more secure while offering a range of benefits for both small and large-scale projects.&lt;/p&gt;
&lt;h2&gt;
  
  
  Laravel Features
&lt;/h2&gt;

&lt;p&gt;Let's take a closer look at some of the key features of Laravel:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Routing&lt;/strong&gt;&lt;br&gt;
Laravel provides a powerful routing system that makes it easy to define application routes and handle HTTP requests. With Laravel's routing system, developers can define both basic and complex routes, add route parameters, and handle multiple HTTP verbs, among other things.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::get('/posts', 'PostController@index');
Route::post('/posts', 'PostController@store');
Route::get('/posts/{id}', 'PostController@show');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Migrations&lt;/strong&gt;&lt;br&gt;
Laravel provides a simple and easy-to-use migration system that makes it easy to manage database schema changes. With Laravel's migration system, developers can easily create, modify, and rollback database tables and fields, without having to write complex SQL queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:migration create_posts_table --create=posts
php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ORM&lt;/strong&gt;&lt;br&gt;
Laravel's ORM (Object-Relational Mapping) system provides a simple and elegant way to interact with databases. With Laravel's ORM, developers can easily create database models, query the database, and perform advanced database operations, without having to write complex SQL queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Post extends Model
{
    protected $fillable = ['title', 'body'];

    public function user()
    {
        return $this-&amp;gt;belongsTo(User::class);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;br&gt;
Laravel provides a simple and easy-to-use authentication system that makes it easy to implement user authentication and authorization. With Laravel's authentication system, developers can easily create login and registration forms, handle password reset requests, and manage user roles and permissions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;br&gt;
Laravel provides a robust testing system that makes it easy to write and run automated tests for web applications. With Laravel's testing system, developers can easily test application routes, database models, and other key components of their web applications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function testExample()
{
    $response = $this-&amp;gt;get('/');

    $response-&amp;gt;assertStatus(200);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Laravel's Ecosystem
&lt;/h2&gt;

&lt;p&gt;Apart from the framework itself, Laravel also has a rich ecosystem of tools and packages that can help developers build robust web applications quickly and easily. Here are some of the key components of Laravel's ecosystem:&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Nova
&lt;/h2&gt;

&lt;p&gt;Laravel Nova is a powerful administration panel for Laravel applications. It provides developers with a simple and easy-to-use interface for managing application data, users, and roles. With Laravel Nova, developers can easily create custom dashboards, reports, and data visualizations, among other things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Mix
&lt;/h2&gt;

&lt;p&gt;Laravel Mix is a powerful build tool for compiling assets, such as CSS, JavaScript, and images. With Laravel Mix, developers can easily compile, minify, and optimize their application assets, without having to worry about complex build configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Telescope
&lt;/h2&gt;

&lt;p&gt;Laravel Telescope is a powerful debugging and monitoring tool for Laravel applications. It provides developers with real-time insights into their application's performance, database queries, and other key metrics. With Laravel Telescope, developers can easily identify and fix performance issues, without having to rely on complex profiling tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Horizon
&lt;/h2&gt;

&lt;p&gt;Laravel Horizon is a powerful queue monitoring tool for Laravel applications. It provides developers with a simple and easy-to-use interface for managing application queues, jobs, and workers. With Laravel Horizon, developers can easily monitor and manage their application's background jobs, without having to rely on complex queue management tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future of Laravel
&lt;/h2&gt;

&lt;p&gt;Laravel has been around for over a decade and has continuously evolved to become one of the most popular web frameworks in the world. With its strong community support and dedicated development team, Laravel is expected to continue to grow and evolve in the coming years. In fact, Laravel 9 is expected to be released in 2023, which will bring new features and improvements to the framework.&lt;/p&gt;

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

&lt;p&gt;In conclusion, learning Laravel in 2023 can provide numerous benefits to web developers who are looking to improve their skills and build high-quality web applications. With its rapid development, robust features, and strong community support, Laravel is an ideal choice for building scalable and maintainable web applications. Additionally, Laravel's ecosystem of tools and packages, as well as its bright future, make it a great investment for web developers looking to stay ahead of the curve.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>laravel</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
