<?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: Shoaib Akbar</title>
    <description>The latest articles on Forem by Shoaib Akbar (@shoiabakbar).</description>
    <link>https://forem.com/shoiabakbar</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%2F332781%2Fc7a505a4-c75a-4751-9ee1-38c05b71b891.jpg</url>
      <title>Forem: Shoaib Akbar</title>
      <link>https://forem.com/shoiabakbar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shoiabakbar"/>
    <language>en</language>
    <item>
      <title>Filtering and Customizing Arrays in PHP: A Step-by-Step Guide</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Sun, 15 Oct 2023 11:47:36 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/filtering-and-customizing-arrays-in-php-a-step-by-step-guide-92l</link>
      <guid>https://forem.com/shoiabakbar/filtering-and-customizing-arrays-in-php-a-step-by-step-guide-92l</guid>
      <description>&lt;p&gt;We'll explore how to filter an array of books to display only those written by a specific author or by relaeseYear.&lt;/p&gt;

&lt;p&gt;Array I'll use in examples&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$books = [&lt;br&gt;
    [&lt;br&gt;
        'name' =&amp;gt; 'Do Androids Dream of Electric Sheep',&lt;br&gt;
        'author' =&amp;gt; 'Philip K. Dick',&lt;br&gt;
        'releaseYear' =&amp;gt; 1968,&lt;br&gt;
        'purchaseURL' =&amp;gt; 'http://example.com'&lt;br&gt;
    ],&lt;br&gt;
    [&lt;br&gt;
        'name' =&amp;gt; 'Project Hail Mary',&lt;br&gt;
        'author' =&amp;gt; 'Andy Weir',&lt;br&gt;
        'releaseYear' =&amp;gt; 2021,&lt;br&gt;
        'purchaseURL' =&amp;gt; 'http://example.com'&lt;br&gt;
    ],&lt;br&gt;
    [&lt;br&gt;
        'name' =&amp;gt; 'The Martian',&lt;br&gt;
        'author' =&amp;gt; 'Andy Weir',&lt;br&gt;
        'releaseYear' =&amp;gt; 2011,&lt;br&gt;
        'purchaseURL' =&amp;gt; 'http://example.com'&lt;br&gt;
    ]&lt;br&gt;
];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We'll start with a basic foreach loop.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;foreach($books as $book) {

    if($book['author'] === "Andy Weir") {
        echo "&amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt;". $book['name'] ."&amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;";
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating a Filter Function by Author and releaseYear&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function filterByAuthor($books) {

    $filteredBooks = [];

    foreach($books as $book){

        if($book['author'] === "Andy Weir") {
            $filteredBooks[] = $book; 
        }

    }

    return $filteredBooks;

}

function filterByReleaseYear($books) {

    $filteredBooks = [];

    foreach($books as $book){

        if($book['releaseYear'] === 2011) {
            $filteredBooks[] = $book; 
        }

    }

    return $filteredBooks;

}

?&amp;gt;

    &amp;lt;ul&amp;gt;

        &amp;lt;?php 

            foreach(filterByAuthor($books) as $book) {

                echo "&amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt;". $book['name'] ."&amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;";

            }

        ?&amp;gt;

    &amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating a Generalized Filter Function to add more flexibility&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function filter($items, $key, $value) {

    $filteredItems = [];

    foreach($items as $item){

        if($item[$key] === $value) {
            $filteredItems[] = $item; 
        }

    }

    return $filteredItems;

}

$filterByAuthor = filter($books, 'author', 'Andy Weir');
$filteredByReleaseYear = filter($books, 'releaseYear', 2011);

?&amp;gt;

    &amp;lt;ul&amp;gt;

        &amp;lt;?php 

            foreach($filterByAuthor as $book) {

                echo "&amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt;". $book['name'] ."&amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;";

            }

        ?&amp;gt;

    &amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using Anonymous Functions for Filtering to add even more flexibility to the conditional statement&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function filter($items, $fn) {

    $filteredItems = [];

    foreach($items as $item){

        if($fn($item)) {
            $filteredItems[] = $item; 
        }

    }

    return $filteredItems;

}

$filterByAuthor = filter($books, function($book){

    return $book['author'] === 'Andy Weir';

});

$filteredByReleaseYear = filter($books, function($book){
    return $book['releaseYear'] &amp;gt;= 2000;
});

?&amp;gt;

    &amp;lt;ul&amp;gt;

        &amp;lt;?php foreach($filterByAuthor as $book) : ?&amp;gt;

                &amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt; &amp;lt;?= $book['name']; ?&amp;gt; &amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;

            &amp;lt;?php endforeach; ?&amp;gt;

    &amp;lt;/ul&amp;gt;    

    &amp;lt;ul&amp;gt;

        &amp;lt;?php foreach($filteredByReleaseYear as $book) : ?&amp;gt;

                &amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt; &amp;lt;?= $book['name']; ?&amp;gt; &amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;

            &amp;lt;?php endforeach; ?&amp;gt;

    &amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP build-in array_filter() solves this exactly!&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$filterByAuthor = array_filter($books, function($book){

    return $book['author'] === 'Andy Weir';

});

$filteredByReleaseYear = array_filter($books, function($book){
    return $book['releaseYear'] &amp;gt;= 1950;
});

?&amp;gt;

    &amp;lt;ul&amp;gt;

        &amp;lt;?php foreach($filterByAuthor as $book) : ?&amp;gt;

                &amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt; &amp;lt;?= $book['name']; ?&amp;gt; &amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;

            &amp;lt;?php endforeach; ?&amp;gt;

    &amp;lt;/ul&amp;gt;    

    &amp;lt;ul&amp;gt;

        &amp;lt;?php foreach($filteredByReleaseYear as $book) : ?&amp;gt;

                &amp;lt;a href='#'&amp;gt;&amp;lt;li&amp;gt; &amp;lt;?= $book['name']; ?&amp;gt; &amp;lt;/li&amp;gt;&amp;lt;/a&amp;gt;

            &amp;lt;?php endforeach; ?&amp;gt;

    &amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>learning</category>
    </item>
    <item>
      <title>How I Remove Productivity Blockers ?</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Thu, 03 Sep 2020 06:51:26 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/how-i-remove-productivity-blockers-1fki</link>
      <guid>https://forem.com/shoiabakbar/how-i-remove-productivity-blockers-1fki</guid>
      <description>&lt;p&gt;Hello everyone,&lt;br&gt;
I am hustling for consistent productivity. I used many techniques and got magical results but I found 2 main blockers which are related to each other, Today I am looking for suggestions and techniques to resolve them. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blocker 1:&lt;/strong&gt;&lt;br&gt;
I do plan for daily tasks, split into small tasks, add todo time for each small task and I got done 90% of work according to plan. And then I leave them incomplete. I noted sometime I waste same/double time to finish that 10% remaining stuff.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blocker 2:&lt;/strong&gt;&lt;br&gt;
After 2 months of work from home, I felt, I started making delay in actions, I wait for actions. And someday I successfully waste either first-half or second-half of day without doing anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; It's not in everyday routine. It's a few days in a month.&lt;/p&gt;

&lt;p&gt;I talked with my friends. They tried to convinced me it's story of everyone. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do you say ?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>productivity</category>
      <category>career</category>
      <category>learning</category>
    </item>
    <item>
      <title>Writing Functions (Uncle Bob's principles)</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Tue, 07 Jul 2020 05:58:32 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/writing-functions-uncle-bob-s-principal-3nd9</link>
      <guid>https://forem.com/shoiabakbar/writing-functions-uncle-bob-s-principal-3nd9</guid>
      <description>&lt;p&gt;Some principles to write functions from &lt;strong&gt;Clean Code&lt;/strong&gt; &lt;em&gt;book&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first rule of functions is that they should be small.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second rule of functions is that they should be smaller &lt;br&gt;
than that (upto 20 lines of code)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;FUNCTIONS SHOULD DO ONE THING&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Function Arguments&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Better if no argument&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Functions should have maximum of 2 arguments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But arguments should not be exceeded by 3 &lt;br&gt;
  (They take a lot of conceptual power)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It should has same level of abstraction &lt;br&gt;
  (1 level of abstraction)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Passing a boolean into a function is a truly terrible &lt;br&gt;
practice. (Flag as argument)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep Learning!!&lt;/p&gt;

</description>
      <category>books</category>
      <category>codenewbie</category>
      <category>php</category>
    </item>
    <item>
      <title>What I learnt in one year of my code review</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Sat, 13 Jun 2020 11:25:53 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/what-i-learnt-in-one-year-of-my-code-review-3of3</link>
      <guid>https://forem.com/shoiabakbar/what-i-learnt-in-one-year-of-my-code-review-3of3</guid>
      <description>&lt;p&gt;In first few months I got much comments on my code after code review. Later on I started building that mindset. It help me a lot,&lt;/p&gt;

&lt;p&gt;Let me share with you few techniques&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Mindset (start building that mindset).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Exceptions handling, read error messages, log errors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try test your core logic, all possible ways (write multiple inputs, don't test your code on same input again and again). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Figure out break points. And print messages on all breakpoints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Believe that you are human and you have made errors. start finding out them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start testing your code at the beginning(line by line).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also Take break, have some coffee and let your logic run in background of your mind, and then get back.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In all this you need a lot of patience.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep Learning!!&lt;/p&gt;

</description>
      <category>testing</category>
      <category>codequality</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Due to Coronovirus (COVID19) TCP applications are being converted to UDP to avoid Handshakes..!!</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Thu, 12 Mar 2020 16:19:36 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/due-to-coronovirus-covid19-tcp-applications-are-being-converted-to-udp-to-avoid-handshakes-1bpj</link>
      <guid>https://forem.com/shoiabakbar/due-to-coronovirus-covid19-tcp-applications-are-being-converted-to-udp-to-avoid-handshakes-1bpj</guid>
      <description>&lt;p&gt;Due to Coronovirus (COVID19) applications are being converted to UDP to avoid Handshakes..!! This kind of jokes we are reading on social media.&lt;/p&gt;

&lt;p&gt;Let's try to understand it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coronovirus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How anyone can be effected with this virus ???? Simply by accepting it from others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How TCP Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TCP is how most of the web works. It's a web page like &lt;em&gt;blog page&lt;/em&gt; sending and receiving data. It's 2 way protocol, there's handshake involved.&lt;br&gt;
You request for data and that request is recognized and you get back data package.&lt;br&gt;
So it's 2 way communication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How UDP Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;UDP is opposite of TCP. It's like there's stream of data you are accepting without recognizing like live streaming. You are just accepting accepting accepting......&lt;/p&gt;

&lt;p&gt;This is how it relates with Coronovirus.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>news</category>
      <category>jokes</category>
    </item>
    <item>
      <title>What's New In Codeigniter4 Installation</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Wed, 11 Mar 2020 09:19:00 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/what-s-new-in-codeigniter4-installation-26k2</link>
      <guid>https://forem.com/shoiabakbar/what-s-new-in-codeigniter4-installation-26k2</guid>
      <description>&lt;p&gt;Codeigniter4 is rewrite of framework and has lot of differences compared to previous version. Lets see what's new in codeigniter4 installation instructions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Codeigniter3 Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Codeigniter3 offers only &lt;a href="https://codeigniter.com/user_guide/installation/index.html"&gt;Manual Installation&lt;/a&gt; in 4 steps.&lt;/p&gt;

&lt;p&gt;1.Download and unzip package&lt;br&gt;
2.Upload CI folder and files on server&lt;br&gt;
3.In &lt;em&gt;application/config/config.php&lt;/em&gt; file set base URL.&lt;br&gt;
4.For database use, set settings in &lt;em&gt;application/config/database.php&lt;/em&gt; file. If you want to use encryption or sessions, set encryption key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Codeigniter4 Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Codeigniter4 offers 3 ways of installations.&lt;/p&gt;

&lt;p&gt;1.Manually Installation&lt;br&gt;
2.&lt;a href="https://codeigniter4.github.io/userguide/installation/installing_composer.html"&gt;Composer Installation&lt;/a&gt;&lt;br&gt;
3.&lt;a href="https://codeigniter4.github.io/userguide/installation/installing_git.html"&gt;Git Installation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'll write in detail about composer and git installations in coming posts.&lt;/p&gt;

&lt;p&gt;Keep Learning!!&lt;/p&gt;

</description>
      <category>codeigniter</category>
      <category>php</category>
      <category>programming</category>
    </item>
    <item>
      <title>Codeigniter4 Requirements</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Tue, 10 Mar 2020 13:19:20 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/codeigniter4-requirements-4a9m</link>
      <guid>https://forem.com/shoiabakbar/codeigniter4-requirements-4a9m</guid>
      <description>&lt;p&gt;&lt;a href="https://codeigniter4.github.io/userguide/index.html"&gt;Codeigniter4&lt;/a&gt; is officially launched with major changes on 24.02.2020&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Codeigniter4 Server Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Codeigniter now requires &lt;a href="https://www.php.net/releases/7_2_0.php"&gt;PHP 7.2 &lt;/a&gt;or newer version&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extensions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Codeigniter4 requires &lt;em&gt;php-json&lt;/em&gt;, &lt;em&gt;php-mbstring&lt;/em&gt;, &lt;em&gt;php-mysqlnd&lt;/em&gt;, &lt;em&gt;php-xml&lt;/em&gt; extensions installed on server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Libraries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To use &lt;a href="https://codeigniter4.github.io/userguide/libraries/curlrequest.html"&gt;CURLRequest&lt;/a&gt;, &lt;a href="https://www.php.net/manual/en/curl.requirements.php"&gt;libcurl&lt;/a&gt; should be installed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/shoiabakbar/status/1237362396739624961"&gt;Read more posts on&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codeigniter</category>
      <category>php</category>
      <category>programming</category>
    </item>
    <item>
      <title>One Difference Between Smart and Professional Programmer</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Mon, 24 Feb 2020 12:10:29 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/one-difference-between-smart-and-professional-programmer-17j9</link>
      <guid>https://forem.com/shoiabakbar/one-difference-between-smart-and-professional-programmer-17j9</guid>
      <description>&lt;p&gt;&lt;em&gt;Programmers are pretty smart people.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Smart Programmer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Smart people sometimes like to show off their smarts by demonstrating their mental juggling abilities.&lt;br&gt;
if you can reliably remember you can write similar code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;for (int j=0; j&amp;lt;34; j++) {&lt;br&gt;
    s += (t[j]*4)/5;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professional Programmer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A professional programmer understands that &lt;em&gt;clarity is king&lt;/em&gt;. Professionals use their powers for good and write code that others can understand.&lt;br&gt;
&lt;code&gt;&lt;br&gt;
int realDaysPerIdealDay = 4;&lt;br&gt;
const int WORK_DAYS_PER_WEEK = 5;&lt;br&gt;
int sum = 0;&lt;br&gt;
for (int j=0; j &amp;lt; NUMBER_OF_TASKS; j++) {&lt;br&gt;
          int realTaskDays = taskEstimate[j] * realDaysPerIdealDay;&lt;br&gt;
          int realTaskWeeks = (realdays / WORK_DAYS_PER_WEEK);&lt;br&gt;
          sum += realTaskWeeks;&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Write readable and understandable code.&lt;/p&gt;

&lt;p&gt;i couldn't add indentation, if you know please write in comment.&lt;/p&gt;

&lt;p&gt;Keep Learning!&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>programming</category>
      <category>developer</category>
      <category>coding</category>
    </item>
    <item>
      <title>Setup vagrant on Linux/Ubuntu</title>
      <dc:creator>Shoaib Akbar</dc:creator>
      <pubDate>Sun, 23 Feb 2020 02:26:44 +0000</pubDate>
      <link>https://forem.com/shoiabakbar/setup-vagrant-on-linux-ubuntu-4ng</link>
      <guid>https://forem.com/shoiabakbar/setup-vagrant-on-linux-ubuntu-4ng</guid>
      <description>&lt;p&gt;A complete guide to setup vagrant on Ubuntu 18.04&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install VirtualBox&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start by importing GPG keys of the Oracle Virtualbox repository:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -&lt;/code&gt;
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Both commands should output OK which means that keys are successfully imported and packages from this repository are trusted.&lt;/p&gt;

&lt;p&gt;Next add virtual box APT repository:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;$(lsb_release -cs) will print the Ubuntu codename. For example, if you have Ubuntu version 18.04 the command will print bionic.&lt;/p&gt;

&lt;p&gt;If you get an error message saying add-apt-repository command not found then you need to install the software-properties-common package.&lt;/p&gt;

&lt;p&gt;Once the Virtualbox repository is enabled, update the apt package list and install the latest version of Virtualbox:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;sudo apt update&lt;/code&gt;
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;sudo apt install virtualbox-6.0&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Now Virtualbox is installed on your Ubuntu system, start:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;virtualbox&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;&lt;strong&gt;Installing Vagrant&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;update package list:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;sudo apt update&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Download the Vagrant package:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;curl -O https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.deb&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;br&gt;
if curl is not installed :&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;sudo apt install curl&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Now try to download the Vagrant package again&lt;/p&gt;

&lt;p&gt;Once the .deb file is downloaded, install it:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;sudo apt install ./vagrant_2.2.6_x86_64.deb&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Verify Vagrant installation:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant --version&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;The output should be similar to&lt;/p&gt;

&lt;h6&gt;
  
  
  Vagrant 2.2.6
&lt;/h6&gt;

&lt;p&gt;&lt;strong&gt;Getting Started with Vagrant&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Vagrant is installed on your Ubuntu system let's create a development environment.&lt;br&gt;
The first step is to create root directory for project which will contain Vagrantfile file. Vagrantfile is a Ruby file that contain configurations and provision the virtual machine.&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;mkdir ~/my-first-vagrant-project&lt;/code&gt;
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;cd ~/my-first-vagrant-project&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Next initialize a new Vagrantfile (will create vagrant file):&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant init&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;and specify the box you want to use.&lt;/p&gt;

&lt;p&gt;(You can search other boxes on this link &lt;a href="https://app.vagrantup.com/boxes/search"&gt;https://app.vagrantup.com/boxes/search&lt;/a&gt; we’ll use ubuntu/trusty64)&lt;/p&gt;

&lt;h6&gt;
  
  
  'vagrant init ubuntu/trusty64`
&lt;/h6&gt;

&lt;p&gt;Now create and configure the virtual machine as specified in the Vagrantfile:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant up&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Next update changes in Vagrantfile:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant provision&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Next reload vagrant and virtual box:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant reload&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;To ssh into the virtual machine:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant ssh&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Can stop the virtual machine:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant halt&lt;/code&gt;
&lt;/h6&gt;

&lt;p&gt;Can destroys all resources(be careful):&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;vagrant destroy&lt;/code&gt;
&lt;/h6&gt;

&lt;h3&gt;
  
  
  Keep Learning!
&lt;/h3&gt;

</description>
      <category>vagrant</category>
      <category>linux</category>
      <category>ubuntu</category>
      <category>virtualbox</category>
    </item>
  </channel>
</rss>
