<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Az Codez]]></title><description><![CDATA[Software engineer focusing on PHP, JavaScript, HTML, CSS, CI/CD, GitHub, AWS, Azure &  Magento Commerce. I enjoy code for good projects, tech, gym, nature, trav]]></description><link>https://blog.azcodez.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1646075829608/PukrEa3XE.png</url><title>Az Codez</title><link>https://blog.azcodez.com</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 06:04:50 GMT</lastBuildDate><atom:link href="https://blog.azcodez.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Creating database tables and adding data in Magento 2 Adobe Commerce]]></title><description><![CDATA[Create a db schema

Reference https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/db-schema.html
Path will be a similar path to this
app\code\AzCodez\CustomerViewing\etc\db_schema.xml

Add this code to set up your table. Mo...]]></description><link>https://blog.azcodez.com/creating-database-tables-and-adding-data-in-magento-2-adobe-commerce</link><guid isPermaLink="true">https://blog.azcodez.com/creating-database-tables-and-adding-data-in-magento-2-adobe-commerce</guid><category><![CDATA[Magento]]></category><category><![CDATA[ecommerce]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Databases]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 06 Aug 2022 19:39:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/zbILyELGOtk/upload/v1659814703419/uio98MKP_-.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-create-a-db-schema">Create a db schema</h2>
<ul>
<li>Reference https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/db-schema.html</li>
<li><p>Path will be a similar path to this
app\code\AzCodez\CustomerViewing\etc\db_schema.xml</p>
</li>
<li><p>Add this code to set up your table. Modify table names, columns, types to suit your own</p>
<pre><code><span class="hljs-operator">&lt;</span>?xml version<span class="hljs-operator">=</span><span class="hljs-string">"1.0"</span>?<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">!</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span> Database schema <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>schema xmlns:xsi<span class="hljs-operator">=</span><span class="hljs-string">"http://www.w3.org/2001/XMLSchema-instance"</span> xsi:noNamespaceSchemaLocation<span class="hljs-operator">=</span><span class="hljs-string">"urn:magento:framework:Setup/Declaration/Schema/etc/schema. xsd"</span><span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span>table name<span class="hljs-operator">=</span><span class="hljs-string">"az_codez_followers"</span> resource<span class="hljs-operator">=</span><span class="hljs-string">"default"</span> engine<span class="hljs-operator">=</span><span class="hljs-string">"innodb"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Azcodez followers"</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>column xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"int"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"follower_id"</span> padding<span class="hljs-operator">=</span><span class="hljs-string">"19"</span> unsigned<span class="hljs-operator">=</span><span class="hljs-string">"true"</span> nullable<span class="hljs-operator">=</span><span class="hljs-string">"false"</span> identity<span class="hljs-operator">=</span><span class="hljs-string">"true"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Follower id"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>column xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"name"</span> nullable<span class="hljs-operator">=</span><span class="hljs-string">"false"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Follower Name"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>column xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"email"</span> nullable<span class="hljs-operator">=</span><span class="hljs-string">"false"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Follower Contact"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>constraint xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"primary"</span> referenceId<span class="hljs-operator">=</span><span class="hljs-string">"PRIMARY"</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>column name<span class="hljs-operator">=</span><span class="hljs-string">"follower_id"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>constraint<span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>table<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>schema<span class="hljs-operator">&gt;</span>
</code></pre></li>
</ul>
<h2 id="heading-generate-generate-dbschemawhitelistjson">Generate  generate db_schema_whitelist.json</h2>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command setup:db<span class="hljs-operator">-</span>declaration:generate<span class="hljs-operator">-</span>whitelist
</code></pre><h2 id="heading-redeploy">Redeploy</h2>
<h2 id="heading-find-your-table-and-see-if-it-worked-eg">Find your table and see if it worked eg.</h2>
<pre><code><span class="hljs-keyword">Select</span> * <span class="hljs-keyword">From</span> az_codez_followers;
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1646408394493/fzvAB2a3I.png" alt="image.png" /></p>
<h1 id="heading-updating-a-database">Updating a database</h1>
<ul>
<li>Following this reference https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/data-patches.html</li>
</ul>
<h1 id="heading-create-a-data-patch">Create a data patch</h1>
<ul>
<li>This file will run on deploy and modify table 
app\code\AzCodez\Databases\Setup\Patch\Data\NewColumn.php</li>
</ul>
<p>## 
 Add sample code from https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/data-patches.html and add what you want to do </p>
<ul>
<li>Here i will be creating a new table column with this patch</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>
<span class="hljs-comment">/**
 * Adds new column twitter_handle
 */</span>

<span class="hljs-keyword">namespace</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">Databases</span>\<span class="hljs-title">Setup</span>\<span class="hljs-title">Patch</span>\<span class="hljs-title">Data</span>;

<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">Setup</span>\<span class="hljs-title">ModuleDataSetupInterface</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">Setup</span>\<span class="hljs-title">Patch</span>\<span class="hljs-title">DataPatchInterface</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">Setup</span>\<span class="hljs-title">Patch</span>\<span class="hljs-title">PatchRevertableInterface</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">NewColumn</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">DataPatchInterface</span>, <span class="hljs-title">PatchRevertableInterface</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> ModuleDataSetupInterface
     */</span>
    <span class="hljs-keyword">private</span> $moduleDataSetup;

    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@param</span> ModuleDataSetupInterface $moduleDataSetup
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">__construct</span>(<span class="hljs-params">
        ModuleDataSetupInterface $moduleDataSetup
    </span>) </span>{
        <span class="hljs-comment">/**
         * If before, we pass $setup as argument in install/upgrade function, from now we start
         * inject it with DI. If you want to use setup, you can inject it, with the same way as here
         */</span>
        <span class="hljs-keyword">$this</span>-&gt;moduleDataSetup = $moduleDataSetup;
    }

    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@inheritdoc</span>
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">apply</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;moduleDataSetup-&gt;getConnection()-&gt;startSetup();
        <span class="hljs-comment">//The code that you want apply in the patch</span>
        <span class="hljs-comment">//Please note, that one patch is responsible only for one setup version</span>
        <span class="hljs-comment">//So one UpgradeData can consist of few data patches</span>
        <span class="hljs-keyword">$this</span>-&gt;moduleDataSetup-&gt;getConnection()-&gt;addColumn(<span class="hljs-string">'az_codez_followers'</span>, <span class="hljs-string">'twitter_handle'</span>,
            [
            <span class="hljs-string">'type'</span> =&gt; \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            <span class="hljs-string">'length'</span> =&gt; <span class="hljs-number">64</span>,
            <span class="hljs-string">'unsigned'</span> =&gt; <span class="hljs-literal">true</span>,
            <span class="hljs-string">'nullable'</span> =&gt; <span class="hljs-literal">false</span>,
            <span class="hljs-string">'comment'</span> =&gt; <span class="hljs-string">'twitter'</span>
            ]
        );

        <span class="hljs-keyword">$this</span>-&gt;moduleDataSetup-&gt;getConnection()-&gt;endSetup();
    }

    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@inheritdoc</span>
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-built_in">static</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getDependencies</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">/**
         * This is dependency to another patch. Dependency should be applied first
         * One patch can have few dependencies
         * Patches do not have versions, so if in old approach with Install/Ugrade data scripts you used
         * versions, right now you need to point from patch with higher version to patch with lower version
         * But please, note, that some of your patches can be independent and can be installed in any sequence
         * So use dependencies only if this important for you
         */</span>
        <span class="hljs-keyword">return</span> [
            SomeDependency::class
        ];
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">revert</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;moduleDataSetup-&gt;getConnection()-&gt;startSetup();
        <span class="hljs-comment">//Here should go code that will revert all operations from `apply` method</span>
        <span class="hljs-comment">//Please note, that some operations, like removing data from column, that is in role of foreign key reference</span>
        <span class="hljs-comment">//is dangerous, because it can trigger ON DELETE statement</span>
        <span class="hljs-keyword">$this</span>-&gt;moduleDataSetup-&gt;getConnection()-&gt;endSetup();
    }

    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@inheritdoc</span>
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getAliases</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">/**
         * This internal Magento method, that means that some patches with time can change their names,
         * but changing name should not affect installation process, that's why if we will change name of the patch
         * we will add alias here
         */</span>
        <span class="hljs-keyword">return</span> [];
    }
}
</code></pre><h2 id="heading-credits">Credits</h2>
<ul>
<li>https://devdocs.magento.com/</li>
<li>https://www.adobe.com/</li>
</ul>
<p>Feel free to comment questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div><div class="hn-embed-widget" id="openinnewtab"></div>]]></content:encoded></item><item><title><![CDATA[Automatically Tweet Hashnode blogs using GitHub Actions]]></title><description><![CDATA[This is how I post my Hashnode blogs to Twitter automatically by using GitHub Actions. You can see these tweets on my Twitter account. 
Costs

Github provides 2,000 minutes a month for free account which is plenty!
This GitHub action only uses 20s / ...]]></description><link>https://blog.azcodez.com/automatically-tweet-hashnode-blogs-using-github-actions</link><guid isPermaLink="true">https://blog.azcodez.com/automatically-tweet-hashnode-blogs-using-github-actions</guid><category><![CDATA[Blogging]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[Cloud Computing]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Mon, 01 Aug 2022 07:31:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636921514531/wqrlX-onp.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is how I post my Hashnode blogs to Twitter automatically by using GitHub Actions. You can see these tweets on <a target="_blank" href="https://twitter.com/az_codez">my Twitter account</a>. </p>
<h1 id="heading-costs">Costs</h1>
<ul>
<li><a target="_blank" href="https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions">Github provides 2,000 minutes a month</a> for free account which is plenty!</li>
<li>This GitHub action only uses 20s / 1 billable minute
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659189142209/6t5XAkee_.png" alt="image.png" /></li>
</ul>
<h1 id="heading-setup-hashnode-api">Setup Hashnode API</h1>
<ul>
<li><p>First, check out this awesome blog by Catalin about the <a target="_blank" href="https://catalins.tech/hashnode-api-how-to-display-your-blog-articles-on-your-portfolio-page">Hashnode API</a> and make sure you can call the API and your blogs</p>
</li>
<li><p>Load the Hashnode API playground https://api.hashnode.com/</p>
</li>
<li><p>Setup your  Hashnode API playground like so, including your own blog name if hasnode playground hasn't done it for you already</p>
<pre><code>{
<span class="hljs-keyword">user</span>(username: "&lt;ADD_YOUR_BLOG_USERNAME") {
  <span class="hljs-keyword">publication</span> {
    posts(page: <span class="hljs-number">0</span>) {
      title
      brief
      slug

    }
  }
}
}
</code></pre></li>
</ul>
<h1 id="heading-create-a-github-action">Create a GitHub Action</h1>
<ul>
<li><p><a target="_blank" href="https://blog.azcodez.com/twitter-tweet-bot-using-github-actions">Follow this my previous blog on how to tweet using GitHub actions</a></p>
</li>
<li><p>Add some more steps before the tweet step</p>
</li>
<li><p>Add fetching Hashnode API</p>
<pre><code>    # <span class="hljs-type">API</span> request https:<span class="hljs-comment">//github.com/marketplace/actions/http-request-action</span>
    - name: <span class="hljs-type">Deploy</span> <span class="hljs-type">Stage</span>
      id: myRequest
      uses: fjogeleit/http-request-action<span class="hljs-meta">@master</span>
      <span class="hljs-keyword">with</span>:
        url: <span class="hljs-symbol">'https</span>:<span class="hljs-comment">//api.hashnode.com/'</span>
        method: <span class="hljs-symbol">'POS</span>T'
        data: '{<span class="hljs-string">"query"</span>:<span class="hljs-string">"{\n  user(username: \"&lt;ADD_YOUR_USERNAME&gt;\") {\n    publication {\n      posts(page: 0) {\n        title\n        brief\n        slug\n      }\n    }\n  }\n}\n"</span>}'
        customHeaders: '{<span class="hljs-string">"headers"</span>: {<span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>}}'
</code></pre></li>
<li><p>Add another step to check your response</p>
<pre><code>    <span class="hljs-operator">-</span> name: Show Response
      run: echo ${{ steps.myRequest.outputs.response }}
</code></pre></li>
<li><p>Add a JavaScript executor to run some JavaScript to modify the query</p>
<pre><code># Sort Json array https:<span class="hljs-comment">//github.com/marketplace/actions/execute-javascript-inline</span>
    - name: Execute JavaScript inline
      id: quoteFiltered
      uses: satackey/action-js-inline<span class="hljs-meta">@v0</span><span class="hljs-number">.0</span><span class="hljs-number">.2</span>
      <span class="hljs-keyword">with</span>:
        # Edit the following line to install packages required to run your script.
        required-packages: axios
        script: |
          <span class="hljs-comment">//setup</span>
          <span class="hljs-keyword">const</span> core = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@actions/core'</span>)
          <span class="hljs-keyword">const</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">'axios'</span>)

          <span class="hljs-comment">//set output from other step            </span>
          <span class="hljs-keyword">const</span> quoteJson = ${{ steps.myRequest.outputs.response }}

          <span class="hljs-comment">//Filter what blog to receive </span>
          randomNumber = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">6</span>);            
          <span class="hljs-keyword">const</span> title = (<span class="hljs-built_in">String</span>(quoteJson[<span class="hljs-string">'data'</span>][<span class="hljs-string">'user'</span>][<span class="hljs-string">'publication'</span>][<span class="hljs-string">'posts'</span>][randomNumber][<span class="hljs-string">'title'</span>]));
          <span class="hljs-keyword">const</span> slug = (<span class="hljs-built_in">String</span>(quoteJson[<span class="hljs-string">'data'</span>][<span class="hljs-string">'user'</span>][<span class="hljs-string">'publication'</span>][<span class="hljs-string">'posts'</span>][randomNumber][<span class="hljs-string">'slug'</span>]));
          <span class="hljs-comment">//What tweet contents will be</span>
          <span class="hljs-keyword">const</span> finalQuote = (title+<span class="hljs-string">' '</span>+<span class="hljs-string">'https://blog.azcodez.com/'</span>+slug+<span class="hljs-string">'{ by @az_codez } from @hashnode #softwaredevelopment #coding #softwareengineering #programming #techblog'</span>) 

          <span class="hljs-built_in">console</span>.log(finalQuote)

          <span class="hljs-comment">//Output</span>
          core.setOutput(<span class="hljs-string">'finalQuote'</span>, finalQuote)
</code></pre></li>
<li><p>Make sure you run your GitHub action multiple times to check what you are going to tweet is correct and GitHub Action passes</p>
</li>
<li><p>Now add your tweet to Twitter step</p>
<pre><code><span class="hljs-comment"># Tweet to twitter https://github.com/marketplace/actions/tweet-to-twitter</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">TweetToTwitter</span>
      <span class="hljs-attr">uses:</span> <span class="hljs-string">InfraWay/tweet-action@v1.0.1</span>
      <span class="hljs-attr">with:</span>
        <span class="hljs-attr">status:</span> <span class="hljs-string">${{</span> <span class="hljs-string">steps.quoteFiltered.outputs.finalQuote</span> <span class="hljs-string">}}</span>
        <span class="hljs-attr">api_key:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.TWITTER_API_KEY</span> <span class="hljs-string">}}</span>
        <span class="hljs-attr">api_key_secret:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.TWITTER_API_SECRET_KEY</span> <span class="hljs-string">}}</span>
        <span class="hljs-attr">access_token:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.TWITTER_ACCESS_TOKEN</span> <span class="hljs-string">}}</span>
        <span class="hljs-attr">access_token_secret:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.TWITTER_ACCESS_TOKEN_SECRET</span> <span class="hljs-string">}}</span>
</code></pre></li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>Github Actions Image coletiv.com/blog/android-github-actions-setup</li>
<li>Twitter image https://www.nytimes.com/2014/08/10/magazine/who-made-that-twitter-bird.html</li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
<li><a target="_blank" href="https://coinbase.com/join/dayana_m40?src=android-link">Join coinbase with my and you will earn some free crypto as well</a></li>
</ul>
<p>Now you don't have to worry about reposing your blogs!</p>
<p>Hope this helps😁</p>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Setup GitHub SSH key using Windows]]></title><description><![CDATA[This is how I installed Git and authenticated with my GitHub repo using a ssh key using Windows OS
Download and install git

https://git-scm.com/

Create a folder for a git repo

Create a folder in your windows system
Open folder in git by right clic...]]></description><link>https://blog.azcodez.com/setup-github-ssh-key-using-windows</link><guid isPermaLink="true">https://blog.azcodez.com/setup-github-ssh-key-using-windows</guid><category><![CDATA[Windows]]></category><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 30 Jul 2022 13:27:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659187857185/AyLf4cHXb.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is how I installed Git and authenticated with my GitHub repo using a ssh key using Windows OS</p>
<h1 id="heading-download-and-install-git">Download and install git</h1>
<ul>
<li>https://git-scm.com/</li>
</ul>
<h1 id="heading-create-a-folder-for-a-git-repo">Create a folder for a git repo</h1>
<ul>
<li>Create a folder in your windows system</li>
<li>Open folder in git by right clicking and selecting git bash
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1649756146144/O4phMyjpq.png" alt="image.png" /></li>
</ul>
<h1 id="heading-create-a-ssh-key-open-ssh-type">Create a ssh key (Open ssh type)</h1>
<pre><code>ssh<span class="hljs-operator">-</span>keygen <span class="hljs-operator">-</span>t ed25519 <span class="hljs-operator">-</span>C <span class="hljs-string">"AddYourEmail@email.com"</span>
</code></pre><ul>
<li>Follow prompts and save to your .ssh folder</li>
<li>View and copy your public key you need to add this later<pre><code>nano <span class="hljs-operator">&lt;</span>YOUR_LOCATION_YOU_ADDED_ABOVE<span class="hljs-operator">&gt;</span><span class="hljs-operator">/</span>.ssh/github<span class="hljs-operator">-</span>key.pub
</code></pre></li>
</ul>
<h1 id="heading-go-to-your-github-security-settings">Go to your github security settings</h1>
<ul>
<li>https://github.com/settings/profile</li>
<li>Cick SSH and GPG keys</li>
<li>Click NewSSH key
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1649755581144/UEKGewbU7.png" alt="image.png" /></li>
<li>Add public key you copied before new SSH key and add add a Title</li>
<li>Add SSH key</li>
<li>You should have a success notification</li>
</ul>
<h1 id="heading-add-your-ssh-agent-connection-to-profile">Add your ssh-agent  connection to .profile</h1>
<ul>
<li>Open your git folder using git bash again</li>
<li>Create a .profile or edit it <pre><code>nano <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.profile
</code></pre></li>
<li>Add these contents. Remember to edit to set path to your ssh key!<pre><code><span class="hljs-meta">#! /bin/bash </span>
<span class="hljs-built_in">eval</span> `ssh-agent -s` 
ssh-add ~/.ssh/&lt;ADD_PATH_TO_SSH_KEY&gt;
</code></pre></li>
</ul>
<h1 id="heading-add-your-ssh-agent-connection-to-bashrc">Add your ssh-agent connection to .bashrc</h1>
<ul>
<li>You will need to add to bash as well. eg. I am using git terminal in Android studio so I will need to change bashrc</li>
<li>Create a .bashrc or edit it <pre><code>nano <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.bashrc
</code></pre></li>
<li>Add these contents. Remember to edit to set path to your ssh key!<pre><code><span class="hljs-meta">#! /bin/bash </span>
<span class="hljs-built_in">eval</span> `ssh-agent -s` 
ssh-add ~/.ssh/&lt;ADD_PATH_TO_SSH_KEY&gt;
</code></pre></li>
<li>Restart the app that you are using git cli</li>
<li>You should see something like <pre><code>Agent pid XXXX
<span class="hljs-keyword">Identity</span> added: xxxxxxxxx
</code></pre></li>
<li>Go to one of your repos and fetch remote repo by running<pre><code>git <span class="hljs-keyword">fetch</span>
</code></pre></li>
<li>This should fetch contents without asking for key or ssh agent</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>https://stackoverflow.com/questions/3669001/getting-ssh-agent-to-work-with-git-run-from-windows-command-shell/15870387#15870387</li>
<li>https://stackoverflow.com/questions/18404272/running-ssh-agent-when-starting-git-bash-on-windows</li>
<li>https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent</li>
<li><a target="_blank" href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent">Create ssh key</a></li>
<li><a target="_blank" href="https://github.blog/2018-06-04-github-microsoft/">Header Image</a></li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
<li><a target="_blank" href="https://coinbase.com/join/dayana_m40?src=android-link">Join coinbase with my and you will earn some free crypto as well</a></li>
</ul>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
]]></content:encoded></item><item><title><![CDATA[Installing the AWS EB CLI command on Debian 11 (WSL2)]]></title><description><![CDATA[In order to create docker containers in Amazon Web Services Elastic Beanstalk, you need the EB CLI command to run. I didn’t find the installation of this very straightforward forward so hopefully, this helps you.
Install python
sudo apt update 
sudo ...]]></description><link>https://blog.azcodez.com/installing-the-aws-eb-cli-command-on-debian-11-wsl2</link><guid isPermaLink="true">https://blog.azcodez.com/installing-the-aws-eb-cli-command-on-debian-11-wsl2</guid><category><![CDATA[AWS]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[Docker]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 02 Jul 2022 09:52:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1656755176994/swBS3pVj0.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In order to create docker containers in Amazon Web Services Elastic Beanstalk, you need the EB CLI command to run. I didn’t find the installation of this very straightforward forward so hopefully, this helps you.</p>
<h1 id="heading-install-python">Install python</h1>
<pre><code>sudo apt update 
sudo apt <span class="hljs-operator">-</span>y upgrade
sudo apt install wget build<span class="hljs-operator">-</span>essential libreadline<span class="hljs-operator">-</span>gplv2<span class="hljs-operator">-</span>dev libncursesw5<span class="hljs-operator">-</span>dev \ libssl<span class="hljs-operator">-</span>dev libsqlite3<span class="hljs-operator">-</span>dev tk<span class="hljs-operator">-</span>dev libgdbm<span class="hljs-operator">-</span>dev libc6<span class="hljs-operator">-</span>dev libbz2<span class="hljs-operator">-</span>dev libffi<span class="hljs-operator">-</span>dev zlib1g<span class="hljs-operator">-</span>dev
sudo apt <span class="hljs-operator">-</span>y install wget
wget https:<span class="hljs-comment">//www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz</span>
tar xzf Python<span class="hljs-number">-3.9</span><span class="hljs-number">.1</span>.tgz
python3<span class="hljs-number">.9</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>version
</code></pre><h2 id="heading-set-python-symlink-to-run-off-just-the-python-command">Set python symlink to run off just the python command</h2>
<pre><code>sudo ln <span class="hljs-operator">-</span>s <span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>python3<span class="hljs-number">.9</span> <span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>python
python <span class="hljs-operator">-</span><span class="hljs-operator">-</span>version
</code></pre><h1 id="heading-install-pip">Install pip</h1>
<pre><code>sudo apt<span class="hljs-operator">-</span>get <span class="hljs-operator">-</span>y install python3<span class="hljs-operator">-</span>pip
</code></pre><h1 id="heading-install-virtualenv">Install virtualenv</h1>
<pre><code>sudo pip <span class="hljs-keyword">install</span> virtualenv
virtualenv <span class="hljs-comment">--version</span>
</code></pre><h1 id="heading-install-git">Install git</h1>
<pre><code>sudo apt<span class="hljs-operator">-</span>get <span class="hljs-operator">-</span>y install git
</code></pre><h1 id="heading-create-a-folder-and-pull-the-eb-command-repo">Create a folder and pull the eb command repo</h1>
<pre><code>sudo mkdir <span class="hljs-operator">/</span>eb<span class="hljs-operator">-</span>command
chown <span class="hljs-operator">-</span>R <span class="hljs-operator">&lt;</span>ADDUSER<span class="hljs-operator">&gt;</span>:<span class="hljs-operator">&lt;</span>ADDUSER<span class="hljs-operator">&gt;</span> <span class="hljs-operator">/</span>eb<span class="hljs-operator">-</span>command
cd eb<span class="hljs-operator">-</span>command
git clone https:<span class="hljs-comment">//github.com/aws/aws-elastic-beanstalk-cli-setup.git</span>
</code></pre><p>Run EB CLI install file</p>
<pre><code>python ./aws<span class="hljs-operator">-</span>elastic<span class="hljs-operator">-</span>beanstalk<span class="hljs-operator">-</span>cli<span class="hljs-operator">-</span>setup<span class="hljs-operator">/</span>scripts<span class="hljs-operator">/</span>ebcli_installer.py
</code></pre><p>A successful install will look like this
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656755359315/IXKMnwhEW.png" alt="image.png" /></p>
<p>Run the bash command provided above</p>
<h1 id="heading-test-eb-cli-command">Test EB CLI Command</h1>
<pre><code>eb <span class="hljs-operator">-</span><span class="hljs-operator">-</span>help
</code></pre><p>Successful will look like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656755433235/3FktOnXG-.png" alt="image.png" /></p>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>https://github.com/aws/aws-elastic-beanstalk-cli-setup</li>
<li>https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html#eb-cli3-install.scripts</li>
<li>https://linuxize.com/post/how-to-install-python-3-9-on-debian-10/</li>
<li>https://virtualenv.pypa.io/en/latest/user_guide.html</li>
<li>https://github.com/pyenv/pyenv</li>
<li>https://stackoverflow.com/questions/18363022/importerror-no-module-named-pip</li>
<li>https://stackoverflow.com/questions/31133050/virtualenv-command-not-found</li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
<li><a target="_blank" href="https://coinbase.com/join/dayana_m40?src=android-link">Join coinbase with my and you will earn some free crypto as well</a></li>
</ul>
<p>Now you can create apps in elastic beanstalk! I will blog creating an app soon.</p>
<p>Hope this helps😁</p>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Creating a AWS EC2 using Github Actions and Terraform Cloud]]></title><description><![CDATA[These are steps on how I created an AWS EC2 using Github Actions and Terraform. 
Create a Terraform Cloud account

Create Terraform Cloud Account using this link
Create a workspace - remember the name you called it
In your AWS portal
Create a new AWS...]]></description><link>https://blog.azcodez.com/creating-a-aws-ec2-using-github-actions-and-terraform-cloud</link><guid isPermaLink="true">https://blog.azcodez.com/creating-a-aws-ec2-using-github-actions-and-terraform-cloud</guid><category><![CDATA[THW Cloud Computing]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Terraform]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Thu, 21 Apr 2022 17:35:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650139074208/NyALn0htK.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>These are steps on how I created an AWS EC2 using Github Actions and Terraform. </p>
<h1 id="heading-create-a-terraform-cloud-account">Create a Terraform Cloud account</h1>
<ul>
<li><a target="_blank" href="https://app.terraform.io/?utm_source=learn">Create Terraform Cloud Account using this link</a></li>
<li>Create a workspace - remember the name you called it</li>
<li>In your AWS portal<ul>
<li><a target="_blank" href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html">Create a new AWS IAM user</a></li>
<li>Give this IAM User full AWS EC2 access</li>
<li>Store AWS Access Credentials in the Terraform cloud workspace under variables named <ul>
<li>AWS_ACCESS_KEY_ID</li>
<li>AWS_SECRET_ACCESS_KEY
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650561122135/-tu54VtdA.png" alt="image.png" /></li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="heading-create-terraform-cloud-token">Create Terraform Cloud token</h1>
<ul>
<li>Go to this link which will take you to terraform tokens page <ul>
<li>https://app.terraform.io/app/settings/tokens?utm_source=learn</li>
</ul>
</li>
<li>Create an API token Copy this token we will store this in Gitub Repo</li>
</ul>
<h1 id="heading-create-a-new-github-repo">Create a new GitHub repo</h1>
<ul>
<li><a target="_blank" href="https://docs.github.com/en/get-started/quickstart/create-a-repo">Follow these instructions on how to create a GitHub repo if you havent before</a></li>
<li>Add above Terraform Cloud API token secret<ul>
<li>In your GitHub repo </li>
<li>Settings &gt; Secrets &gt; Actions</li>
<li>Create repository secret named TF_API_TOKEN
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650561599991/9TbKNUZAd.png" alt="image.png" /></li>
</ul>
</li>
</ul>
<h1 id="heading-pull-repo-down-locally-to-modify-codehttpsdocsgithubcomendesktopcontributing-and-collaborating-using-github-desktopadding-and-cloning-repositoriescloning-a-repository-from-github-to-github-desktop"><a target="_blank" href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/adding-and-cloning-repositories/cloning-a-repository-from-github-to-github-desktop">Pull repo down locally to modify code</a></h1>
<h1 id="heading-add-terraform-files">Add Terraform files</h1>
<ul>
<li>Copy this file to your repo <a target="_blank" href="https://github.com/hashicorp/learn-terraform-github-actions/blob/main/main.tf">main.tf</a></li>
</ul>
<h1 id="heading-add-github-action-file">Add GitHub Action file</h1>
<ul>
<li>Copy this terraform.ym to your repo as well https://github.com/hashicorp/learn-terraform-github-actions/blob/main/.github/workflows/terraform.yml</li>
<li>See this for more info to what it does
https://learn.hashicorp.com/tutorials/terraform/github-actions?in=terraform/automation</li>
</ul>
<h1 id="heading-change-maintf">Change main.tf</h1>
<ul>
<li>Configure these lines to suit what you have created in terraform cloud </li>
<li>Change ADD_TERRAFORM_ORGANISATION_NAME &amp; ADD_TERRAFORM_WORKSPACE_NAME </li>
</ul>
<pre><code>  <span class="hljs-section">cloud</span> {
    <span class="hljs-attribute">organization</span> = <span class="hljs-string">"ADD_TERRAFORM_ORGANISATION_NAME"</span>

    workspaces {
      <span class="hljs-attribute">name</span> = <span class="hljs-string">"ADD_TERRAFORM_WORKSPACE_NAME"</span>
    }
  }
}
</code></pre><ul>
<li>Change this line to where you want your EC2 to be created (us-west-2)<pre><code><span class="hljs-attribute">provider</span> <span class="hljs-string">"aws"</span> {
<span class="hljs-attribute">region</span> = <span class="hljs-string">"us-west-2"</span>
}
</code></pre></li>
</ul>
<h1 id="heading-create-a-branch-and-push-changes-up">Create a branch and push changes up</h1>
<pre><code><span class="hljs-attribute">git</span> branch NewEC<span class="hljs-number">2</span>
<span class="hljs-attribute">git</span> checkout NewEC<span class="hljs-number">2</span>
<span class="hljs-attribute">git</span> push NewEC<span class="hljs-number">2</span>
</code></pre><h1 id="heading-create-a-in-github-pr-to-merge-into-main">Create a in GitHub PR to merge into main</h1>
<ul>
<li><a target="_blank" href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request">Create PR in GitHub Repo</a></li>
<li>GitHub Action Check will kick off and check if everything is ok</li>
<li>If you get errors like<pre><code>Error: <span class="hljs-keyword">No</span> <span class="hljs-keyword">valid</span> credential sources <span class="hljs-built_in">found</span> <span class="hljs-keyword">for</span> AWS Provider.
</code></pre></li>
<li>Double check your organization and workspace in terraform or Terraform API key we added into secrets in github</li>
<li>If checks succeed you are ready to create your EC2 from Terraform code</li>
<li>Merge pull request into main </li>
<li>Wait for GitHub action to run
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650562128763/Z5LsKzVr-.png" alt="image.png" /></li>
</ul>
<h1 id="heading-check-if-ec2-got-provisioned">Check if EC2 got provisioned</h1>
<ul>
<li>Go to your Github Action in your repo and click under Terraform Apply step you should have a url to check server
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1648326842609/CF7XZfpBY.png" alt="image.png" /></li>
<li>Copy it and go to the site and check it should respond to hello world.</li>
<li>You also could login to your AWS account and find the server</li>
</ul>
<p>Congrats you have created a server with GitHub Actions and Terraform 🎉</p>
<h1 id="heading-now-delete-resources">Now delete resources</h1>
<ul>
<li>Open  your Terraform Cloud </li>
<li>Find your workspace</li>
<li>Click settings</li>
<li>Queue destroy plan 
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1648327119697/r8yz6TIo5.png" alt="image.png" /></li>
<li>You will see triggers running to destroy it</li>
<li>You have to confirm you want to accept deleting</li>
<li>Check your url before is broken </li>
<li>Check your EC2 server is removed in the AWS portal or via AWS CLI command</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li><a target="_blank" href="https://learn.hashicorp.com/tutorials/terraform/github-actions?in=terraform/automation">Hashicorp Terraform Github Actions</a></li>
<li><a target="_blank" href="https://learn.hashicorp.com/tutorials/terraform/aws-build?in=terraform/aws-get-started">Learn Hashicorp Terraform Github Actions</a></li>
<li><a target="_blank" href="https://www.coletiv.com/blog/android-github-actions-setup/">Github Action image</a></li>
<li><a target="_blank" href="https://www.parkmycloud.com/blog/terraform-on-aws/">Terraform AWS image</a></li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
<li><a target="_blank" href="https://coinbase.com/join/dayana_m40?src=android-link">Join coinbase with my and you will earn some free crypto as well</a></li>
</ul>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Automate login to GitHub with ssh key (linux)]]></title><description><![CDATA[Intro
If you have setup ssh authentification to GitHub and if you are annoyed at setting ssh-agent and github key everytime you pull/push to git, here is how you automate it 😁
Edit linux profile
This is based on linux WSL2 system

Edit your linux pr...]]></description><link>https://blog.azcodez.com/automate-login-to-github-with-ssh-key-linux</link><guid isPermaLink="true">https://blog.azcodez.com/automate-login-to-github-with-ssh-key-linux</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Fri, 15 Apr 2022 20:35:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/ZBWn5DvO0hg/upload/v1650054684431/0zl-dDk8g.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-intro">Intro</h1>
<p>If you have setup ssh authentification to GitHub and if you are annoyed at setting ssh-agent and github key everytime you pull/push to git, here is how you automate it 😁</p>
<h1 id="heading-edit-linux-profile">Edit linux profile</h1>
<p>This is based on linux WSL2 system</p>
<ul>
<li>Edit your linux profile <pre><code>nano <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.profile
</code></pre></li>
<li>And add eval <pre><code>`eval `ssh<span class="hljs-operator">-</span>agent` 
ssh<span class="hljs-operator">-</span>add <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.ssh/github<span class="hljs-operator">-</span>key
</code></pre></li>
<li>Close current terminal and open new terminal </li>
<li>You should have these lines printed out at start of terminal <pre><code>Agent pid XXXX Identity added: <span class="hljs-operator">/</span>root<span class="hljs-operator">/</span>.ssh/github<span class="hljs-operator">-</span>key XXXX
</code></pre></li>
<li>Test fetching/commiting and pushing a change. eg<pre><code>git fetch
git commit <span class="hljs-operator">-</span><span class="hljs-operator">-</span>allow<span class="hljs-operator">-</span>empty <span class="hljs-operator">-</span>m <span class="hljs-string">"test"</span>
git push
</code></pre></li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent</li>
<li><a target="_blank" href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent">Create ssh key</a></li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
<li><a target="_blank" href="https://coinbase.com/join/dayana_m40?src=android-link">Join coinbase with my and you will earn some free crypto as well</a></li>
</ul>
<p>Hope this saves you some time and getting annoyed 😒😁</p>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Add GitHub ssh-agent and ssh key on startup (Windows)]]></title><description><![CDATA[If you have GitHub ssh key setup to access your remote repo, whenever you log out your PC your ssh key drops out! So you have to run evalssh-agent -s&& 
ssh-add ~/.ssh/xxx-key everytime you login.😡
This is how I added ssh-agent and ssh key authentif...]]></description><link>https://blog.azcodez.com/add-github-ssh-agent-and-ssh-key-on-startup-windows</link><guid isPermaLink="true">https://blog.azcodez.com/add-github-ssh-agent-and-ssh-key-on-startup-windows</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 26 Mar 2022 13:09:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/AvqpdLRjABs/upload/v1648300103473/lvDYdM2xTX.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have GitHub ssh key setup to access your remote repo, whenever you log out your PC your ssh key drops out! So you have to run <code>eval</code>ssh-agent -s<code>&amp;&amp; 
ssh-add ~/.ssh/xxx-key</code> everytime you login.😡</p>
<p>This is how I added ssh-agent and ssh key authentification on start up of git terminal in Windows and in Android studio git bash terminal. </p>
<h1 id="heading-add-your-ssh-agent-connection-to-profile">Add your ssh-agent  connection to .profile</h1>
<ul>
<li>In git terminal</li>
<li>Create a .profile or edit it <pre><code>nano <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.profile
</code></pre></li>
<li>Add these contents. Remember to edit to set path to your ssh key!<pre><code><span class="hljs-meta">#! /bin/bash </span>
<span class="hljs-built_in">eval</span> `ssh-agent -s` 
ssh-add ~/.ssh/&lt;ADD_PATH_TO_SSH_KEY&gt;
</code></pre></li>
</ul>
<h1 id="heading-add-your-ssh-agent-connection-to-bashrc">Add your ssh-agent connection to .bashrc</h1>
<ul>
<li>You will need to add to bash as well. eg. I am using git terminal in Android studio so I will need to change bashrc</li>
<li>Create a .bashrc or edit it <pre><code>nano <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.bashrc
</code></pre></li>
<li>Add these contents. Remember to edit to set path to your ssh key!<pre><code><span class="hljs-meta">#! /bin/bash </span>
<span class="hljs-built_in">eval</span> `ssh-agent -s` 
ssh-add ~/.ssh/&lt;ADD_PATH_TO_SSH_KEY&gt;
</code></pre></li>
<li>Restart the app that you are using git cli</li>
<li>You should see something like <pre><code>Agent pid XXXX
<span class="hljs-keyword">Identity</span> added: xxxxxxxxx
</code></pre></li>
<li>Go to one of your repos and fetch remote repo by running<pre><code>git <span class="hljs-keyword">fetch</span>
</code></pre></li>
<li>This should fetch contents without asking for key or ssh agent</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>https://stackoverflow.com/questions/3669001/getting-ssh-agent-to-work-with-git-run-from-windows-command-shell/15870387#15870387</li>
<li>https://stackoverflow.com/questions/18404272/running-ssh-agent-when-starting-git-bash-on-windows</li>
<li>https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent</li>
<li><a target="_blank" href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent">Create ssh key</a></li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
</ul>
<p>Hope this saves you some time and getting annoyed 😒😁</p>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
]]></content:encoded></item><item><title><![CDATA[Create a database table in Magento 2]]></title><description><![CDATA[Below are steps I went though to create a new database table in Magento 2 / Adobe Commerce
Create a module
You can add to your existing module or follow this blog to create a module
Create a db schema

Refernce https://devdocs.magento.com/guides/v2.4...]]></description><link>https://blog.azcodez.com/create-a-database-table-in-magento-2</link><guid isPermaLink="true">https://blog.azcodez.com/create-a-database-table-in-magento-2</guid><category><![CDATA[coding]]></category><category><![CDATA[Magento]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Fri, 04 Mar 2022 17:13:42 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1565791380713-1756b9a05343?ixlib=rb-1.2.1&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=1760&amp;q=80" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below are steps I went though to create a new database table in Magento 2 / Adobe Commerce</p>
<h2 id="heading-create-a-module">Create a module</h2>
<p>You can add to your existing module or <a target="_blank" href="https://blog.azcodez.com/magento-2-create-a-module-in-magento-2">follow this blog to create a module</a></p>
<h2 id="heading-create-a-db-schema">Create a db schema</h2>
<ul>
<li><p>Refernce <a target="_blank" href="https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/db-schema.html">https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/db-schema.html</a></p>
</li>
<li><p>Path will be similar path to this
app\code\AzCodez\CustomerViewing\etc\db_schema.xml</p>
</li>
<li><p>Add this code to setup your table. Modify table names, columns, types to suit your own</p>
</li>
</ul>

<pre><code><span class="hljs-operator">&lt;</span>?xml version<span class="hljs-operator">=</span><span class="hljs-string">"1.0"</span>?<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">!</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span> Database schema <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>schema xmlns:xsi<span class="hljs-operator">=</span><span class="hljs-string">"http://www.w3.org/2001/XMLSchema-instance"</span> xsi:noNamespaceSchemaLocation<span class="hljs-operator">=</span><span class="hljs-string">"urn:magento:framework:Setup/Declaration/Schema/etc/schema. xsd"</span><span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>table name<span class="hljs-operator">=</span><span class="hljs-string">"az_codez_followers"</span> resource<span class="hljs-operator">=</span><span class="hljs-string">"default"</span> engine<span class="hljs-operator">=</span><span class="hljs-string">"innodb"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Azcodez followers"</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>column xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"int"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"follower_id"</span> padding<span class="hljs-operator">=</span><span class="hljs-string">"19"</span> unsigned<span class="hljs-operator">=</span><span class="hljs-string">"true"</span> nullable<span class="hljs-operator">=</span><span class="hljs-string">"false"</span> identity<span class="hljs-operator">=</span><span class="hljs-string">"true"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Follower id"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>column xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"name"</span> nullable<span class="hljs-operator">=</span><span class="hljs-string">"false"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Follower Name"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>column xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"email"</span> nullable<span class="hljs-operator">=</span><span class="hljs-string">"false"</span> comment<span class="hljs-operator">=</span><span class="hljs-string">"Follower Contact"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>constraint xsi:<span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"primary"</span> referenceId<span class="hljs-operator">=</span><span class="hljs-string">"PRIMARY"</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>column name<span class="hljs-operator">=</span><span class="hljs-string">"follower_id"</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>constraint<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>table<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>schema<span class="hljs-operator">&gt;</span>
</code></pre><h2 id="heading-generate-generate-dbschemawhitelistjson">Generate  generate db_schema_whitelist.json</h2>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command setup:db<span class="hljs-operator">-</span>declaration:generate<span class="hljs-operator">-</span>whitelist
</code></pre><h2 id="heading-redeploy">Redeploy</h2>
<h2 id="heading-find-your-table-and-see-if-it-worked-eg">Find your table and see if it worked eg.</h2>
<pre><code><span class="hljs-keyword">Select</span> * <span class="hljs-keyword">From</span> az_codez_followers;
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1646408394493/fzvAB2a3I.png" alt="image.png" /></p>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li><a target="_blank" href="https://unsplash.com/photos/nME9TubZtSo">Header image</a></li>
<li><a target="_blank" href="https://devdocs.magento.com">Adobe Magento Commence Documentation</a></li>
</ul>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
]]></content:encoded></item><item><title><![CDATA[Create a frontend page in Magento 2]]></title><description><![CDATA[Below are steps to how I created a front-end page using a controller in Magento 2. 
Create a module

Create folders and paths as this example. Replace AzCodez\Page with your module.

app\code\AzCodez\Page\Controller\Action\Index.php


In Index.php ad...]]></description><link>https://blog.azcodez.com/create-a-frontend-page-in-magento-2</link><guid isPermaLink="true">https://blog.azcodez.com/create-a-frontend-page-in-magento-2</guid><category><![CDATA[software development]]></category><category><![CDATA[Magento]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 05 Feb 2022 18:18:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1644084610617/8VSljvBe8.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below are steps to how I created a front-end page using a controller in Magento 2. </p>
<p><a target="_blank" href="https://blog.azcodez.com/magento-2-create-a-module-in-magento-2">Create a module</a></p>
<ul>
<li><p>Create folders and paths as this example. Replace AzCodez\Page with your module.</p>
<ul>
<li>app\code\AzCodez\Page\Controller\Action\Index.php</li>
</ul>
</li>
<li><p>In Index.php add the below code.</p>
<ul>
<li>This class creates a page and sets page contents to 'Hello From Custom Page'</li>
<li>Replace AzCodez\Page with your module.</li>
</ul>
</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>
<span class="hljs-comment">/**
 * Render page
 * 
 */</span>
<span class="hljs-keyword">namespace</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">Page</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">Action</span>;

<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">View</span>\<span class="hljs-title">Result</span>\<span class="hljs-title">PageFactory</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">App</span>\<span class="hljs-title">Action</span>\<span class="hljs-title">Action</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">App</span>\<span class="hljs-title">Action</span>\<span class="hljs-title">Context</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">ResultInterface</span>;

<span class="hljs-comment">/**
 * Class Index
 * <span class="hljs-doctag">@package</span> AzCodez\Page\Controller\Action
 */</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Index</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Action</span>
</span>{

     <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> PageFactory
     */</span>
     <span class="hljs-keyword">protected</span> $_pageFactory;

     <span class="hljs-comment">/**
     * Index constructor.
     * <span class="hljs-doctag">@param</span> Context $context
     * <span class="hljs-doctag">@param</span> PageFactory $pageFactory
     */</span>
     <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">construct</span>(<span class="hljs-params">
        Context $context,
        PageFactory $pageFactory
    </span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;_pageFactory = $pageFactory;
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">parent</span>::__construct($context);
     }

     <span class="hljs-comment">/**
     * <span class="hljs-doctag">@return</span> ResultInterface
     */</span>
     <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">execute</span>(<span class="hljs-params"></span>)
     </span>{
        $result = <span class="hljs-keyword">$this</span>-&gt;resultFactory-&gt;create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
        $result-&gt;setContents(<span class="hljs-string">'Hello From AzCodez Custom Page'</span>);
        <span class="hljs-keyword">return</span> $result;
     }

}
</code></pre><ul>
<li><p>Create a route to route the page to the frontend.  Replace AzCodez\Page with your module.</p>
<ul>
<li>This is the file path app\code\AzCodez\Page\etc\frontend\routes.xml</li>
</ul>
</li>
<li><p>Add code for route. Replace AzCodez_Page with your module name</p>
<pre><code><span class="hljs-operator">&lt;</span>?xml version<span class="hljs-operator">=</span><span class="hljs-string">"1.0"</span>?<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>config xmlns:xsi<span class="hljs-operator">=</span><span class="hljs-string">"http://www.w3.org/2001/XMLSchema-instance"</span> xsi:noNamespaceSchemaLocation<span class="hljs-operator">=</span><span class="hljs-string">"urn:magento:framework:App/etc/routes.xsd"</span><span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span>router id<span class="hljs-operator">=</span><span class="hljs-string">"standard"</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>route id<span class="hljs-operator">=</span><span class="hljs-string">"product_list"</span> frontName<span class="hljs-operator">=</span><span class="hljs-string">"product_list"</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>module name<span class="hljs-operator">=</span><span class="hljs-string">"AzCodez_Page"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>route<span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>router<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>config<span class="hljs-operator">&gt;</span>
</code></pre></li>
<li><p>Run deploy commands </p>
</li>
<li><p>If not running docker remove <code>docker-compose run --rm deploy magento-command</code> and replace with <code>php bin/magento</code></p>
<pre><code>rm -rf generated<span class="hljs-regexp">/code/</span>* &amp;&amp; 
rm -rf pub<span class="hljs-regexp">/static/frontend/</span>* &amp;&amp; 
rm -rf pub<span class="hljs-regexp">/static/adminhtml/</span>* &amp;&amp; 
docker-compose run --rm deploy magento-command setup:upgrade &amp;&amp; 
docker-compose run --rm deploy magento-command setup:di:compile &amp;&amp; 
docker-compose run --rm deploy cloud-deploy &amp;&amp; 
docker-compose run --rm deploy magento-command cache:clean &amp;&amp; 
docker-compose run --rm deploy magento-command cache:flush
</code></pre></li>
<li><p>Load the page 
http://magento2.docker/product_list/action/index</p>
</li>
</ul>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li>Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200. https://magic.freetrade.io/join/asrin/447192e9</li>
<li>Want to start a blog on hashnode use this <a target="_blank" href="https://hashnode.com/@azcodez/joinme">link </a> so I get a free shirt. I will assist you with setup 🙂</li>
<li>Sign up for coinbase and get £7.42 of Bitcoin http://coinbase.com/join/dayana_m40?src=android-link</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li><a target="_blank" href="https://business.adobe.com/products/magento/magento-commerce.html">Magento 2 / Adobe Commerce</a></li>
<li><a target="_blank" href="https://devdocs.magento.com/">Magento Dev Docs</a></li>
</ul>
<p>Feel free to comment if you get stuck or have questions or feedback✌️</p>
<p>Happy Coding 🙂</p>
<p>Az 👨🏾‍💻</p>
]]></content:encoded></item><item><title><![CDATA[Create a budget alert in Azure cloud]]></title><description><![CDATA[Below are steps on how I set up a budget in Azure cloud so it alerts me before I spend too much. I hope this helps you as well.

Sign in to your Azure portal
Search for cost management and click on cost management. You will have a screen like below

...]]></description><link>https://blog.azcodez.com/create-a-budget-alert-in-azure-cloud</link><guid isPermaLink="true">https://blog.azcodez.com/create-a-budget-alert-in-azure-cloud</guid><category><![CDATA[Azure]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 29 Jan 2022 17:46:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/QH8mhSR_gcE/upload/v1643477448513/PF5M2leVn.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below are steps on how I set up a budget in Azure cloud so it alerts me before I spend too much. I hope this helps you as well.</p>
<ul>
<li>Sign in to your Azure portal</li>
<li>Search for cost management and click on cost management. You will have a screen like below</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1643478083183/NeUmJctNe.png" alt="image.png" /></p>
<ul>
<li>Click on budgets on the right hand side</li>
<li>Add a budget</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1643478095872/94eMcJrXU.png" alt="image.png" /></p>
<ul>
<li>Enter budget details </li>
<li>Set Budget name to whatever you like</li>
<li>Set Reset period to monthly to reset the budget monthly as usually you are charged monthly unless you have changed do a different way to pay</li>
<li>Set Creation date to the beginning of the month. This should be set for you</li>
<li>Set Expiration date to whenever you want the budget to end, say 10 years time </li>
<li>Set your Budget amount, this is what amount you are willing pay</li>
<li>My budget looks like this </li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1643478119003/dI0A-YOJm.png" alt="image.png" /></p>
<ul>
<li>Click Next after confirming</li>
<li>Set Alert conditions </li>
<li>Select Type of actual or forecasted. Actual means amount of services used and charged for and forecasted means prediction of azure services depending on how you use them. Eg. if a virtual server is on most of the time it's going to predict how much it's going to spend. I prefer actual.</li>
<li>Select % of budget, this percentage is when the percentage of budget you set in the   previous screen will send an alert to you. I like to set this at 90%. The Amount will be worked out for you automatically</li>
<li>Action group is set to none</li>
<li>Add Alert recipients emails to who you want alerts to go to</li>
<li>Select language</li>
<li>Click create</li>
</ul>
<p>Congrats, You have created an alert
Now you will be notified when you are reaching your budget and there will be no nasty surprises.</p>
<p>More info at Microsoft docs https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/tutorial-acm-create-budgets</p>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
</ul>
<p>Feel free to comment if you get stuck or have questions or feedback✌️</p>
<p>Happy Coding 🙂
Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[How to turn on AWS EC2 using Github Actions]]></title><description><![CDATA[Below we are going to write a  Github Action  that turns on an AWS EC2 server
Create a  GitHub account

Create a new repository

Setup file for workflow

Folder named .github
Folder in .github called workflows
Create a file called turnOnAWSEC2.yml
Se...]]></description><link>https://blog.azcodez.com/how-to-turn-on-aws-ec2-using-github-actions</link><guid isPermaLink="true">https://blog.azcodez.com/how-to-turn-on-aws-ec2-using-github-actions</guid><category><![CDATA[AWS]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 15 Jan 2022 15:25:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/CiUR8zISX60/upload/v1642248344848/CXlgiaHLn.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below we are going to write a  <a target="_blank" href="https://github.com/features/actions">Github Action</a>  that turns on an AWS EC2 server</p>
<h2 id="heading-create-a-githubhttpsgithubcom-account">Create a  <a target="_blank" href="https://github.com/">GitHub</a> account</h2>
<ul>
<li><p>Create a new repository</p>
</li>
<li><p>Setup file for workflow</p>
<ul>
<li>Folder named .github</li>
<li>Folder in .github called workflows</li>
<li>Create a file called turnOnAWSEC2.yml</li>
<li>See  <a target="_blank" href="https://docs.github.com/en/actions/quickstart">Link for more info</a> </li>
</ul>
</li>
</ul>
<h2 id="heading-add-code-to-workflow-turnonawsec2yml-file">Add code to workflow (turnOnAWSEC2.yml) file</h2>
<ul>
<li>Please see comments starting with '#' explaining what each bit of the file does</li>
<li>This code is set up only to run when you click action in the repository</li>
<li>Github workflows servers that are used to run the workflows have AWS CLI commands built-in, so all you need to do is run the AWS CLI command  <a target="_blank" href="https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners">See this link for more information</a> </li>
</ul>
<pre><code><span class="hljs-attribute">name</span>: startMagent2DevEC2

<span class="yaml"><span class="hljs-comment"># Controls when the action will run. </span>
<span class="hljs-comment"># This code is set up only to run when you click action in the repository, If you require to run on a push or cron edit below</span>
<span class="hljs-attr">on:</span>
  <span class="hljs-comment"># Triggers the workflow on push or pull request events but only for the main branch</span>
  <span class="hljs-comment"># push:</span>
  <span class="hljs-comment">#  branches: [ main ]</span>
  <span class="hljs-comment"># Allows you to run this workflow manually from the Actions tab</span>
  <span class="hljs-attr">workflow_dispatch:</span>

<span class="hljs-comment"># A workflow run is made up of one or more jobs that can run sequentially or in parallel</span>
<span class="hljs-attr">jobs:</span>
  <span class="hljs-comment"># This workflow contains a single job called "build"</span>
  <span class="hljs-attr">build:</span>

    <span class="hljs-comment"># The type of runner that the job will run on</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>

    <span class="hljs-comment"># Below this are each of the steps that are run</span>
    <span class="hljs-attr">steps:</span>

     <span class="hljs-comment"># Name of step</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Start</span> <span class="hljs-string">AWS</span> <span class="hljs-string">EC2</span>
        <span class="hljs-comment"># Run AWS Command on the GitHub Hosted runner which starts the instance using AWS authentication stored in GitHub Secrets (see below how to add)</span>
        <span class="hljs-attr">run:</span> <span class="hljs-string">|
          aws ec2 start-instances --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
</span>        <span class="hljs-attr">env:</span>
          <span class="hljs-attr">AWS_ACCESS_KEY_ID:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_ACCESS_KEY_ID</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_SECRET_ACCESS_KEY:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_SECRET_ACCESS_KEY</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_DEFAULT_REGION:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_REGION</span> <span class="hljs-string">}}</span></span>
</code></pre><h2 id="heading-add-github-repository-secrets">Add GitHub Repository Secrets</h2>
<ul>
<li><p>In the above workflow, we have many secrets to add eg. ${{ secrets.AWS_ACCESS_KEY_ID }}</p>
<ul>
<li>Secrets are secret values stored so that GitHub workflow can use them without exposing them in your workflow file</li>
</ul>
</li>
<li><p>Create AWS Keys </p>
<ul>
<li>Log into your AWS portal that has high privileges to create accounts</li>
<li>Create a new IAM user as its AWS best practice to keep your logins separate from your root account  <a target="_blank" href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html">See this link</a> </li>
<li>Logout and login as your new IAM user</li>
<li>Click your cloud name </li>
<li>Click 'My Security Credentials'
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1636198012667/FZ3bAswSN.png" alt="image.png" /></li>
<li>Click create </li>
<li>Here you will have 2 keys that you will need to add to your repository. Keep this page open or copy these to add to below</li>
</ul>
</li>
<li><p>To add these AWS keys to your GitHub Repository</p>
<ul>
<li>Click settings in your repository</li>
<li>Then secrets</li>
<li>Add repository secret named AWS_ACCESS_KEY_ID and add the key from the AWS portal you generated above</li>
<li>Create another secret named AWS_SECRET_ACCESS_KEY and add relevant keys from your keys created in your AWS Account</li>
</ul>
</li>
<li><p>Create a secret for your instance id ie. ${{secrets.AWS_EC2_INSTANCE_ID }}</p>
<ul>
<li>Go to your AWS Console</li>
<li>Select Services &gt; EC2</li>
<li>Instance ID is the identifier of what EC2 VM as below screenshot</li>
<li>Copy this ID and add it to your GitHub Secrets</li>
<li>Click settings in your repository</li>
<li>Then secrets</li>
<li>Add repository secret named AWS_EC2_INSTANCE_ID and add instance id</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642256417358/3zhO4jSvK.png" alt="image.png" /></p>
<ul>
<li>Create a secret for your AWS region where your AWS EC2 is running id ie. ${{ secrets.AWS_REGION }}</li>
<li>Go to your AWS Console <ul>
<li>Select Services &gt; EC2</li>
<li>Region is in the right-hand corner as below screenshot</li>
<li>Make sure you match your region with code in this  <a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-regions">link</a> </li>
<li>Add to your GitHub Secrets</li>
<li>Click settings in your repository</li>
<li>Then secrets</li>
<li>Add repository secret named AWS_REGION and add AWS region</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642256512013/zAxKXXY9o.png" alt="image.png" /></p>
<p>Commit and push code if you haven't already</p>
<h1 id="heading-run-your-github-action">Run your GitHub action</h1>
<ul>
<li>In your repo</li>
<li>Click Actions</li>
<li>Select Action to run</li>
<li>Click run the workflow</li>
</ul>
<p>If successful you should have a complete success workflow and your EC2 should be switched on in AWS.</p>
<p>Don't forget to turn off your EC2 if you don't want it to run.</p>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li>Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200. https://magic.freetrade.io/join/asrin/447192e9</li>
<li>Want to start a blog on hashnode use this <a target="_blank" href="https://hashnode.com/@azcodez/joinme">link </a> so I get a free shirt. I will assist you with setup 🙂</li>
<li>Sign up for coinbase and get £7.42 of Bitcoin http://coinbase.com/join/dayana_m40?src=android-link</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li><a target="_blank" href="https://docs.aws.amazon.com/cli/latest/reference/ec2/start-instances.html">AWS CLI commands</a> </li>
<li><a target="_blank" href="https://docs.github.com/en/actions">GitHub Actions</a> </li>
<li><a target="_blank" href="https://aws.amazon.com/">Amazon Web Services</a> </li>
</ul>
<p>Feel free to comment if you get stuck or have questions or feedback✌️</p>
<p>Happy Coding 🙂</p>
<p>Az 👨🏾‍💻</p>
]]></content:encoded></item><item><title><![CDATA[Method Chaining in PHP with PHPUnit test]]></title><description><![CDATA[What is method chaining
Method chaining is where you can call multiple methods after one another in one line like so
$methodChain->addHelloToChain()->addSpaceToChain()->addThereToChain()->getOutputOfChain();
Let's write some code
Setup an initial cla...]]></description><link>https://blog.azcodez.com/method-chaining-in-php-with-phpunit-test</link><guid isPermaLink="true">https://blog.azcodez.com/method-chaining-in-php-with-phpunit-test</guid><category><![CDATA[PHP]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[coding]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sun, 05 Dec 2021 19:17:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/2zGTh-S5moM/upload/v1638731379090/gUaU-Kq8a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-what-is-method-chaining">What is method chaining</h1>
<p>Method chaining is where you can call multiple methods after one another in one line like so</p>
<pre><code>$methodChain<span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span>addHelloToChain()<span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span>addSpaceToChain()<span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span>addThereToChain()<span class="hljs-operator">-</span><span class="hljs-operator">&gt;</span>getOutputOfChain();
</code></pre><h1 id="heading-lets-write-some-code">Let's write some code</h1>
<p>Setup an initial class with this code which has a few methods that you can call. </p>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">namespace</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">UnitTesting</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MethodChainingTest</span>
</span>{
    <span class="hljs-keyword">public</span> $outputOfChain = <span class="hljs-string">''</span>;

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">__construct</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;outputOfChain = <span class="hljs-string">''</span>;
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addHelloToChain</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;outputOfChain .= <span class="hljs-string">"hello"</span>;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>;
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addSpaceToChain</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;outputOfChain .= <span class="hljs-string">" "</span>;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>;
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addThereToChain</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;outputOfChain .= <span class="hljs-string">"there"</span>;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>;
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addByeToChain</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;outputOfChain .= <span class="hljs-string">"bye"</span>;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>;
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addNowToChain</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;outputOfChain .= <span class="hljs-string">"now"</span>;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>;
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getOutputOfChain</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>-&gt;outputOfChain;
    }
}
</code></pre><p>The above four methods are what you call to make your chain.</p>
<ul>
<li>addHelloToChain()</li>
<li>addSpaceToChain()</li>
<li>addThereToChain()</li>
<li>addByeToChain()</li>
</ul>
<p>The last method getOutputOfChain() gets the output of the chain result.</p>
<h1 id="heading-write-a-phpunit-test">Write a PHPUnit Test</h1>
<p>Now we will write a PHP Unit test, call the chain, and test output. Explanation is in comment of code.</p>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">UnitTesting</span>\<span class="hljs-title">TestClassMethodChaining</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestMethodChaining</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * Unit test to check method chaining of calling addByeToChain + addNowToChain() + addNowToChain should result in 'bye now'
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testMethodChaningHelloThere</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>
        $methodChain = <span class="hljs-keyword">new</span> TestClassMethodChaining();

        <span class="hljs-comment">//Act</span>
        $result = $methodChain-&gt;addHelloToChain()-&gt;addSpaceToChain()-&gt;addThereToChain()-&gt;getOutputOfChain();

        <span class="hljs-comment">// Asset</span>
        <span class="hljs-keyword">$this</span>-&gt;assertEquals(<span class="hljs-string">'hello there'</span>, $result);

    }

    <span class="hljs-comment">/**
     * Unit test to check method chaining of calling addByeToChain + addNowToChain() + addNowToChain should result in 'bye now'
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testMethodChaningByeNow</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>
        $methodChain = <span class="hljs-keyword">new</span> TestClassMethodChaining();

        <span class="hljs-comment">//Act</span>
        $result = $methodChain-&gt;addByeToChain()-&gt;addSpaceToChain()-&gt;addNowToChain()-&gt;getOutputOfChain();

        <span class="hljs-comment">// Asset</span>
        <span class="hljs-keyword">$this</span>-&gt;assertEquals(<span class="hljs-string">'bye now'</span>, $result);

    }
}
</code></pre><p>Run the tests </p>
<pre><code>./vendor<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>phpunit <span class="hljs-operator">-</span>c dev<span class="hljs-operator">/</span>tests<span class="hljs-operator">/</span>unit<span class="hljs-operator">/</span>phpunit.xml.dist app<span class="hljs-operator">/</span>code<span class="hljs-operator">/</span>AzCodez<span class="hljs-operator">/</span>MagentoTraining<span class="hljs-operator">/</span>Test<span class="hljs-operator">/</span>Unit<span class="hljs-operator">/</span>
</code></pre><h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li>Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200. https://magic.freetrade.io/join/asrin/447192e9</li>
<li>Start a blog on Hashnode https://hashnode.com/@azcodez/joinme</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>https://www.php.net/</li>
<li>Image https://unsplash.com/photos/2zGTh-S5moM</li>
</ul>
<p>Feel free to comment with questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Install Magento 2.4.3 Community on Docker WSL2]]></title><description><![CDATA[Install and activate Windows WSL2

Follow these instructions to setup your windows for linux subsystem
https://docs.microsoft.com/en-us/windows/wsl/install-win10



Setup Debian

In windows search and open Microsoft store 
Search for Debian App and I...]]></description><link>https://blog.azcodez.com/install-magento-243-community-on-docker-wsl2</link><guid isPermaLink="true">https://blog.azcodez.com/install-magento-243-community-on-docker-wsl2</guid><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[Developer]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Mon, 29 Nov 2021 20:31:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1638217853425/YrypjgreK.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-install-and-activate-windows-wsl2">Install and activate Windows WSL2</h2>
<ul>
<li>Follow these instructions to setup your windows for linux subsystem<ul>
<li>https://docs.microsoft.com/en-us/windows/wsl/install-win10</li>
</ul>
</li>
</ul>
<h2 id="heading-setup-debian">Setup Debian</h2>
<ul>
<li>In windows search and open Microsoft store </li>
<li>Search for Debian App and Install it</li>
<li>Launch the Debian terminal and create a user account</li>
<li>Switch to using the "root" user for the whole installation as this is doesnt cause file permission issues for magento generating files NOTE: Only do this on developer environments!</li>
<li>Change the password for the root user.<pre><code><span class="hljs-attribute">sudo</span> passwd root
</code></pre></li>
<li>Then login under root<pre><code><span class="hljs-attribute">su</span> root
</code></pre></li>
<li>We then need to set root as the default user for Debian. </li>
<li>Close Debian</li>
<li>Open CMD or Powershell and run<pre><code>debian config <span class="hljs-operator">-</span><span class="hljs-operator">-</span>default<span class="hljs-operator">-</span>user root
</code></pre></li>
<li><p>The root user has been set as the primary default user for Debian</p>
</li>
<li><p>Check if you have internet connectivity by running</p>
<pre><code>apt <span class="hljs-keyword">update</span>
</code></pre></li>
<li>If not see this for more info https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6</li>
</ul>
<h2 id="heading-install-docker-desktop">Install Docker Desktop</h2>
<ul>
<li><a target="_blank" href="https://docs.docker.com/docker-for-windows/install/">See these instructions for installation</a> </li>
<li>Once installed, Open docker desktop &gt; Settings &gt; General and select "Use the WSL 2 based engine".</li>
<li>Then click on Resources &gt; WSL Integration and select Enable integration with my default WSL distro</li>
<li>Apply and restart Docker desktop</li>
<li>After Docker Desktop has reinitialized, restart windows to be save everything is set properly</li>
</ul>
<h2 id="heading-install-php74-in-debian">Install php7.4 in Debian</h2>
<ul>
<li>Update apt<pre><code>sudo apt <span class="hljs-keyword">update</span>
</code></pre></li>
<li>Install wget<pre><code><span class="hljs-attribute">sudo</span> apt install wget
</code></pre></li>
<li>Install dependencies<pre><code>sudo apt install software<span class="hljs-operator">-</span>properties<span class="hljs-operator">-</span>common ca<span class="hljs-operator">-</span>certificates lsb<span class="hljs-operator">-</span>release apt<span class="hljs-operator">-</span>transport<span class="hljs-operator">-</span>https
</code></pre></li>
<li>Enable SURY repo<pre><code>sudo sh -<span class="hljs-built_in">c</span> 'echo <span class="hljs-string">"deb https://packages.sury.org/php/ $(lsb_release -sc) main"</span> &gt; /etc/apt/sources.list.d/php.list'
</code></pre></li>
<li>Install gnupg<pre><code>apt-<span class="hljs-keyword">get</span> <span class="hljs-keyword">update</span>
</code></pre><pre><code><span class="hljs-attribute">apt</span> install gnupg
</code></pre></li>
<li>Import the GPG key for the repository<pre><code>wget <span class="hljs-operator">-</span>qO <span class="hljs-operator">-</span> https:<span class="hljs-comment">//packages.sury.org/php/apt.gpg | sudo apt-key add -</span>
</code></pre></li>
<li>Install PHP7.4<pre><code>sudo apt <span class="hljs-keyword">update</span>
</code></pre><pre><code><span class="hljs-attribute">sudo</span> apt install php<span class="hljs-number">7</span>.<span class="hljs-number">4</span>
</code></pre><pre><code>sudo apt-<span class="hljs-keyword">get</span> install php7<span class="hljs-number">.4</span>-{bcmath,curl,<span class="hljs-type">xml</span>,fpm,gd,intl,mbstring,mysql,zip,soap}
</code></pre>Check php is installed<pre><code><span class="hljs-attribute">php</span> -v
</code></pre></li>
</ul>
<h2 id="heading-install-composer-in-debian">Install composer in Debian</h2>
<ul>
<li>Install curl<pre><code><span class="hljs-attribute">sudo</span> apt install curl
</code></pre></li>
<li>Get composer installer<pre><code><span class="hljs-attribute">curl</span> -sS https://getcomposer.org/installer -o composer-setup.php
</code></pre></li>
<li>Get composer key from here and update below Hash variable https://composer.github.io/pubkeys.html<pre><code><span class="hljs-attribute">HASH</span>=<span class="hljs-number">906</span>a<span class="hljs-number">84</span>df<span class="hljs-number">04</span>cea<span class="hljs-number">2</span>aa<span class="hljs-number">72</span>f<span class="hljs-number">40</span>b<span class="hljs-number">5</span>f<span class="hljs-number">787</span>e<span class="hljs-number">49</span>f<span class="hljs-number">22</span>d<span class="hljs-number">4</span>c<span class="hljs-number">2</span>f<span class="hljs-number">19492</span>ac<span class="hljs-number">310</span>e<span class="hljs-number">8</span>cba<span class="hljs-number">5</span>b<span class="hljs-number">96</span>ac<span class="hljs-number">8</span>b<span class="hljs-number">64115</span>ac<span class="hljs-number">402</span>c<span class="hljs-number">8</span>cd<span class="hljs-number">292</span>b<span class="hljs-number">8</span>a<span class="hljs-number">03482574915</span>d<span class="hljs-number">1</span>a<span class="hljs-number">8</span>
</code></pre></li>
<li>Check installer valid<pre><code><span class="hljs-attribute">php</span> -r <span class="hljs-string">"if (hash_file('SHA384', 'composer-setup.php') === '<span class="hljs-variable">$HASH</span>') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"</span>
</code></pre></li>
<li>Install composer<pre><code>sudo php composer<span class="hljs-operator">-</span>setup.php <span class="hljs-operator">-</span><span class="hljs-operator">-</span>version<span class="hljs-operator">=</span><span class="hljs-number">2.1</span><span class="hljs-number">.3</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>install<span class="hljs-operator">-</span>dir<span class="hljs-operator">=</span><span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>local<span class="hljs-operator">/</span>bin <span class="hljs-operator">-</span><span class="hljs-operator">-</span>filename<span class="hljs-operator">=</span>composer
</code></pre>Check installer is installed<pre><code><span class="hljs-attribute">composer</span> -v
</code></pre></li>
</ul>
<h2 id="heading-see-wsl-files">See WSL files</h2>
<ul>
<li>Open your windows file explorer and put below in your search bar. You will see your Debian installation here<pre><code>\\wsl$
</code></pre></li>
</ul>
<h2 id="heading-install-magento-on-docker-desktop">Install magento on docker desktop</h2>
<ul>
<li><a target="_blank" href="https://magepow.com/blog/install-magento-2-on-docker-p1/">Referencing these instructions </a> </li>
<li>Get magento community repository using composer<pre><code>composer create<span class="hljs-operator">-</span>project <span class="hljs-operator">-</span><span class="hljs-operator">-</span>repository<span class="hljs-operator">-</span>url<span class="hljs-operator">=</span>https:<span class="hljs-comment">//repo.magento.com/ magento/project-community-edition</span>
</code></pre></li>
<li>Get magento auth keys<ul>
<li>Following this link <ul>
<li>https://devdocs.magento.com/guides/v2.4/install-gde/prereq/connect-auth.html</li>
</ul>
</li>
<li>Rename auth.json.sample to auth.json and add your public and private keys here</li>
<li>If asks for authentification required again using cli commands. <ul>
<li>Public key = username </li>
<li>Private key = password </li>
</ul>
</li>
</ul>
</li>
<li>Go to your install directory of magento<pre><code>cd project<span class="hljs-operator">-</span>community<span class="hljs-operator">-</span>edition<span class="hljs-operator">/</span>
</code></pre></li>
<li>Install magento ece tools<pre><code>composer <span class="hljs-built_in">require</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>no<span class="hljs-operator">-</span>update <span class="hljs-operator">-</span><span class="hljs-operator">-</span>dev magento<span class="hljs-operator">/</span>ece<span class="hljs-operator">-</span>tools magento<span class="hljs-operator">/</span>magento<span class="hljs-operator">-</span>cloud<span class="hljs-operator">-</span>docker
</code></pre></li>
<li>Add .magento.docker.yml file to your repository<ul>
<li>Check requirements https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html</li>
<li>Add below code to .magento.docker.yml file (Make sure this is formatted properly)<pre><code><span class="hljs-attribute">name</span>: magento
<span class="hljs-attribute">system</span>:
<span class="hljs-attribute">mode</span>: <span class="hljs-string">'production'</span>
<span class="hljs-attribute">services</span>:
<span class="hljs-attribute">php</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'7.4'</span>
  <span class="hljs-attribute">extensions</span>:
      <span class="hljs-attribute">enabled</span>:
          - xsl
          - json
          - redis
<span class="hljs-attribute">mysql</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'10.4'</span>
  <span class="hljs-attribute">image</span>: <span class="hljs-string">'mariadb'</span>
<span class="hljs-attribute">redis</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'6.0'</span>
  <span class="hljs-attribute">image</span>: <span class="hljs-string">'redis'</span>
<span class="hljs-attribute">elasticsearch</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'7.9'</span>
  <span class="hljs-attribute">image</span>: <span class="hljs-string">'magento/magento-cloud-docker-elasticsearch'</span>
<span class="hljs-attribute">hooks</span>:
<span class="hljs-attribute">build</span>: |
  set -e
  php ./vendor/bin/ece-tools run scenario/build/generate.xml
  php ./vendor/bin/ece-tools run scenario/build/transfer.xml
<span class="hljs-attribute">deploy</span>: <span class="hljs-string">'php ./vendor/bin/ece-tools run scenario/deploy.xml'</span>
<span class="hljs-attribute">post_deploy</span>: <span class="hljs-string">'php ./vendor/bin/ece-tools run scenario/post-deploy.xml'</span>
<span class="hljs-attribute">mounts</span>:
<span class="hljs-attribute">var</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'var'</span>
<span class="hljs-attribute">app-etc</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'app/etc'</span>
<span class="hljs-attribute">pub-media</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'pub/media'</span>
<span class="hljs-attribute">pub-static</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'pub/static'</span>
</code></pre></li>
</ul>
</li>
<li>Run install script (this may error, just continue installing)<pre><code><span class="hljs-attribute">curl</span> -sL https://github.com/magento/magento-cloud-docker/releases/download/<span class="hljs-number">1</span>.<span class="hljs-number">2</span>.<span class="hljs-number">3</span>/init-docker.sh | bash -s -- --php <span class="hljs-number">7</span>.<span class="hljs-number">4</span>
</code></pre><ul>
<li>If you get this error<pre><code>Unable to find image <span class="hljs-string">'magento/magento-cloud-docker-php:7.4-cli-1.1'</span> locally docker: <span class="hljs-built_in">Error</span> response <span class="hljs-keyword">from</span> daemon: Get <span class="hljs-string">"https://registry-1.docker.io/v2/"</span>: net<span class="hljs-operator">/</span>http: request canceled <span class="hljs-keyword">while</span> waiting <span class="hljs-keyword">for</span> connection (Client.Timeout exceeded <span class="hljs-keyword">while</span> awaiting headers).
</code></pre><ul>
<li>Look at these links, this will help<ul>
<li>https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6#file-fix-wsl2-dns-resolution</li>
<li>https://stackoverflow.com/questions/59360629/docker-windows-timeout<ul>
<li>This was my fix - commented out the registry one seems to work now</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Deploy your magento installation (run all at once or remove the &amp;&amp; if you want to run one at a time)<pre><code>composer update <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
docker volume create <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name<span class="hljs-operator">=</span>magento<span class="hljs-operator">-</span>sync <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker volume create <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name<span class="hljs-operator">=</span>mymagento<span class="hljs-operator">-</span>magento<span class="hljs-operator">-</span>sync <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
./vendor<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>ece<span class="hljs-operator">-</span>docker build:compose <span class="hljs-operator">-</span><span class="hljs-operator">-</span>mode<span class="hljs-operator">=</span><span class="hljs-string">"developer"</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>with<span class="hljs-operator">-</span>cron <span class="hljs-operator">-</span><span class="hljs-operator">-</span>expose<span class="hljs-operator">-</span>db<span class="hljs-operator">-</span>port<span class="hljs-operator">=</span><span class="hljs-number">3306</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>no<span class="hljs-operator">-</span>tls <span class="hljs-operator">-</span><span class="hljs-operator">-</span>host<span class="hljs-operator">=</span>magento2.docker <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose up <span class="hljs-operator">-</span>d <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy php ./vendor<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>ece<span class="hljs-operator">-</span>patches apply <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_adminhtml <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_frontend <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>unsecure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//magento2.docker/ &amp;&amp; </span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//magento2.docker/ &amp;&amp; </span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer
</code></pre></li>
</ul>
<p>If you have any errors try redeploy few times</p>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_adminhtml <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_frontend <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>unsecure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//magento2.docker/ &amp;&amp; </span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//magento2.docker/ &amp;&amp; </span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer
</code></pre><ul>
<li><p>If errors on deploy, run cloud-deploy again until it works, this is just initially needs a few deploys</p>
<pre><code><span class="hljs-keyword">Call</span> <span class="hljs-keyword">to</span> undefined method Magento\Eav\Api\<span class="hljs-keyword">Data</span>\AttributeExtension::setIsPagebuilderEnabled()<span class="hljs-comment">#0 /app/vendor/magento/framework/Interception/Interceptor.php(146): Magento\</span>
PageBuilder\<span class="hljs-keyword">Plugin</span>\<span class="hljs-keyword">Catalog</span>\<span class="hljs-keyword">Model</span>\Product\<span class="hljs-keyword">Attribute</span>\RepositoryPlugin-&gt;afterGet(<span class="hljs-keyword">Object</span>(Magento\<span class="hljs-keyword">Catalog</span>\<span class="hljs-keyword">Model</span>\Product\<span class="hljs-keyword">Attribute</span>\Repository\Interceptor), <span class="hljs-keyword">Object</span>(Magento\Ca
talog\<span class="hljs-keyword">Model</span>\ResourceModel\Eav\<span class="hljs-keyword">Attribute</span>\Interceptor), <span class="hljs-string">'sku'</span>)
</code></pre><pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy
</code></pre></li>
<li><p>Set your URL to magento instance and https off because its local</p>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_adminhtml <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_frontend <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>unsecure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//magento2.docker/ &amp;&amp; </span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//magento2.docker/ &amp;&amp; </span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer
</code></pre></li>
<li><p>Set varnish</p>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set system<span class="hljs-operator">/</span>full_page_cache<span class="hljs-operator">/</span>caching_application <span class="hljs-number">2</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>lock<span class="hljs-operator">-</span>env <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command setup:config:set <span class="hljs-operator">-</span><span class="hljs-operator">-</span>http<span class="hljs-operator">-</span>cache<span class="hljs-operator">-</span>hosts<span class="hljs-operator">=</span>varnish <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>post<span class="hljs-operator">-</span>deploy <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command cache:clean
</code></pre></li>
<li><p>Add localhost ip to your windows host file</p>
<ul>
<li>Go to C:\Windows\System32\drivers\etc and open hosts file and add<pre><code>127<span class="hljs-selector-class">.0</span><span class="hljs-selector-class">.0</span><span class="hljs-selector-class">.1</span> <span class="hljs-selector-tag">magento2</span><span class="hljs-selector-class">.docker</span>
</code></pre></li>
</ul>
</li>
<li><p>Disable vernish as it was loading https </p>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set system<span class="hljs-operator">/</span>full_page_cache<span class="hljs-operator">/</span>caching_application <span class="hljs-number">0</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>lock<span class="hljs-operator">-</span>env
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command cache:flush
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command cache:clean
</code></pre></li>
<li><p>This should load a blank magento luma theme site!
http://magento2.docker/</p>
</li>
<li><p>To create an admin user run below, add your variables first.</p>
<pre><code>docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command admin:user:create <span class="hljs-operator">-</span><span class="hljs-operator">-</span>admin<span class="hljs-operator">-</span>user<span class="hljs-operator">=</span><span class="hljs-operator">&lt;</span>ADD_USER<span class="hljs-operator">&gt;</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>admin<span class="hljs-operator">-</span>password<span class="hljs-operator">=</span><span class="hljs-operator">&lt;</span>ADD_PASSWORD<span class="hljs-operator">&gt;</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>admin<span class="hljs-operator">-</span>email<span class="hljs-operator">=</span><span class="hljs-operator">&lt;</span>ADD_EMAIL<span class="hljs-operator">&gt;</span>@gmail.com <span class="hljs-operator">-</span><span class="hljs-operator">-</span>admin<span class="hljs-operator">-</span>firstname<span class="hljs-operator">=</span>Az <span class="hljs-operator">-</span><span class="hljs-operator">-</span>admin<span class="hljs-operator">-</span>lastname<span class="hljs-operator">=</span>Codez
</code></pre></li>
</ul>
<h2 id="heading-credits">Credits</h2>
<ul>
<li>Windows Image https://www.pngkit.com/view/u2q8a9o0u2o0y3t4_upgrade-gobierno-open-business-logo-windows-10-home/</li>
<li>Docker image https://mobile.twitter.com/docker</li>
<li>Magento 2 logo https://en.wikipedia.org/wiki/Magento</li>
<li>https://docs.docker.com/</li>
<li>https://devdocs.magento.com/</li>
<li>https://www.adobe.com/</li>
<li>https://www.debian.org/</li>
</ul>
<p>Feel free to comment questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Install Magento 2.4.3 Community on AWS EC2 (Debian 10)]]></title><description><![CDATA[First Calculate your costs

https://calculator.aws/#/createCalculator/EC2
Below we are using
US East (N.Virginia)
t2.medium
10gb storage 
Which should cost only $34.87USD on demand OR $21.95USD if you are using EC2 Savings Plan



Sign up or in to AW...]]></description><link>https://blog.azcodez.com/install-magento-243-community-on-aws-ec2-debian-10</link><guid isPermaLink="true">https://blog.azcodez.com/install-magento-243-community-on-aws-ec2-debian-10</guid><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[PHP]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sun, 28 Nov 2021 12:46:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1638097782360/F094bT_t5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-first-calculate-your-costs">First Calculate your costs</h1>
<ul>
<li>https://calculator.aws/#/createCalculator/EC2</li>
<li>Below we are using<ul>
<li>US East (N.Virginia)</li>
<li>t2.medium</li>
<li>10gb storage </li>
<li>Which should cost only $34.87USD on demand OR $21.95USD if you are using EC2 Savings Plan</li>
</ul>
</li>
</ul>
<h1 id="heading-sign-up-or-in-to-aws-console">Sign up or in to AWS Console</h1>
<ul>
<li>Select EC2</li>
<li>Launch Instances</li>
<li>Search Debian </li>
<li>Choose Debian 10 (HVM), SSD Volume Type </li>
<li>Select Choose an Instance Type = t2.medium</li>
<li>Next Configure Instance Details</li>
<li>Next Add storage
 -Use minimum 10gb</li>
<li>Add tag if you want</li>
<li>Configure Security Group add following<ul>
<li>SSH = Open to IPs you want to ssh to</li>
<li>HTTP = Anywhere</li>
<li>HTTPS = Anywhere</li>
</ul>
</li>
<li>Review and Launch</li>
<li>Launch<ul>
<li>Create a new key pair OR use exising one if you want</li>
</ul>
</li>
</ul>
<h1 id="heading-add-static-ip-to-ec2-if-you-prefer-to-keep-same-ip-address">Add Static IP to EC2 if you prefer to keep same IP address</h1>
<ul>
<li>See <a target="_blank" href="https://aws.amazon.com/premiumsupport/knowledge-center/ec2-associate-static-public-ip/">this Link</a> on how to setup a Elastic IP to your VM</li>
</ul>
<h1 id="heading-ssh-into-vm">SSH into VM</h1>
<ul>
<li>I am using WSL2 on windows and VScode for this</li>
<li>Add your .pem key to ~/.ssh folder</li>
<li>SSH using a VSCode Terminal connected to WSL2<pre><code>ssh <span class="hljs-operator">-</span>i <span class="hljs-operator">~</span><span class="hljs-operator">/</span>.ssh/<span class="hljs-operator">&lt;</span>SSH_KEY_NAME<span class="hljs-operator">&gt;</span>.pem admin@<span class="hljs-operator">&lt;</span>PUBLIC_IP_OR_DNS_OF_AWS_EC2_SERVER<span class="hljs-operator">&gt;</span>
</code></pre></li>
</ul>
<h1 id="heading-install-docker">Install Docker</h1>
<ul>
<li>Below install steps from this <a target="_blank" href="https://docs.docker.com/engine/install/debian/">link</a> with slight modifications on commands</li>
<li>Set up the repository</li>
<li>Update the apt package index and install packages to allow apt to use a repository over HTTPS:<pre><code>sudo apt-<span class="hljs-keyword">get</span> <span class="hljs-keyword">update</span>
sudo apt-<span class="hljs-keyword">get</span> install \
  ca-certificates \
  curl \
  gnupg \
  lsb-<span class="hljs-keyword">release</span>
</code></pre></li>
<li>Add Docker’s official GPG key:<pre><code>curl -fsSL <span class="hljs-symbol">https:</span>/<span class="hljs-regexp">/download.docker.com/linux</span><span class="hljs-regexp">/debian/gpg</span> <span class="hljs-params">| sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg</span>
</code></pre></li>
<li>Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.<pre><code>echo \
<span class="hljs-string">"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable"</span> <span class="hljs-operator">|</span> sudo tee <span class="hljs-operator">/</span>etc<span class="hljs-operator">/</span>apt<span class="hljs-operator">/</span>sources.list.d/docker.list <span class="hljs-operator">&gt;</span> <span class="hljs-operator">/</span>dev<span class="hljs-operator">/</span>null
</code></pre></li>
<li>Install Docker Engine</li>
<li>This procedure works for Debian on x86_64 / amd64, armhf, arm64, and Raspbian.</li>
<li>Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:<pre><code>sudo apt<span class="hljs-operator">-</span>get update
sudo apt<span class="hljs-operator">-</span>get install docker<span class="hljs-operator">-</span>ce docker<span class="hljs-operator">-</span>ce<span class="hljs-operator">-</span>cli containerd.io
</code></pre><pre><code>sudo service docker <span class="hljs-keyword">start</span>
</code></pre></li>
<li>Make docker be able to run by non sudo user<pre><code>sudo usermod <span class="hljs-operator">-</span>a <span class="hljs-operator">-</span>G docker admin
</code></pre></li>
<li>Reboot server<pre><code><span class="hljs-attribute">sudo</span> reboot
</code></pre></li>
<li>Check whether can run docker with normal user<pre><code><span class="hljs-attribute">docker</span> <span class="hljs-literal">info</span>
</code></pre></li>
<li>Install docker compose as we are going to build docker with docker-compose.yml<pre><code><span class="hljs-attribute">sudo</span> apt install docker-compose
</code></pre></li>
</ul>
<h1 id="heading-go-to-install-directory">Go to install directory</h1>
<ul>
<li>Go to directory to install. This directory is already created with permissions already to add your whatever you need<pre><code>cd <span class="hljs-operator">/</span>home<span class="hljs-operator">/</span>admin<span class="hljs-operator">/</span>
</code></pre></li>
</ul>
<h1 id="heading-install-php74">Install php7.4</h1>
<ul>
<li>Update apt<pre><code>sudo apt <span class="hljs-keyword">update</span>
</code></pre></li>
<li>Install wget<pre><code><span class="hljs-attribute">sudo</span> apt install wget
</code></pre></li>
<li>Install dependancies<pre><code>sudo apt install software<span class="hljs-operator">-</span>properties<span class="hljs-operator">-</span>common ca<span class="hljs-operator">-</span>certificates lsb<span class="hljs-operator">-</span>release apt<span class="hljs-operator">-</span>transport<span class="hljs-operator">-</span>https
</code></pre></li>
<li>Enable SURY repo<pre><code>sudo sh -<span class="hljs-built_in">c</span> 'echo <span class="hljs-string">"deb https://packages.sury.org/php/ $(lsb_release -sc) main"</span> &gt; /etc/apt/sources.list.d/php.list'
</code></pre></li>
<li>Install gnupg<pre><code>sudo apt<span class="hljs-operator">-</span>get update <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> apt<span class="hljs-operator">-</span>get install <span class="hljs-operator">-</span>y gnupg
</code></pre></li>
<li>Import the GPG key for the repository<pre><code>wget <span class="hljs-operator">-</span>qO <span class="hljs-operator">-</span> https:<span class="hljs-comment">//packages.sury.org/php/apt.gpg | sudo apt-key add -</span>
</code></pre></li>
<li>Installing PHP7.4<pre><code>sudo apt <span class="hljs-keyword">update</span>
sudo apt <span class="hljs-keyword">install</span> php7<span class="hljs-number">.4</span> 
sudo apt-<span class="hljs-keyword">get</span> <span class="hljs-keyword">install</span> php7<span class="hljs-number">.4</span>-{bcmath,curl,<span class="hljs-keyword">xml</span>,fpm,gd,intl,mbstring,mysql,zip,soap}
</code></pre></li>
<li>Check php is installed<pre><code><span class="hljs-attribute">php</span> -v
</code></pre></li>
<li>Should look like this
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1638029604023/F_Qmd6Y_4.png" alt="image.png" /></li>
</ul>
<h1 id="heading-install-composer-in-debian">Install composer in Debian</h1>
<ul>
<li>Install curl<pre><code><span class="hljs-attribute">sudo</span> apt install curl
</code></pre></li>
<li>Get composer installer<pre><code><span class="hljs-attribute">curl</span> -sS https://getcomposer.org/installer -o composer-setup.php
</code></pre></li>
<li>Get composer key from here and update below Hash variable https://composer.github.io/pubkeys.html<pre><code><span class="hljs-attribute">HASH</span>=<span class="hljs-number">906</span>a<span class="hljs-number">84</span>df<span class="hljs-number">04</span>cea<span class="hljs-number">2</span>aa<span class="hljs-number">72</span>f<span class="hljs-number">40</span>b<span class="hljs-number">5</span>f<span class="hljs-number">787</span>e<span class="hljs-number">49</span>f<span class="hljs-number">22</span>d<span class="hljs-number">4</span>c<span class="hljs-number">2</span>f<span class="hljs-number">19492</span>ac<span class="hljs-number">310</span>e<span class="hljs-number">8</span>cba<span class="hljs-number">5</span>b<span class="hljs-number">96</span>ac<span class="hljs-number">8</span>b<span class="hljs-number">64115</span>ac<span class="hljs-number">402</span>c<span class="hljs-number">8</span>cd<span class="hljs-number">292</span>b<span class="hljs-number">8</span>a<span class="hljs-number">03482574915</span>d<span class="hljs-number">1</span>a<span class="hljs-number">8</span>
</code></pre></li>
<li>Check installer valid<pre><code><span class="hljs-attribute">php</span> -r <span class="hljs-string">"if (hash_file('SHA384', 'composer-setup.php') === '<span class="hljs-variable">$HASH</span>') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"</span>
</code></pre></li>
<li>Install composer<pre><code>sudo php composer<span class="hljs-operator">-</span>setup.php <span class="hljs-operator">-</span><span class="hljs-operator">-</span>version<span class="hljs-operator">=</span><span class="hljs-number">2.1</span><span class="hljs-number">.3</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>install<span class="hljs-operator">-</span>dir<span class="hljs-operator">=</span><span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>local<span class="hljs-operator">/</span>bin <span class="hljs-operator">-</span><span class="hljs-operator">-</span>filename<span class="hljs-operator">=</span>composer
</code></pre></li>
<li>Check installer is installed<pre><code><span class="hljs-attribute">composer</span> -v
</code></pre></li>
</ul>
<h1 id="heading-uninstall-apache">Uninstall apache</h1>
<ul>
<li>Instructions from <a target="_blank" href="https://www.codegrepper.com/code-examples/shell/debian+10+uninstall+apache2+safe+%3F">this link</a>   </li>
<li>stop the apache2 service <pre><code>sudo service apache2 <span class="hljs-keyword">stop</span>
sudo systemctl <span class="hljs-keyword">stop</span> apache2
</code></pre></li>
<li>Remove apache2 packages<pre><code><span class="hljs-attribute">sudo</span> apt-get purge apache<span class="hljs-number">2</span> apache<span class="hljs-number">2</span>-utils apache<span class="hljs-number">2</span>-bin apache<span class="hljs-number">2</span>.<span class="hljs-number">2</span>-common
</code></pre></li>
<li>Cleanup<pre><code>sudo apt-<span class="hljs-keyword">get</span> autoremove
</code></pre></li>
<li>Check if the apache has been removed, the following command line should return a blank line<pre><code><span class="hljs-built_in">which</span> apache2
</code></pre></li>
</ul>
<h1 id="heading-install-fresh-magento-243-community-edition">Install fresh Magento 2.4.3 community edition</h1>
<ul>
<li>Get repo<pre><code>composer create<span class="hljs-operator">-</span>project <span class="hljs-operator">-</span><span class="hljs-operator">-</span>repository<span class="hljs-operator">-</span>url<span class="hljs-operator">=</span>https:<span class="hljs-comment">//repo.magento.com/ magento/project-community-edition</span>
</code></pre></li>
<li>When it asks you for auth keys, get them from these instructions and store them <ul>
<li>https://devdocs.magento.com/guides/v2.4/install-gde/prereq/connect-auth.html</li>
</ul>
</li>
<li>Go to directory<pre><code>cd project<span class="hljs-operator">-</span>community<span class="hljs-operator">-</span>edition
</code></pre></li>
<li>Run composer require<pre><code>composer <span class="hljs-built_in">require</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>no<span class="hljs-operator">-</span>update <span class="hljs-operator">-</span><span class="hljs-operator">-</span>dev magento<span class="hljs-operator">/</span>ece<span class="hljs-operator">-</span>tools magento<span class="hljs-operator">/</span>magento<span class="hljs-operator">-</span>cloud<span class="hljs-operator">-</span>docker
</code></pre></li>
<li>Create a .magento.docker.yml file<pre><code><span class="hljs-selector-tag">nano</span> <span class="hljs-selector-class">.magento</span><span class="hljs-selector-class">.docker</span><span class="hljs-selector-class">.yml</span>
</code></pre></li>
<li>Add below, make sure you format yml correctly<pre><code><span class="hljs-attribute">name</span>: magento
<span class="hljs-attribute">system</span>:
<span class="hljs-attribute">mode</span>: <span class="hljs-string">'production'</span>
<span class="hljs-attribute">services</span>:
<span class="hljs-attribute">php</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'7.4'</span>
  <span class="hljs-attribute">extensions</span>:
      <span class="hljs-attribute">enabled</span>:
          - xsl
          - json
          - redis
<span class="hljs-attribute">mysql</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'10.4'</span>
  <span class="hljs-attribute">image</span>: <span class="hljs-string">'mariadb'</span>
<span class="hljs-attribute">redis</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'6.0'</span>
  <span class="hljs-attribute">image</span>: <span class="hljs-string">'redis'</span>
<span class="hljs-attribute">elasticsearch</span>:
  <span class="hljs-attribute">version</span>: <span class="hljs-string">'7.9'</span>
  <span class="hljs-attribute">image</span>: <span class="hljs-string">'magento/magento-cloud-docker-elasticsearch'</span>
<span class="hljs-attribute">hooks</span>:
<span class="hljs-attribute">build</span>: |
  set -e
  php ./vendor/bin/ece-tools run scenario/build/generate.xml
  php ./vendor/bin/ece-tools run scenario/build/transfer.xml
<span class="hljs-attribute">deploy</span>: <span class="hljs-string">'php ./vendor/bin/ece-tools run scenario/deploy.xml'</span>
<span class="hljs-attribute">post_deploy</span>: <span class="hljs-string">'php ./vendor/bin/ece-tools run scenario/post-deploy.xml'</span>
<span class="hljs-attribute">mounts</span>:
<span class="hljs-attribute">var</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'var'</span>
<span class="hljs-attribute">app-etc</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'app/etc'</span>
<span class="hljs-attribute">pub-media</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'pub/media'</span>
<span class="hljs-attribute">pub-static</span>:
  <span class="hljs-attribute">path</span>: <span class="hljs-string">'pub/static'</span>
</code></pre></li>
<li>Run install  (This may error, but ignore it)<pre><code><span class="hljs-attribute">curl</span> -sL https://github.com/magento/magento-cloud-docker/releases/download/<span class="hljs-number">1</span>.<span class="hljs-number">2</span>.<span class="hljs-number">3</span>/init-docker.sh | bash -s -- --php <span class="hljs-number">7</span>.<span class="hljs-number">4</span>
</code></pre><ul>
<li>Dont worry about this error<pre><code>Installing dependencies (including require-dev) <span class="hljs-keyword">from</span> <span class="hljs-keyword">lock</span> file
<span class="hljs-built_in">Warning</span>: The <span class="hljs-keyword">lock</span> file <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> up <span class="hljs-keyword">to</span> <span class="hljs-type">date</span> <span class="hljs-keyword">with</span> the latest changes <span class="hljs-keyword">in</span> composer.json. You may be getting outdated dependencies. It <span class="hljs-keyword">is</span> recommended that you run `composer <span class="hljs-keyword">update</span>` <span class="hljs-keyword">or</span> `composer <span class="hljs-keyword">update</span> &lt;package <span class="hljs-type">name</span>&gt;`.
Your requirements could <span class="hljs-keyword">not</span> be resolved <span class="hljs-keyword">to</span> an installable <span class="hljs-keyword">set</span> <span class="hljs-keyword">of</span> packages.
</code></pre></li>
</ul>
</li>
<li><a target="_blank" href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-register.html">Get a domain name from AWS R53</a>  or whereever you prefer</li>
<li>Build dockers and install<pre><code>composer update
docker volume create <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name<span class="hljs-operator">=</span>magento<span class="hljs-operator">-</span>sync
docker volume create <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name<span class="hljs-operator">=</span>mymagento<span class="hljs-operator">-</span>magento<span class="hljs-operator">-</span>sync
./vendor<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>ece<span class="hljs-operator">-</span>docker build:compose <span class="hljs-operator">-</span><span class="hljs-operator">-</span>mode<span class="hljs-operator">=</span><span class="hljs-string">"developer"</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>with<span class="hljs-operator">-</span>cron <span class="hljs-operator">-</span><span class="hljs-operator">-</span>expose<span class="hljs-operator">-</span>db<span class="hljs-operator">-</span>port<span class="hljs-operator">=</span><span class="hljs-number">3306</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>no<span class="hljs-operator">-</span>tls <span class="hljs-operator">-</span><span class="hljs-operator">-</span>host<span class="hljs-operator">=</span><span class="hljs-operator">&lt;</span>ADD_YOUR_HOST<span class="hljs-operator">&gt;</span>.com
docker<span class="hljs-operator">-</span>compose up <span class="hljs-operator">-</span>d
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy php ./vendor<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>ece<span class="hljs-operator">-</span>patches apply
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy  <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-literal">true</span> 
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_adminhtml <span class="hljs-number">0</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>use_in_frontend <span class="hljs-number">0</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>unsecure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//&lt;ADD_YOUR_HOST&gt;.com/</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command config:set web<span class="hljs-operator">/</span>secure<span class="hljs-operator">/</span>base_url http:<span class="hljs-comment">//&lt;ADD_YOUR_HOST&gt;.com/</span>
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy cloud<span class="hljs-operator">-</span>deploy
docker<span class="hljs-operator">-</span>compose run <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm deploy magento<span class="hljs-operator">-</span>command deploy:mode:set developer
</code></pre></li>
<li><p>Point your domain at your EC2 at EC2 resource using Route53 point at resource or get Public IP of your EC2 and forward your domain to that IP</p>
</li>
<li><p>Load your shop <code>http://&lt;ADD_YOUR_HOST&gt;.com/</code></p>
</li>
<li><p>This site is setup as dev environment at the moment. If going into production you need to switch site to production mode and check security settings</p>
</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li>Docker image https://mobile.twitter.com/docker</li>
<li>AWS EC2 Image https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fdev.to%2Faziz_amghar%2Fall-you-need-to-know-about-ec2-instance-55na&amp;psig=AOvVaw2-8_PE61VZ-QhdiAJG2BmZ&amp;ust=1638118229172000&amp;source=images&amp;cd=vfe&amp;ved=0CAsQjRxqFwoTCNiAk5qAufQCFQAAAAAdAAAAABAI</li>
<li>Magento 2 logo https://en.wikipedia.org/wiki/Magento</li>
<li>https://calculator.aws/#/createCalculator/EC2</li>
<li>https://docs.docker.com/engine/install/debian/</li>
<li>https://www.codegrepper.com/code-examples/shell/debian+10+uninstall+apache2+safe+%3F</li>
<li>https://devdocs.magento.com/</li>
<li>https://www.adobe.com/</li>
<li>https://aws.amazon.com/</li>
</ul>
<p>Feel free to comment questions or feedback✌️</p>
<p>Happy coding,</p>
<p>Az 👨🏾‍💻</p>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Magento 2 - Creating an observer]]></title><description><![CDATA[In Magento 2 (Adobe Commerce) observers are events that are already setup thoughout the whole ecommerce eco-system. 
This is a great way to customise magento. Just find an event that happens and put your custom code in after it. 
Firstly view all obs...]]></description><link>https://blog.azcodez.com/magento-2-creating-an-observer</link><guid isPermaLink="true">https://blog.azcodez.com/magento-2-creating-an-observer</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Thu, 25 Nov 2021 20:29:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636822718193/LUGwlBxpnX.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Magento 2 (Adobe Commerce) observers are events that are already setup thoughout the whole ecommerce eco-system. </p>
<p>This is a great way to customise magento. Just find an event that happens and put your custom code in after it. </p>
<p>Firstly view all observers and pick one you want to use all observers are listed in <a target="_blank" href="https://devdocs.magento.com/guides/v2.4/extension-dev-guide/event-list.html">here via Adobe Magento Documentation</a> </p>
<p>Here we will be using checkout_cart_add_product_complete.
This fires when a product has been added to cart.</p>
<ul>
<li><p>If you havent created a custom module please <a target="_blank" href="https://blog.azcodez.com/magento-2-create-a-module-in-magento-2">see my previous blog </a> </p>
</li>
<li><p>Add events.xml file under your custom plugin eg. app\code\AzCodez\MagentoTraining\etc\events.xml</p>
</li>
<li><p>Add xml code as below</p>
<ul>
<li><strong>event name</strong> is the observer we picked to use</li>
<li><strong>instance</strong> is your custom class that you are going to execute after this observer is fired<pre><code><span class="hljs-meta">&lt;?xml version="1.0"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">config</span> <span class="hljs-attr">xmlns:xsi</span>=<span class="hljs-string">"http://www.w3.org/2001/XMLSchema-instance"</span> <span class="hljs-attr">xsi:noNamespaceSchemaLocation</span>=<span class="hljs-string">"urn:magento:framework:Event/etc/events.xsd"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">event</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"controller_action_predispatch"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">observer</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"magento_training_test"</span> <span class="hljs-attr">instance</span>=<span class="hljs-string">"AzCodez\MagentoTraining\Observer\Log"</span> <span class="hljs-attr">shared</span>=<span class="hljs-string">"false"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">event</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">config</span>&gt;</span>
</code></pre></li>
</ul>
</li>
<li><p>Add php observer class, this fires when observer is fired</p>
<ul>
<li>eg. magento2\app\code\AzCodez\MagentoTraining\Observer\Log.php</li>
</ul>
</li>
<li><p>Add below php code to this file </p>
<ul>
<li>This code just logs a message to the system.log file</li>
<li>Modify namespace to suit your's</li>
</ul>
</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>
<span class="hljs-comment">/**
 * Observer Test
 * 
 */</span>
<span class="hljs-keyword">namespace</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Observer</span>;

<span class="hljs-keyword">use</span> <span class="hljs-title">Psr</span>\<span class="hljs-title">Log</span>\<span class="hljs-title">LoggerInterface</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">Event</span>\<span class="hljs-title">Observer</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Log</span> <span class="hljs-keyword">implements</span> \<span class="hljs-title">Magento</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">Event</span>\<span class="hljs-title">ObserverInterface</span>
</span>{
     <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> LoggerInterface
     */</span>
     <span class="hljs-keyword">protected</span> $logger;

     <span class="hljs-comment">/**
     * Dependency Constructor
     * <span class="hljs-doctag">@param</span> LoggerInterface $logger
     */</span>
     <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">construct</span>(<span class="hljs-params">
         LoggerInterface $logger
        </span>)
     </span>{
        <span class="hljs-keyword">$this</span>-&gt;logger = $logger;
     }

     <span class="hljs-comment">/**
     * <span class="hljs-doctag">@param</span> Observer $observer
     */</span>
     <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">execute</span>(<span class="hljs-params">Observer $observer</span>) 
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;logger-&gt;debug(<span class="hljs-string">"test"</span>);
     }
}
</code></pre><p>Hard Deploy Magento</p>
<pre><code>rm -rf generated<span class="hljs-regexp">/code/</span>* &amp;&amp; 
rm -rf pub<span class="hljs-regexp">/static/frontend/</span>* &amp;&amp; 
rm -rf pub<span class="hljs-regexp">/static/adminhtml/</span>* &amp;&amp; 
docker-compose run --rm deploy magento-command setup:upgrade &amp;&amp; 
docker-compose run --rm deploy magento-command setup:di:compile &amp;&amp; 
docker-compose run --rm deploy cloud-deploy &amp;&amp; 
docker-compose run --rm deploy magento-command cache:clean &amp;&amp; 
docker-compose run --rm deploy magento-command cache:flush
</code></pre><p>Add product to cart and see if you get a log line in system.log</p>
<p>Hope this was helpful,
Az 😎</p>
<p>Credits</p>
<ul>
<li>https://devdocs.magento.com/guides/v2.4/extension-dev-guide/events-and-observers.html</li>
<li>https://devdocs.magento.com/guides/v2.4/extension-dev-guide/event-list.html#abstract_search_result_load_after</li>
<li>https://www.mageplaza.com/magento-2-module-development/magento-2-create-events.html</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Create a AWS S3 bucket with Github Actions]]></title><description><![CDATA[Below we are going to run a Github Action that creates a S3 bucket in AWS Cloud
Github workflows have AWS CLI commands built in so all you need to do it run the command  See this link for more information 
Create a  GiHub  account
Create a new reposi...]]></description><link>https://blog.azcodez.com/create-a-aws-s3-bucket-with-github-actions</link><guid isPermaLink="true">https://blog.azcodez.com/create-a-aws-s3-bucket-with-github-actions</guid><category><![CDATA[software development]]></category><category><![CDATA[coding]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[infrastructure]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sat, 06 Nov 2021 13:14:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636284613889/kOZ4alGXi.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below we are going to run a Github Action that creates a S3 bucket in AWS Cloud</p>
<p>Github workflows have AWS CLI commands built in so all you need to do it run the command  <a target="_blank" href="https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners">See this link for more information</a> </p>
<p>Create a  <a target="_blank" href="https://github.com/">GiHub </a> account</p>
<p>Create a new repository</p>
<p>Setup file for workflow</p>
<ul>
<li>Folder named .github</li>
<li>Folder in .github called workflows</li>
<li>Create a file called addS3BucketAWS.yml</li>
<li>See  <a target="_blank" href="https://docs.github.com/en/actions/quickstart">Link for more info</a> </li>
</ul>
<p>Add Below code to workflow file</p>
<ul>
<li>This code is setup only to run when you click action in repository</li>
</ul>
<pre><code><span class="hljs-comment"># This is a basic workflow to help you get started with Actions</span>

<span class="hljs-attr">name:</span> <span class="hljs-string">addS3BucketAWS</span>

<span class="hljs-comment"># Controls when the action will run. </span>
<span class="hljs-attr">on:</span>
  <span class="hljs-comment"># Triggers the workflow on push or pull request events but only for the main branch</span>
  <span class="hljs-comment"># push:</span>
  <span class="hljs-comment">#  branches: [ main ]</span>

  <span class="hljs-comment"># Allows you to run this workflow manually from the Actions tab</span>
  <span class="hljs-attr">workflow_dispatch:</span>

<span class="hljs-comment"># A workflow run is made up of one or more jobs that can run sequentially or in parallel</span>
<span class="hljs-attr">jobs:</span>

  <span class="hljs-comment"># This workflow contains a single job called "build"</span>
  <span class="hljs-attr">build:</span>

   <span class="hljs-comment"># The type of runner that the job will run on</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>

    <span class="hljs-attr">steps:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@master</span>

      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Upload</span> <span class="hljs-string">to</span> <span class="hljs-string">S3</span>
        <span class="hljs-attr">run:</span> <span class="hljs-string">|
          aws s3 mb s3://&lt;ADD BUCKET NAME MAKE SURE IT'S UNIQUE&gt;
</span>        <span class="hljs-attr">env:</span>
          <span class="hljs-attr">AWS_ACCESS_KEY_ID:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_ACCESS_KEY_ID</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_SECRET_ACCESS_KEY:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_SECRET_ACCESS_KEY</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_DEFAULT_REGION:</span> <span class="hljs-string">'eu-west-1'</span>
</code></pre><ul>
<li><p>Change this in your action </p>
<pre><code>&lt;<span class="hljs-keyword">ADD</span> BUCKET <span class="hljs-type">NAME</span> MAKE SURE IT<span class="hljs-string">'S UNIQUE&gt;</span>
</code></pre><ul>
<li>Change it to a unique name. Remember S3 names are publicly chosen. Add a random string to end of your bucket name to make sure its unique eg. I used <code>az-test-bucket-8923yhr98uh</code></li>
</ul>
</li>
<li><p>Create AWS Keys</p>
</li>
<li>Log into your AWS portal</li>
<li>Click your cloud name </li>
<li>Click 'My Security Credentials'
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1636198012667/FZ3bAswSN.png" alt="image.png" /></li>
<li>Click create </li>
<li>Here you will have 2 keys which you will need to add to your repository</li>
</ul>
<p>Add keys to your GitHub Repository</p>
<ul>
<li>Click settings in your repository</li>
<li>Then secrets</li>
<li>Add repository secrets named AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and add relevant keys from your keys created in your AWS Account</li>
</ul>
<p>Commit and push code if you havent already</p>
<p>Run your action</p>
<ul>
<li>In your repo</li>
<li>Click Actions</li>
<li>Select Action to run</li>
<li>Click run workflow</li>
</ul>
<p>If successful you should have a complete success workflow like below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1636204211053/a3lop3Bi0.png" alt="image.png" /></p>
<p>Hope this helped you, if this didn't please comment and I will try help you.</p>
<p>Remember to like, post a comment and share.</p>
<p>Happy Coding 🙂</p>
<p>Asrin 🤙</p>
<p>Want to start a blog on hashnode use this <a target="_blank" href="https://hashnode.com/@azcodez/joinme">link </a> so I get a free shirt. I will assist you with setup 🙂</p>
<p>If this helped you consider buying me a coffee 🙂</p>
<div class="hn-embed-widget" id="buymecoffee"></div><p>Credits</p>
<ul>
<li>https://stackoverflow.com/questions/59166099/github-action-aws-cli</li>
<li>AWS CLI commands https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html#using-s3-commands-managing-buckets-creating</li>
<li>Image https://chillplanet.org/tag/aws/</li>
<li>Image https://www.coletiv.com/blog/android-github-actions-setup/</li>
</ul>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Create new branch with git command line]]></title><description><![CDATA[Say you have made some changes on a branch currently but dont want to put these changes on this branch but instead on a new branch 

First check your current status of your git 
git status

Stash your changes, don't worry they wont be lost
git stash
...]]></description><link>https://blog.azcodez.com/create-new-branch-with-git-command-line</link><guid isPermaLink="true">https://blog.azcodez.com/create-new-branch-with-git-command-line</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Fri, 05 Nov 2021 20:35:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/lK4eXU2E2ww/upload/v1644679218472/88ap0okOA.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Say you have made some changes on a branch currently but dont want to put these changes on this branch but instead on a new branch </p>
<ul>
<li><p>First check your current status of your git </p>
<pre><code><span class="hljs-attribute">git</span> status
</code></pre></li>
<li><p>Stash your changes, don't worry they wont be lost</p>
<pre><code><span class="hljs-attribute">git</span> stash
</code></pre></li>
<li><p>Check your current branch status </p>
<pre><code><span class="hljs-attribute">git</span> branch -a
</code></pre></li>
<li><p>Create a new branch, this will copy from current branch </p>
<pre><code>git branch &lt;<span class="hljs-keyword">ADD</span> YOUR <span class="hljs-built_in">NEW</span> BRANCH <span class="hljs-type">NAME</span>&gt;
</code></pre></li>
<li><p>Check your current branch status, see if your new branch exists</p>
<pre><code><span class="hljs-attribute">git</span> branch -a
</code></pre></li>
<li><p>Switch to this new branch </p>
<pre><code>git checkout &lt;<span class="hljs-keyword">ADD</span> YOUR <span class="hljs-built_in">NEW</span> BRANCH <span class="hljs-type">NAME</span>&gt;
</code></pre></li>
<li><p>Check your current branch status</p>
<pre><code><span class="hljs-attribute">git</span> branch -a
</code></pre><p>Your current branch will be green like so</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1636106844282/beXo52fXB.png" alt="image.png" /></p>
<ul>
<li><p>Bring your changes back that you stashed before </p>
<pre><code>git stash <span class="hljs-keyword">pop</span>
</code></pre></li>
<li><p>You will have your changes back now, confirm this by running</p>
<pre><code><span class="hljs-attribute">git</span> status
</code></pre></li>
<li><p>Add all your changes for commit by running</p>
<pre><code>git <span class="hljs-keyword">add</span> .
</code></pre></li>
<li><p>Add a commit message</p>
<pre><code>git <span class="hljs-keyword">commit</span> -m "&lt;ADD YOUR COMMIT MESSAGE&gt;"
</code></pre></li>
<li><p>Push your changes, setting the new branch to root of your directory</p>
<pre><code>git push <span class="hljs-operator">-</span><span class="hljs-operator">-</span>set<span class="hljs-operator">-</span>upstream origin <span class="hljs-operator">&lt;</span>ADD YOUR NEW BRANCH NAME<span class="hljs-operator">&gt;</span>
</code></pre></li>
<li><p>Your changes will now be on your remote branch</p>
</li>
</ul>
<p>Hope this helped you, if this didn't please comment and I will try help you.</p>
<p>Remember to like, post a comment and share.</p>
<p>Happy Coding 🙂</p>
<p>Asrin 🤙</p>
<h1 id="heading-shameless-plugs">Shameless Plugs</h1>
<ul>
<li><a target="_blank" href="https://magic.freetrade.io/join/asrin/447192e9">Join me and invest commission-free with Freetrade. Get started with a free share worth £3-£200.</a></li>
<li><a target="_blank" href="https://hashnode.com/@azcodez/joinme">Start a blog on Hashnode</a></li>
<li><a target="_blank" href="https://wise.com/invite/ath/asrind">Transfer money internationally with Wise</a></li>
<li><a target="_blank" href="https://coinbase.com/join/dayana_m40?src=android-link">Join coinbase with my and you will earn some free crypto as well</a></li>
</ul>
<p>If this helped you consider buying me a coffee 🙂</p>
<div class="hn-embed-widget" id="buymecoffee"></div><div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Sync AWS S3 Bucket on Git Push using GitHub Actions]]></title><description><![CDATA[Below we are going to setup a GitHub Action to upload files to a S3 Bucket

If you haven't got an S3 bucket on AWS you can set one up using this  link 

If you want to host your files as a static web server set up instructions are here 



Create a G...]]></description><link>https://blog.azcodez.com/sync-aws-s3-bucket-on-git-push-using-github-actions</link><guid isPermaLink="true">https://blog.azcodez.com/sync-aws-s3-bucket-on-git-push-using-github-actions</guid><category><![CDATA[Devops]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[AWS]]></category><category><![CDATA[GitHub]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Wed, 03 Nov 2021 19:18:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/U_BhfVLRKF4/upload/v1644679148762/zIAdgm6wa.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below we are going to setup a GitHub Action to upload files to a S3 Bucket</p>
<ul>
<li><p>If you haven't got an S3 bucket on AWS you can set one up using this  <a target="_blank" href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html">link</a> </p>
</li>
<li><p>If you want to host your files as a static web server set up instructions are <a target="_blank" href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html">here</a> </p>
</li>
</ul>
<ul>
<li><p>Create a GitHub Reposiory</p>
<ul>
<li>https://github.com/</li>
</ul>
</li>
<li><p>Add a github action workflow folder and file in repository</p>
<ul>
<li>Path should look like this /.github/workflows/.yml</li>
</ul>
</li>
<li><p>Add this code to the yml file</p>
</li>
</ul>
<pre><code><span class="hljs-comment"># This is a basic workflow to help you get started with Actions</span>

<span class="hljs-attr">name:</span> <span class="hljs-string">SyncToS3</span>

<span class="hljs-comment"># Controls when the action will run. </span>
<span class="hljs-attr">on:</span>
  <span class="hljs-comment"># Triggers the workflow on push or pull request events but only for the main branch</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span> [ <span class="hljs-string">main</span> ]

  <span class="hljs-comment"># Allows you to run this workflow manually from the Actions tab</span>
  <span class="hljs-attr">workflow_dispatch:</span>

<span class="hljs-comment"># A workflow run is made up of one or more jobs that can run sequentially or in parallel</span>
<span class="hljs-attr">jobs:</span>
  <span class="hljs-comment"># This workflow contains a single job called "build"</span>
  <span class="hljs-attr">build:</span>
    <span class="hljs-comment"># The type of runner that the job will run on</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
    <span class="hljs-comment"># https://github.com/marketplace/actions/s3-sync </span>
    <span class="hljs-attr">steps:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@master</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">jakejarvis/s3-sync-action@master</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">args:</span> <span class="hljs-string">--acl</span> <span class="hljs-string">public-read</span> <span class="hljs-string">--follow-symlinks</span> <span class="hljs-string">--delete</span> <span class="hljs-string">--exclude</span> <span class="hljs-string">'.git/*'</span> <span class="hljs-string">--exclude</span> <span class="hljs-string">'.github/*'</span>
        <span class="hljs-attr">env:</span>
          <span class="hljs-attr">AWS_S3_BUCKET:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_S3_BUCKET</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_ACCESS_KEY_ID:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_ACCESS_KEY_ID</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_SECRET_ACCESS_KEY:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_SECRET_ACCESS_KEY</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">AWS_REGION:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_REGION</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">SOURCE_DIR:</span> <span class="hljs-string">'./public'</span>
</code></pre><ul>
<li>Create Secrets<ul>
<li>In your reposiory click Settings &gt; Secrets</li>
<li>Add below secrets, this  <a target="_blank" href="https://github.com/marketplace/actions/s3-sync#configuration">link </a> provides what secret should be </li>
</ul>
</li>
</ul>
<pre><code><span class="hljs-attribute">AWS_S3_BUCKET</span> 
AWS_ACCESS_KEY_ID 
AWS_SECRET_ACCESS_KEY 
AWS_REGION
</code></pre><ul>
<li><p>Create a folder in root of your repository called public</p>
<ul>
<li>Add files in this folder</li>
</ul>
</li>
<li><p>Push your changes</p>
<ul>
<li>Check Actions in your repo to see if its building</li>
</ul>
</li>
<li><p>Check your S3 Bucket to see whether files added</p>
</li>
</ul>
<p>Hope this helped you, if this didn't please comment and I will try help you.</p>
<p>Remember to like, post a comment and share.</p>
<p>Happy Coding :)</p>
<p>Asrin</p>
<p>If this helped you consider buying me a coffee :)</p>
<div class="hn-embed-widget" id="buymecoffee"></div><ul>
<li>Credits <ul>
<li>GitHub Action from https://github.com/marketplace/actions/s3-sync </li>
</ul>
</li>
</ul>
<div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[Combine commands to run on Linux (Debian)]]></title><description><![CDATA[Below we are going to add a bunch of commands into a file and run them all at once where you need to. This should help with development time
In your debian instance

Create a file for your commands
nano /bin/new_script

Add some commands to your scri...]]></description><link>https://blog.azcodez.com/combine-commands-to-run-on-linux-debian</link><guid isPermaLink="true">https://blog.azcodez.com/combine-commands-to-run-on-linux-debian</guid><category><![CDATA[Linux]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Sun, 31 Oct 2021 16:11:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/4Mw7nkQDByk/upload/v1644679167760/E8TppdfIs.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below we are going to add a bunch of commands into a file and run them all at once where you need to. This should help with development time</p>
<p>In your debian instance</p>
<ul>
<li><p>Create a file for your commands</p>
<pre><code>nano <span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>new_script
</code></pre></li>
<li><p>Add some commands to your script with &amp;&amp; symbols at end of each command to run after another like example</p>
</li>
<li><p>This is example is Magento 2 Commands when rebuilding code on developer environments</p>
<pre><code><span class="hljs-title">rm</span> -rf generated/code/* &amp;&amp; 
<span class="hljs-title">rm</span> -rf pub/static/frontend/* &amp;&amp; 
<span class="hljs-title">rm</span> -rf pub/static/adminhtml/* &amp;&amp; 
<span class="hljs-title">docker</span>-compose run <span class="hljs-comment">--rm deploy magento-command setup:upgrade &amp;&amp; </span>
<span class="hljs-title">docker</span>-compose run <span class="hljs-comment">--rm deploy magento-command setup:di:compile &amp;&amp; </span>
<span class="hljs-title">docker</span>-compose run <span class="hljs-comment">--rm deploy cloud-deploy &amp;&amp; </span>
<span class="hljs-title">docker</span>-compose run <span class="hljs-comment">--rm deploy magento-command cache:clean &amp;&amp; </span>
<span class="hljs-title">docker</span>-compose run <span class="hljs-comment">--rm deploy magento-command cache:flush</span>
</code></pre></li>
<li><p>Add permissions to file so the script can run anywhere</p>
<pre><code>chmod <span class="hljs-operator">+</span>x <span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>new_script
</code></pre></li>
<li><p>CD into directory you want to run script and run like so</p>
<pre><code>new_script
</code></pre></li>
</ul>
<p>If this didn't please comment and I will try help you.</p>
<p>Remember to like, post a comment and share this blog if this worked for you.</p>
<p>Happy Coding :)</p>
<p>Asrin</p>
<p>If this helped you consider buying me a coffee :)</p>
<div class="hn-embed-widget" id="buymecoffee"></div><div class="hn-embed-widget" id="amazonads"></div>]]></content:encoded></item><item><title><![CDATA[PHPUnit checking method is called once]]></title><description><![CDATA[Below we are going to use PHP Unit to check if a function was called inside a method.

First setup your class that you are going to test. 
This is a simple class with two functions. mainFunction calls secondFunction.

<?php

namespace AzCodez\Magento...]]></description><link>https://blog.azcodez.com/phpunit-checking-method-is-called-once</link><guid isPermaLink="true">https://blog.azcodez.com/phpunit-checking-method-is-called-once</guid><category><![CDATA[PHP]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[coding]]></category><category><![CDATA[Testing]]></category><dc:creator><![CDATA[Asrin Dayananda]]></dc:creator><pubDate>Thu, 28 Oct 2021 20:01:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/7jjnJ-QA9fY/upload/v1644679092012/sSiYXk8UR.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below we are going to use PHP Unit to check if a function was called inside a method.</p>
<ul>
<li>First setup your class that you are going to test. </li>
<li>This is a simple class with two functions. mainFunction calls secondFunction.</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">namespace</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethod</span>
</span>{
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">mainFunction</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">$this</span>-&gt;secondFunction();
    }

    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">secondFunction</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;
    }
}
</code></pre><p>Setup your php unit test</p>
<ul>
<li>First setup basic configuration of calling php unit dependency so we can run tests</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{

}
</code></pre><ul>
<li>Then add real class dependency and setup a variable for it</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">TestOneMethod</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> TestOneMethod
     */</span>
    <span class="hljs-keyword">protected</span> $testOneMethod;

}
</code></pre><ul>
<li>Add a new test funtion with comments for arranging the test, asseting (checking), and calling real class to php unit tests your class</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">TestOneMethod</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> TestOneMethod
     */</span>
    <span class="hljs-keyword">protected</span> $testOneMethod;

    <span class="hljs-comment">/**
     * 
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testFirstUnitTest</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>

        <span class="hljs-comment">//Asset</span>

        <span class="hljs-comment">//Act</span>

    }
}
</code></pre><ul>
<li>Add to Arrange setting up of method. </li>
<li>We are mocking method so we can test it here</li>
<li>We don't need to set method of 'mainFunction' as we want 'mainFunction' to act like normal and call our secondFunction. We don't want to do any mocking with 'mainFunction'</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">TestOneMethod</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> TestOneMethod
     */</span>
    <span class="hljs-keyword">protected</span> $testOneMethod;

    <span class="hljs-comment">/**
     * 
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testFirstUnitTest</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod = <span class="hljs-keyword">$this</span>-&gt;getMockBuilder(TestOneMethod::class)
            -&gt;setMethods([<span class="hljs-string">'secondFunction'</span>])
            -&gt;getMock();

        <span class="hljs-comment">//Asset</span>

        <span class="hljs-comment">//Act</span>

    }
}
</code></pre><ul>
<li>Add assert</li>
<li>Here we are testing if the 'secondFunction' is called only once</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">TestOneMethod</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> TestOneMethod
     */</span>
    <span class="hljs-keyword">protected</span> $testOneMethod;

    <span class="hljs-comment">/**
     * 
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testFirstUnitTest</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod = <span class="hljs-keyword">$this</span>-&gt;getMockBuilder(TestOneMethod::class)
            -&gt;setMethods([<span class="hljs-string">'secondFunction'</span>])
            -&gt;getMock();

        <span class="hljs-comment">//Asset</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod-&gt;expects(<span class="hljs-keyword">$this</span>-&gt;once())
        -&gt;method(<span class="hljs-string">'secondFunction'</span>);

        <span class="hljs-comment">//Act</span>

    }
}
</code></pre><ul>
<li>Finally add act. This is where php unit test calls our real class</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">TestOneMethod</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> TestOneMethod
     */</span>
    <span class="hljs-keyword">protected</span> $testOneMethod;

    <span class="hljs-comment">/**
     * 
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testFirstUnitTest</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod = <span class="hljs-keyword">$this</span>-&gt;getMockBuilder(TestOneMethod::class)
            -&gt;setMethods([<span class="hljs-string">'secondFunction'</span>])
            -&gt;getMock();

        <span class="hljs-comment">//Asset</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod-&gt;expects(<span class="hljs-keyword">$this</span>-&gt;once())
        -&gt;method(<span class="hljs-string">'secondFunction'</span>);

        <span class="hljs-comment">//Act</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod-&gt;mainFunction();
    }
}
</code></pre><ul>
<li>Run your test (I am running a magento instance with phpUnit inside vendor/bin/phpunit folder</li>
</ul>
<pre><code>./vendor<span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>phpunit <span class="hljs-operator">-</span>c dev<span class="hljs-operator">/</span>tests<span class="hljs-operator">/</span>unit<span class="hljs-operator">/</span>phpunit.xml.dist app<span class="hljs-operator">/</span>code<span class="hljs-operator">/</span>AzCodez<span class="hljs-operator">/</span>MagentoTraining<span class="hljs-operator">/</span>Test<span class="hljs-operator">/</span>Unit
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1635450474608/wY97LfG8r.png" alt="image.png" /></p>
<ul>
<li>If you want to check if you are testing properly change your assert to check if secondFunction never calls like below</li>
</ul>
<pre><code><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">PHPUnit</span>\<span class="hljs-title">Framework</span>\<span class="hljs-title">TestCase</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">AzCodez</span>\<span class="hljs-title">MagentoTraining</span>\<span class="hljs-title">Controller</span>\<span class="hljs-title">TestOneMethod</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TestOneMethodCallsTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TestCase</span>
</span>{
    <span class="hljs-comment">/**
     * <span class="hljs-doctag">@var</span> TestOneMethod
     */</span>
    <span class="hljs-keyword">protected</span> $testOneMethod;

    <span class="hljs-comment">/**
     * 
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testFirstUnitTest</span>(<span class="hljs-params"></span>)
    </span>{
        <span class="hljs-comment">//Arrange</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod = <span class="hljs-keyword">$this</span>-&gt;getMockBuilder(TestOneMethod::class)
            -&gt;setMethods([<span class="hljs-string">'secondFunction'</span>])
            -&gt;getMock();

        <span class="hljs-comment">//Asset</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod-&gt;expects(<span class="hljs-keyword">$this</span>-&gt;never())
        -&gt;method(<span class="hljs-string">'secondFunction'</span>);

        <span class="hljs-comment">//Act</span>
        <span class="hljs-keyword">$this</span>-&gt;testOneMethod-&gt;mainFunction();
    }
}
</code></pre><ul>
<li>You should get error like below</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1635450662717/T5wRciMdr.png" alt="image.png" /></p>
<p>Hope this works for you. Let me know if you get stuck. </p>
<p>Happy Coding,
Asrin</p>
<p>If this helped you consider buying me a coffee :)</p>
<div class="hn-embed-widget" id="buymecoffee"></div><p>References</p>
<ul>
<li>https://phpunit.readthedocs.io/en/9.5/</li>
<li>https://stackoverflow.com/questions/25214407/how-to-use-phpunit-to-test-a-method-that-calls-other-methods-of-the-same-class</li>
</ul>
]]></content:encoded></item></channel></rss>