<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aastha Shrivastava</title>
    <description>The latest articles on DEV Community by Aastha Shrivastava (@shriaas2898).</description>
    <link>https://dev.to/shriaas2898</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F259770%2Fad135228-d94c-405a-aaee-5868ac276554.JPG</url>
      <title>DEV Community: Aastha Shrivastava</title>
      <link>https://dev.to/shriaas2898</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shriaas2898"/>
    <language>en</language>
    <item>
      <title>Setting up drupal9 multi-site with Lando</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 22 Sep 2021 14:12:08 +0000</pubDate>
      <link>https://dev.to/shriaas2898/setting-up-drupal9-multi-site-with-lando-4god</link>
      <guid>https://dev.to/shriaas2898/setting-up-drupal9-multi-site-with-lando-4god</guid>
      <description>&lt;p&gt;Setting up a multi-site architecture can sound overwhelming and scary😱 with all the database setup and creating vhost for each site... it can become painful and daunting. But here is how you can setup a drupal 9 multi-site with single database using prefixes within 15 min(30 mins tops I swear!😬). So let's dive into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.lando.dev/basics/installation.html"&gt;Lando&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps:
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. Start by downloading codebase for drupal9 by
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;composer create drupal/recommended-project&lt;/code&gt;&lt;br&gt;
Inside your project folder run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lando init   --source cwd   --recipe drupal9   --webroot .   --name &amp;lt;project-name&amp;gt;
 lando composer require drush/drush
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Edit &lt;code&gt;.lando.yml&lt;/code&gt; with following (example) content:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;project-name&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;recipe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;drupal9&lt;/span&gt;
&lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;webroot&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
  &lt;span class="na"&gt;drush&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^10&lt;/span&gt;
  &lt;span class="na"&gt;xdebug&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
  &lt;span class="na"&gt;via&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mariadb:10.5&lt;/span&gt;
&lt;span class="na"&gt;proxy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;appserver_nginx&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;subsite1.lndo.site&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;subsite2.lndo.site&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;subsite3.lndo.site&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Replace  with your project name.&lt;br&gt;
The important thing to see here is &lt;code&gt;proxy: appserver_nginx&lt;/code&gt; key which lists  the URLs for our default and subsites which is equivalent to setting up vhost for each site, you may also need to add an entry for your default site like &lt;code&gt;- &amp;lt;project-name&amp;gt;.lndo.site&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Create folders for subsites in your &lt;code&gt;sites&lt;/code&gt; directory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   mkdir subsite{1..3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Copy &lt;code&gt;examples.sites.php&lt;/code&gt; to &lt;code&gt;sites.php&lt;/code&gt; and add entries for subsites  in your &lt;code&gt;sites.php&lt;/code&gt; file:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $sites['subsite1.lndo.site'] = 'subsite1';
   $sites['subsite2.lndo.site'] = 'subsite2';
   $sites['subsite3.lndo.site'] = 'subsite3';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Copy settings.php to your default and subsites directories.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  6. Run &lt;code&gt;lando rebuild&lt;/code&gt;so it creates urls for our subsites.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  7. Go to the respective URL on browser and install the default site first.
&lt;/h4&gt;

&lt;p&gt;By default lando creates database with name &lt;code&gt;drupal9&lt;/code&gt; and username as password as &lt;code&gt;drupal9&lt;/code&gt; too and host as &lt;code&gt;database&lt;/code&gt; so use these while installing the site:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0AslyuzV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyjle8obyn389vtxfrdz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0AslyuzV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyjle8obyn389vtxfrdz.png" alt="alt text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Tip:&lt;/strong&gt; you can quickly find info about configuration using &lt;code&gt;lando info&lt;/code&gt;&lt;br&gt;
Since this is default site we will leave the prefix empty. &lt;br&gt;
Proceed and install the site.&lt;/p&gt;

&lt;h4&gt;
  
  
  8. Installing subsites
&lt;/h4&gt;

&lt;p&gt;Go the URL for subsite, repeat step7, except this time also add the value in prefix field:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Agk79Ld_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssafc0a9yj5b04cgzwhq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Agk79Ld_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssafc0a9yj5b04cgzwhq.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Proceed and install the site.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Install site using browser instead of drush because drush will ask to drop and recreate the database for each site.&lt;/p&gt;

&lt;p&gt;And We are all done!!!&lt;/p&gt;

&lt;p&gt;In case you want to add more sites just repeat 2-6 and then 8 for your new site. And get it up and running in no time.&lt;/p&gt;

&lt;p&gt;Remember we are doing everything here inside a docker container so if you want to check your databases for example, you will need to use &lt;code&gt;lando mysql&lt;/code&gt; instead of just &lt;code&gt;mysql&lt;/code&gt; and also the credentials will be the one which are created by lando rather than what you have on your system.&lt;/p&gt;

&lt;p&gt;Let me know in the comments if you found this helpful! KThnxByee!👋🏼&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting up drupal9 multi-site with DDEV</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 22 Sep 2021 13:04:34 +0000</pubDate>
      <link>https://dev.to/shriaas2898/setting-up-drupal9-multi-site-with-ddev-2f22</link>
      <guid>https://dev.to/shriaas2898/setting-up-drupal9-multi-site-with-ddev-2f22</guid>
      <description>&lt;p&gt;Setting up a multi-site architecture can sound overwhelming and scary😱 with all the database setup and creating vhost for each site... it can become painful and daunting. But here is how you can setup a drupal 9 multi-site with single database using prefixes within 15 min(30 mins tops I swear!😬). So let's dive into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ddev.readthedocs.io/en/latest/"&gt;DDEV&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps:
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. Make a new folder for your project and in your folder run:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ddev config --project-type=drupal9 --docroot=web --create-docroot
 ddev composer create drupal/recommended-project
 ddev composer require drush/drush
 ddev restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Create &lt;code&gt;.ddev/config.multisite.yaml&lt;/code&gt; with following (example) content:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;   &lt;span class="na"&gt;additional_hostnames&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;subsite1&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;subsite2&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;subsite3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file contains list of URLs for our subsites which is equivalent to setting up vhost for each site.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Create folders for subsites in your &lt;code&gt;sites&lt;/code&gt; directory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   mkdir subsite{1..3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Copy &lt;code&gt;examples.sites.php&lt;/code&gt; to &lt;code&gt;sites.php&lt;/code&gt; and add entries for subsites  in your &lt;code&gt;sites.php&lt;/code&gt; file:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $sites['subsite1.ddev.site'] = 'subsite1';
   $sites['subsite2.ddev.site'] = 'subsite2';
   $sites['subsite3.ddev.site'] = 'subsite3';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. DDEV creates &lt;code&gt;settings.php&lt;/code&gt; in &lt;code&gt;default&lt;/code&gt; directory so copy this to your subsites
&lt;/h4&gt;

&lt;h3&gt;
  
  
  6. Since we are using single DB with prefixes add entry for db prefix in each of your subsite's &lt;code&gt;settings.php&lt;/code&gt; after the line to import &lt;code&gt;settings.ddev.php&lt;/code&gt;. Like this:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// Automatically generated include for settings managed by ddev.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$app_root&lt;/span&gt;  &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/sites/default/settings.ddev.php'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'IS_DDEV_PROJECT'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;include&lt;/span&gt; &lt;span class="nv"&gt;$app_root&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/sites/default/settings.ddev.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;$databases&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'prefix'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'subsite1'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: By default ddev uses &lt;code&gt;__DIR__ . '/settings.ddev.php'&lt;/code&gt; since it assumes &lt;code&gt;settings.ddev.php&lt;/code&gt; is in the same directory, but since that is not the case with our subsites folders, we are using  &lt;code&gt;$app_root  . '/sites/default/settings.ddev.php'&lt;/code&gt; instead.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Run &lt;code&gt;ddev restart&lt;/code&gt; so it creates urls for our subsites.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  8. Go to the respective URL on browser and install the site.
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Install site using browser instead of drush because drush will ask to drop and recreate the database for each site.&lt;/p&gt;

&lt;p&gt;And We are all done!!!&lt;/p&gt;

&lt;p&gt;In case you want to add more sites just repeat 2-8 for your new site. And get it up and running in no time.&lt;/p&gt;

&lt;p&gt;In case you want to use multiste with multiple databse refer to this &lt;a href="https://github.com/drud/ddev-contrib/tree/master/recipes/drupal8-multisite"&gt;example&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Remember we are doing everything here inside a docker container so if you want to check your databases for example, you will need to use &lt;code&gt;ddev mysql&lt;/code&gt; instead of just &lt;code&gt;mysql&lt;/code&gt; and also the credentials will be the one which are created by DDEV rather than what you have on your system.&lt;/p&gt;

&lt;p&gt;Let me know in the comments if you found this helpful! KThnxByee!👋🏼&lt;/p&gt;

</description>
      <category>drupal</category>
      <category>ddev</category>
      <category>drupalmultisite</category>
      <category>drupal9</category>
    </item>
    <item>
      <title>Understanding Drupal's composer.json file line by line</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Thu, 05 Nov 2020 06:56:47 +0000</pubDate>
      <link>https://dev.to/shriaas2898/understanding-drupal-s-composer-json-file-line-by-line-1ml</link>
      <guid>https://dev.to/shriaas2898/understanding-drupal-s-composer-json-file-line-by-line-1ml</guid>
      <description>&lt;h1&gt;
  
  
  Understanding Drupal's composer.json file line by line
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Name
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"drupal/legacy-project"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;name&lt;/code&gt;: denotes the name of the package.&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Project template for Drupal 9 projects with composer following drupal/drupal layout"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;description&lt;/code&gt;: denotes the short description about the package.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"project"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;type&lt;/code&gt;: denotes the type of a package, by default the &lt;code&gt;type&lt;/code&gt; of a composer package is &lt;code&gt;library&lt;/code&gt;. Here Drupal is of type &lt;code&gt;project&lt;/code&gt; it means that drupal is full-fledged application rather than just a &lt;code&gt;library&lt;/code&gt; which could be used by other projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  License
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"license"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"GPL-2.0-or-later"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;license&lt;/code&gt;: denotes the type of license this project uses in this case &lt;code&gt;GNU's General Public License&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Homepage
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"homepage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://www.drupal.org/project/drupal"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;homepage&lt;/code&gt;: denotes the url of the package's website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"support"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"docs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://www.drupal.org/docs/user_guide/en/index.html"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"chat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://www.drupal.org/node/314178"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;support&lt;/code&gt;: contains list of various resources to get support about the project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;docs&lt;/code&gt;: contains link of official documentation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chat&lt;/code&gt;: contains link for the chat channel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Repositories
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"repositories"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"composer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://packages.drupal.org/8"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;repositories&lt;/code&gt; contains list of custom repositories to use, by default composer uses &lt;code&gt;packagist&lt;/code&gt; repository to fetch packages. Here we are telling composer to fetch packages from &lt;code&gt;https://packages.drupal.org/8&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Require
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"require"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"composer/installers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^1.9"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"drupal/core-composer-scaffold"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"drupal/core-project-message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"drupal/core-recommended"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"drupal/core-vendor-hardening"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;require&lt;/code&gt; contains list of packages required by this package. The current package could install only after all its requirements are installed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conflict
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"conflict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"drupal/drupal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;conflict&lt;/code&gt; contains list of packages which conflict with this package for this version, this package will not get installed if any conflicting packages exists.&lt;/p&gt;

&lt;h3&gt;
  
  
  Minimum Stability
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"minimum-stability"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dev"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Minimum stability is used to filter packages based on their stability i.e &lt;code&gt;stable&lt;/code&gt;, &lt;code&gt;dev&lt;/code&gt; etc, the by default value of &lt;code&gt;minimum-stability&lt;/code&gt; is &lt;code&gt;stable&lt;/code&gt;. This means when you are trying to install a package via composer and the package is under &lt;em&gt;development&lt;/em&gt; and there is no &lt;em&gt;stable&lt;/em&gt; release yet, the composer will not install that package. Hence if you expect to work with package under development you should specify &lt;code&gt;"minimum-stability&lt;/code&gt; as &lt;code&gt;dev&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prefer Stable
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;prefer-stable&lt;/code&gt; is set to &lt;code&gt;true&lt;/code&gt; composer will perfer to install &lt;code&gt;stable&lt;/code&gt; package version over &lt;code&gt;unstable&lt;/code&gt; package versions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Config
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;Config is only supported with &lt;code&gt;projects&lt;/code&gt;. &lt;code&gt;config&lt;/code&gt; defines list of configurations for the project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if &lt;code&gt;sort-packages&lt;/code&gt; is set to true the &lt;code&gt;require&lt;/code&gt; command will keep the packages sorted by name inside &lt;code&gt;composer.json&lt;/code&gt; whenever it adds a new package.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Extra
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;extra&lt;/code&gt; contains any extra data which can be used by &lt;code&gt;scripts&lt;/code&gt;. To access the data from script you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$extra&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$event&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;getComposer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;getPackage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;getExtra&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Let's try to understand each section in &lt;code&gt;extra&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;drupal-scaffold&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nl"&gt;"drupal-scaffold"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"locations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"web-root"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the &lt;code&gt;drupal-scaffold&lt;/code&gt; configuration for &lt;a href="https://www.drupal.org/docs/develop/using-composer/using-drupals-composer-scaffold"&gt;composer-scaffold plugin&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;location&lt;/code&gt; defines location of the &lt;code&gt;web-root&lt;/code&gt; in this case it is &lt;code&gt;./&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;installer-paths&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;There are various types of packages which can be installed by composer in drupal, for e.g &lt;code&gt;core&lt;/code&gt;, &lt;code&gt;libraries&lt;/code&gt;, &lt;code&gt;modules&lt;/code&gt;, &lt;code&gt;themes&lt;/code&gt; etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nl"&gt;"installer-paths"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"core"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"type:drupal-core"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"libraries/{$name}"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"type:drupal-library"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;installer-paths&lt;/code&gt; specifies where a package should be places according to its &lt;em&gt;type&lt;/em&gt;. For e.g a &lt;code&gt;drupal-core&lt;/code&gt; package should be placed inside the &lt;code&gt;core&lt;/code&gt; directory, and a &lt;code&gt;drupal-library&lt;/code&gt; package should be placed inside a directory with its name in &lt;code&gt;libraries&lt;/code&gt; directory and so on.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;drupal-core-project-message&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;This section is used for &lt;em&gt;The Drupal Project Message Plugin&lt;/em&gt;. The project message plugin is used to display messages after composer finishes installation, you can get the full documentation &lt;a href="https://www.drupal.org/docs/develop/using-composer/using-drupals-project-message-composer-plugin"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nl"&gt;"drupal-core-project-message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"include-keys"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"homepage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"support"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"post-create-project-cmd-message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;bg=blue;fg=white&amp;gt;                                                         &amp;lt;/&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;bg=blue;fg=white&amp;gt;  Congratulations, you’ve installed the Drupal codebase  &amp;lt;/&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;bg=yellow;fg=black&amp;gt;Next steps&amp;lt;/&amp;gt;:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"  * Install the site: https://www.drupal.org/docs/8/install"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;include-keys&lt;/code&gt; is used to tell plugin to output the structured support information from the &lt;code&gt;composer.json&lt;/code&gt; file. Currently the plugin supports &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;homepage&lt;/code&gt; and &lt;code&gt;support&lt;/code&gt; keys only.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;post-create-project-cmd-message&lt;/code&gt; contains the formatted message to display on the command line after the project is successfully created/installed.&lt;/p&gt;

&lt;p&gt;And that's all! We understood what each section represents in drupal's default composer file.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://getcomposer.org/doc/04-schema.md#extra"&gt;Official composer  documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://drupalize.me/tutorial/anatomy-composer-project?p=3233"&gt;Anatomy of a Composer Project&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.drupal.org/docs/develop/using-composer/using-drupals-composer-scaffold"&gt;Using Drupal's Composer Scaffold&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.drupal.org/docs/develop/using-composer/using-drupals-project-message-composer-plugin"&gt;Using Drupal's Project Message Composer Plugin&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Automating Virtual Host setup on your server</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 04 Nov 2020 14:04:11 +0000</pubDate>
      <link>https://dev.to/shriaas2898/automating-virtual-host-setup-on-your-server-4oha</link>
      <guid>https://dev.to/shriaas2898/automating-virtual-host-setup-on-your-server-4oha</guid>
      <description>&lt;p&gt;Are you also one of those who frequently need to setup VHosts in order to test,create etc new sites and you feel doing the whole process again and again is time consuming and well.. BORING? Then this article is for you!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The script used in this article is written for any &lt;strong&gt;Linux&lt;/strong&gt; distro with &lt;strong&gt;Apache&lt;/strong&gt; server, but you may still get a general idea of how to use it for your requirements.  &lt;/p&gt;

&lt;p&gt;Here we will create a simple bash script to automate the whole vhost setup process which includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a new folder for your website.&lt;/li&gt;
&lt;li&gt;Creating configuration files for the website.&lt;/li&gt;
&lt;li&gt;Configuring the &lt;code&gt;hosts&lt;/code&gt; file and&lt;/li&gt;
&lt;li&gt;Enabling the vhost.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Creating template files
&lt;/h3&gt;

&lt;p&gt;Before we start working on our script we will need these template files which we use in the setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A template &lt;code&gt;conf&lt;/code&gt; file to create configuration for the vhost.&lt;/li&gt;
&lt;li&gt;A template &lt;code&gt;index.html&lt;/code&gt; file for default homepage of our newly created vhost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how my template files looks like:&lt;br&gt;
&lt;strong&gt;default-index.html&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

 &lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Home|New Virtual Host&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Welcome!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt; 
        You just created a new virtual host!&lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        Go ahead and add some files in your brand new vhost
   &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;default-vhost.conf&lt;/strong&gt;&lt;/p&gt;

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

&amp;lt;VirtualHost *:80&amp;gt;
        ServerName 127.0.0.x
        ServerAlias example.local
        ServerAdmin admin@example.local
        DocumentRoot /var/www/example.local

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
&amp;lt;/VirtualHost&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;You can create similar files based on your requirements.&lt;/p&gt;

&lt;p&gt;Now let's get started with the script.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting &lt;code&gt;sitename&lt;/code&gt; and &lt;code&gt;host&lt;/code&gt; from command line
&lt;/h3&gt;

&lt;p&gt;Let's start by getting the input parameters as command line arguments. We will use the flags:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-s&lt;/code&gt;: for sitename&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-h&lt;/code&gt;: for host&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will also use a flag &lt;code&gt;-d&lt;/code&gt; (optional) in case user wants to create a new project directory for the vhost.&lt;/p&gt;

&lt;p&gt;We will use &lt;code&gt;getopts&lt;/code&gt; to get the arguments, if you are not familiar with &lt;code&gt;getopts&lt;/code&gt; you can check out &lt;a href="https://dev.to/shriaas2898/taking-command-line-arguments-using-flags-in-bash-121"&gt;this article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is how we can take input from command line:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;getopts &lt;/span&gt;s:h:d flag
&lt;span class="k"&gt;do
case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;flag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
                &lt;/span&gt;s&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;sitename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
                        &lt;span class="p"&gt;;;&lt;/span&gt;
                h&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
                         &lt;span class="p"&gt;;;&lt;/span&gt;
                d&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;createdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
                        &lt;span class="p"&gt;;;&lt;/span&gt;
 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Added entry in hosts file"&lt;/span&gt;
               &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Invalid option: -&lt;/span&gt;&lt;span class="nv"&gt;$flag&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
        &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;We are storing the values we got from input in &lt;code&gt;sitename&lt;/code&gt; and &lt;code&gt;host&lt;/code&gt; variable and setting &lt;code&gt;createdir&lt;/code&gt; to 1.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating and configuring project directory
&lt;/h3&gt;

&lt;p&gt;Next we will create a folder in &lt;code&gt;/var/www&lt;/code&gt; and copy our &lt;code&gt;default-index.html&lt;/code&gt; file in that folder:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$createdir&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 1 &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;
  &lt;span class="nb"&gt;cp &lt;/span&gt;default-index.html /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;/index.html


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

&lt;/div&gt;

&lt;p&gt;We are checking if user has specified the &lt;code&gt;-d&lt;/code&gt; flag or not, you can remove the condition if you always want create a new directory for your vhost. You can also skip this step depending on your requirement.&lt;/p&gt;

&lt;p&gt;Now that we have created the directory let's change the owner to current logged-in user:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

  &lt;span class="nb"&gt;chown&lt;/span&gt; &lt;span class="nv"&gt;$SUDO_USER&lt;/span&gt;:&lt;span class="nv"&gt;$SUDO_USER&lt;/span&gt; /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;This is because only the super user has permissions to create files and folders in &lt;code&gt;var/www&lt;/code&gt;, so we are changing the owner of the folder so that the current user will have full control over the folder.&lt;/p&gt;

&lt;p&gt;This script needs to be run using sudo, &lt;code&gt;$SUDO_USER&lt;/code&gt; contains user name of user which is executing the script using &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now let's change the permission for&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

  &lt;span class="nb"&gt;chmod &lt;/span&gt;755 /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;



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

&lt;/div&gt;
&lt;h3&gt;
  
  
  Creating configuration files
&lt;/h3&gt;

&lt;p&gt;Now we will create the &lt;code&gt;conf&lt;/code&gt; file for our site in &lt;code&gt;/etc/apache2/sites-available/&lt;/code&gt; using or default template:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/apache2/sites-available/
&lt;span class="nb"&gt;cp &lt;/span&gt;default-vhost.conf &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"s/example.local/&lt;/span&gt;&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;span class="s2"&gt;/g"&lt;/span&gt; &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"s/127.0.0.x/&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="s2"&gt;/g"&lt;/span&gt; &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf


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

&lt;/div&gt;

&lt;p&gt;Here &lt;code&gt;sed&lt;/code&gt; or &lt;code&gt;stream editor&lt;/code&gt; is a command line tool for editing, we are using &lt;code&gt;sed&lt;/code&gt; to replace &lt;em&gt;example.local&lt;/em&gt; with &lt;code&gt;$sitename&lt;/code&gt; and &lt;em&gt;127.0.0.x&lt;/em&gt; with &lt;code&gt;$host&lt;/code&gt; in our conf file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring hosts file
&lt;/h3&gt;

&lt;p&gt;Currently your &lt;code&gt;/etc/host&lt;/code&gt; must look like something like this :&lt;/p&gt;

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

127.0.0.1       localhost
.
.
.

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
.
.
.


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

&lt;/div&gt;

&lt;p&gt;We want to add the host and sitename before &lt;code&gt;# The following lines are desirable...&lt;/code&gt; line. For this we will once again use the &lt;code&gt;sed&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"0,/# The following lines are desirable for IPv6 capable hosts/s/^# The following lines are desirable.*/&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="s2"&gt;       &lt;/span&gt;&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;/"&lt;/span&gt; /etc/hosts


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  Enabling virtual host and restarting the server
&lt;/h3&gt;

&lt;p&gt;Now let's enable our vhost using &lt;code&gt;a2ensite&lt;/code&gt; command and reload apache:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

a2ensite &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf
systemctl reload apache2
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"All done! Visit your newly created virtual host at https://example123.local"&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;And that's it! Phew! We just created a simple script to automate vhost configuration. Let's go ahead and execute it:&lt;/p&gt;

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

sudo ./create-conf.sh -s example123.local -h 127.0.0.12 -d

All done! Visit your newly created virtual host at https://example123.local


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

&lt;/div&gt;

&lt;p&gt;Let's visit our newly created virtual host&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6otf0jd6hr6mbdo3d1d1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6otf0jd6hr6mbdo3d1d1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is how our full script looks like:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;getopts &lt;/span&gt;s:h:d flag&lt;br&gt;
&lt;span class="k"&gt;do&lt;br&gt;
case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;flag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in&lt;br&gt;
                &lt;/span&gt;s&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;sitename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;br&gt;
                        &lt;span class="p"&gt;;;&lt;/span&gt;&lt;br&gt;
                h&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;br&gt;
                         &lt;span class="p"&gt;;;&lt;/span&gt;&lt;br&gt;
                d&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;createdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1&lt;br&gt;
                        &lt;span class="p"&gt;;;&lt;/span&gt;&lt;br&gt;
                &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Invalid option: -&lt;/span&gt;&lt;span class="nv"&gt;$flag&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;&lt;br&gt;
        &lt;span class="k"&gt;esac&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;done&lt;/span&gt;&lt;br&gt;
&lt;span class="c"&gt;# Create and configure folder in &lt;code&gt;/var/www&lt;/code&gt; if option if option selected&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$createdir&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 1 &lt;span class="o"&gt;]]&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;then&lt;br&gt;
  &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;br&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Folder /var/www/&lt;/span&gt;&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;span class="s2"&gt; created"&lt;/span&gt;&lt;br&gt;
  &lt;span class="c"&gt;# Creating dummy landing page&lt;/span&gt;&lt;br&gt;
  &lt;span class="nb"&gt;cp &lt;/span&gt;default-index.html /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;/index.html&lt;br&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Intitialized with index page"&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# Changing owner and permission of the folder&lt;/span&gt;&lt;br&gt;
  &lt;span class="nb"&gt;chown&lt;/span&gt; &lt;span class="nv"&gt;$SUDO_USER&lt;/span&gt;:&lt;span class="nv"&gt;$SUDO_USER&lt;/span&gt; /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;br&gt;
  &lt;span class="nb"&gt;chmod &lt;/span&gt;755 /var/www/&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;br&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Modified permissions and owner"&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;&lt;br&gt;
&lt;span class="c"&gt;# Creating configuration files&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/apache2/sites-available/&lt;br&gt;
&lt;span class="nb"&gt;cp &lt;/span&gt;default-vhost.conf &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf&lt;br&gt;
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"s/example.local/&lt;/span&gt;&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;span class="s2"&gt;/g"&lt;/span&gt; &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf&lt;br&gt;
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"s/127.0.0.x/&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="s2"&gt;/g"&lt;/span&gt; &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf&lt;br&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Configuration files created"&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# Configuring hosts file&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"0,/# The following lines are desirable for IPv6 capable hosts/s/^# The following lines are desirable.*/&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="s2"&gt;       &lt;/span&gt;&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;/"&lt;/span&gt; /etc/hosts&lt;br&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Added entry in hosts file"&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# Enabling virtual host and restarting the server&lt;/span&gt;&lt;br&gt;
a2ensite &lt;span class="nv"&gt;$sitename&lt;/span&gt;.conf&lt;br&gt;
systemctl reload apache2&lt;br&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Restarted apache"&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"All done! Visit your newly created virtual host at https://&lt;/span&gt;&lt;span class="nv"&gt;$sitename&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;/p&gt;

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

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Final Thoughts&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Though this script may not fully work with your requirement you can definitely get an idea of how to make one for yourself do let me know in the comments what you think about it!&lt;/p&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/shriaas2898/setting-up-virtual-host-on-ubuntu-20-joe"&gt;Setting up Virtual Host on Ubuntu 20 &lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/shriaas2898/taking-command-line-arguments-using-flags-in-bash-121"&gt;Taking command line arguments using flags in bash &lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/30386483/command-to-insert-lines-before-first-match" rel="noopener noreferrer"&gt;Stream Editor to insert line&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/" rel="noopener noreferrer"&gt;How to use sed to find and replace text in files in Linux / Unix shell&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting up Virtual Host on Ubuntu 20
</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 04 Nov 2020 11:45:03 +0000</pubDate>
      <link>https://dev.to/shriaas2898/setting-up-virtual-host-on-ubuntu-20-joe</link>
      <guid>https://dev.to/shriaas2898/setting-up-virtual-host-on-ubuntu-20-joe</guid>
      <description>&lt;h2&gt;
  
  
  What is Virtual Host:
&lt;/h2&gt;

&lt;p&gt;Virtual host is a mechanism to set up multiple hosts in a single system the user feels that they are getting redirected to different locations when in reality their requests are sent to the same IP, just on different directories. Every virtual host is identified by virtualname. Virtual are useful because you can utilize a single IP location and single machine to host multiple websites. Let’s see how we can setup virtual host on our own machine in few simple steps &lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites:
&lt;/h2&gt;

&lt;p&gt;In order to setup vhost you need to install and configure &lt;strong&gt;apache 2&lt;/strong&gt; on your ubuntu system. You can refer to &lt;a href="https://www.linuxbabe.com/ubuntu/install-lamp-stack-ubuntu-20-04-server-desktop"&gt;this&lt;/a&gt; link to setup apache.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Intitalizing and configuring directory
&lt;/h3&gt;

&lt;p&gt;The first step is to create directory which contains the website i.e the document root of your site.&lt;/p&gt;

&lt;p&gt;create the folder for your website in &lt;code&gt;var/www/html&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; /var/www/mysite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to have root priviliges to create a folder in  &lt;code&gt;var/www/html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we need to change the permissions for &lt;code&gt;mysite&lt;/code&gt; so that it can be accessed without root privilages. We will change the owner to current logged-in user to gain full access of &lt;code&gt;mysite&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;:&lt;span class="nv"&gt;$USER&lt;/span&gt; /var/www/mysite/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;$USER&lt;/code&gt; contains name of current logged-in user.&lt;/p&gt;

&lt;p&gt;Also we can ensure that &lt;code&gt;mysite&lt;/code&gt; is readable by all the users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;755 /var/www/mysite/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Creating demo page in &lt;code&gt;mysite&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Now that we are all done with setting up directory let's add some content to it.&lt;br&gt;
&lt;strong&gt;Note:&lt;/strong&gt; You can skip this step if you have website content ready with you.&lt;/p&gt;

&lt;p&gt;Create a file in &lt;code&gt;mysite&lt;/code&gt; using &lt;code&gt;nano&lt;br&gt;
&lt;/code&gt; or you can use any editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano /var/www/mysite/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add some content like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;My Site&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello and Welcome to My Site&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;
This is where it all started......
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;code&gt;Ctrl+X&lt;/code&gt; and save the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Creating configuration files for virtual host
&lt;/h3&gt;

&lt;p&gt;We are all done with setting up content for our site. Let's move on to setup our virtual host file.&lt;/p&gt;

&lt;p&gt;Apache provides a default file for virtual host called &lt;code&gt;000-default.conf&lt;/code&gt; present in &lt;code&gt;/etc/apache2/sites-available/&lt;/code&gt; which we can copy and modify a bit for our virtual host.&lt;br&gt;
Let's copy the default file and open it in nano:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.local.conf

&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/apache2/sites-available/mysite.local.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see a bunch of parameters in this file. We will modify four of them for basic setup.&lt;br&gt;
&lt;code&gt;SeverAdmin&lt;/code&gt; -&amp;gt; the email of your website's admin&lt;br&gt;
&lt;code&gt;Sever Name&lt;/code&gt; -&amp;gt; the address of your website&lt;br&gt;
&lt;code&gt;Document Root&lt;/code&gt; -&amp;gt; the directory which contains the website.&lt;br&gt;
&lt;code&gt;Server Alias&lt;/code&gt; -&amp;gt; a sudo or virtual name that should be displayed on search bar while accessing the site.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&amp;lt;VirtualHost &lt;span class="k"&gt;*&lt;/span&gt;:80&amp;gt;

        ServerName 127.0.0.2
        ServerAlias mysite.local
        ServerAdmin admin@mysite.com
        DocumentRoot /var/www/mysite

        ErrorLog &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;APACHE_LOG_DIR&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/error.log
        CustomLog &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;APACHE_LOG_DIR&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/access.log combined

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

&lt;/div&gt;



&lt;p&gt;Save the file and exit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Enabling newly added virtual host
&lt;/h3&gt;

&lt;p&gt;After configuring the virtual host file we have to enable it using &lt;code&gt;a2ensite&lt;/code&gt; command (which rougly translates to apache2 enable site)&lt;br&gt;
Change the directory and enable the site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/apache2/sites-available/
&lt;span class="nb"&gt;sudo &lt;/span&gt;a2ensite mysite.com.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make the changes restart the apache server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Configuring hosts file
&lt;/h3&gt;

&lt;p&gt;The last step is to configure &lt;code&gt;/etc/hosts&lt;/code&gt; file which contains list of IP addresses and names. It acts like a local DNS file.&lt;br&gt;
Let's open the file using &lt;code&gt;nano&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now add the IP address and name of the site.&lt;br&gt;
&lt;strong&gt;Note:&lt;/strong&gt; the name should be same as the name of file for virtual host i.e &lt;code&gt;mysite.local.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;127.0.0.1       localhost
127.0.0.2       mysite.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it!!&lt;/p&gt;

&lt;p&gt;Open browser and type &lt;code&gt;http://mysite.local&lt;/code&gt; and you can access your site.&lt;/p&gt;

&lt;p&gt;Congratulations! you just setup a virtual host. &lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart"&gt;https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart&lt;/a&gt;&lt;br&gt;
&lt;a href="https://linuxhint.com/install_apache_web_server_ubuntu/"&gt;https://linuxhint.com/install_apache_web_server_ubuntu/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Taking command line arguments using flags in bash</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 04 Nov 2020 11:17:52 +0000</pubDate>
      <link>https://dev.to/shriaas2898/taking-command-line-arguments-using-flags-in-bash-121</link>
      <guid>https://dev.to/shriaas2898/taking-command-line-arguments-using-flags-in-bash-121</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/shriaas2898/getting-started-with-shell-scripting-4mla"&gt;previous article&lt;/a&gt; we created a simple bash script let's modify it a bit to accept command line arguments.&lt;br&gt;
We will accept the name of directory which needs to be created and the path of directory whose files we have to list.&lt;br&gt;
We will use flags to take input i.e &lt;code&gt;-i&lt;/code&gt; for name of input directory whose contents will be listed and &lt;code&gt;-o&lt;/code&gt; for output directory.&lt;/p&gt;

&lt;p&gt;This is our current code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Script to create a directory in home with given name and a file containing list of files present in /var/www/html&lt;/span&gt;
&lt;span class="nv"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Aastha"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/&lt;span class="nv"&gt;$NAME&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /var/www/html&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/&lt;span class="nv"&gt;$NAME&lt;/span&gt;/file_list.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Getting arguments using &lt;code&gt;getopts&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;We will use get &lt;code&gt;getopts&lt;/code&gt; function which returns a list of options(flags) with respective argument. &lt;br&gt;
We will use a &lt;code&gt;while&lt;/code&gt; to iterate through &lt;code&gt;getopts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;getopts &lt;/span&gt;i:o: flag 
&lt;span class="k"&gt;do&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are we are specifying list of valid options as &lt;code&gt;i:o:&lt;/code&gt; the &lt;code&gt;:&lt;/code&gt; represents that an option need to be followed by a value.You can read more about &lt;code&gt;getopts&lt;/code&gt; &lt;a href="https://www.mkssoftware.com/docs/man1/getopts.1.asp"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;code&gt;flag&lt;/code&gt; is the iterator variable here. In bash  the &lt;code&gt;do&lt;/code&gt; followed  by &lt;code&gt;while&lt;/code&gt; statement specifies starting of block which contains satement to be executed by &lt;code&gt;while&lt;/code&gt;. The ending of block is specified by &lt;code&gt;done&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Storing argument values in variables
&lt;/h1&gt;

&lt;p&gt;We will use switch &lt;code&gt;case&lt;/code&gt; to assign values, based on options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;flag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
                &lt;/span&gt;i&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;infolder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
                        &lt;span class="p"&gt;;;&lt;/span&gt;
                o&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;outfolder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
                         &lt;span class="p"&gt;;;&lt;/span&gt;
                &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Invalid option: -&lt;/span&gt;&lt;span class="nv"&gt;$flag&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
        &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above will comapare &lt;code&gt;$flag&lt;/code&gt; with &lt;code&gt;i&lt;/code&gt;,&lt;code&gt;o&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; where &lt;code&gt;*&lt;/code&gt; can be any thing other than &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt;. The &lt;code&gt;;;&lt;/code&gt; indicates the end of a &lt;code&gt;case&lt;/code&gt;. The &lt;code&gt;${OPTARG}&lt;/code&gt; contains the argument supplied for &lt;code&gt;$flag&lt;/code&gt; option.&lt;br&gt;
The &lt;code&gt;esac&lt;/code&gt; indicates the end of the whole switch &lt;code&gt;case&lt;/code&gt; block.&lt;/p&gt;

&lt;h1&gt;
  
  
  Replacing hard-coded values with new variables
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/&lt;span class="nv"&gt;$outfolder&lt;/span&gt; 
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nv"&gt;$infolder&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/&lt;span class="nv"&gt;$outfolder&lt;/span&gt;/file_list.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Script to create a directory in home with name `$outfolder` and a file containing list of files present in`$infolder`&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;getopts &lt;/span&gt;i:o: flag

&lt;span class="k"&gt;do
        case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;flag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
                &lt;/span&gt;i&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;infolder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
                        &lt;span class="p"&gt;;;&lt;/span&gt;
                o&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;outfolder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OPTARG&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
                         &lt;span class="p"&gt;;;&lt;/span&gt;
                &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Invalid option: -&lt;/span&gt;&lt;span class="nv"&gt;$flag&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
        &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done
&lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/&lt;span class="nv"&gt;$outfolder&lt;/span&gt; 
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nv"&gt;$infolder&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/&lt;span class="nv"&gt;$outfolder&lt;/span&gt;/file_list.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Getting started with Shell Scripting</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 04 Nov 2020 11:14:31 +0000</pubDate>
      <link>https://dev.to/shriaas2898/getting-started-with-shell-scripting-4mla</link>
      <guid>https://dev.to/shriaas2898/getting-started-with-shell-scripting-4mla</guid>
      <description>&lt;p&gt;Shell scripting is a simple yet powerful way of performing some task using shell. A shell script is just like any program file which contains sequence of statements. Shell scripts can be useful when you want to execute a same set of commands everytime say for installing dependencies on multiple systems. What makes a shell script so powerfull is that you can directly write your shell commands as statements which allows you to do a lot of things ranging from linkinking two files for e.g getting some value from say a python script and supplying  it as an input to say a php file, to monitoring the entire system. All this is possible because you are working on the system level. &lt;br&gt;
Now that we know what can we do using shell script let's try to make one of our own.&lt;/p&gt;

&lt;p&gt;Let's try to create a directory and list all the files in a specific directory.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating bash script step by step
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Open your terminal and create a new script file.
&lt;/h3&gt;

&lt;p&gt;Let's call our script file &lt;code&gt;list_file.sh&lt;/code&gt;, every bash script has extension &lt;code&gt;.sh&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vi list_files.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;code&gt;I&lt;/code&gt; to insert.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Specifying executable binary
&lt;/h3&gt;

&lt;p&gt;The first line of the script contains the absolute path of the program by which it is executed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Although it is not necessary to specify program it is followed as a good practice.&lt;/p&gt;

&lt;p&gt;Since we are creating a bash script the path will be &lt;code&gt;/usr/bin/bash&lt;/code&gt;&lt;br&gt;
Enter the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/bash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Adding comments
&lt;/h3&gt;

&lt;p&gt;You can add comments by adding &lt;code&gt;#&lt;/code&gt; followed by comment in a bash script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Script to create a directory in home with given name and a file containing list of files present in /var/www/html&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Declaring variable
&lt;/h3&gt;

&lt;p&gt;Now let's create a variable which contains name of the folder which we are going to create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Aastha"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can create variables just by writing &lt;code&gt;variable_name = value&lt;/code&gt;, no need to specify data type.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Creating folder
&lt;/h3&gt;

&lt;p&gt;Now let's create a folder in home directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/&lt;span class="nv"&gt;$NAME&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that &lt;code&gt;NAME&lt;/code&gt; is preceeded by &lt;code&gt;$&lt;/code&gt;, here &lt;code&gt;$NAME&lt;/code&gt; represents value stored in &lt;code&gt;NAME&lt;/code&gt; variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Generating file with list of files present in /var/www/html
&lt;/h3&gt;

&lt;p&gt;We can use &lt;code&gt;echo&lt;/code&gt; followed by text, to print some text on stdout(Standard Outoput) but we can also use it to add some text in a specified file using &lt;code&gt;&amp;gt;&lt;/code&gt; operator like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /var/www/html&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/&lt;span class="nv"&gt;$NAME&lt;/span&gt;/file_list.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;~/$NAME/file_list.txt&lt;/code&gt; is the name of out put file which contains result of &lt;code&gt;ls /var/www/html&lt;/code&gt;.&lt;br&gt;
The &lt;code&gt;`&lt;/code&gt; denotes that echo will first evaluate the expression and then use its value.&lt;/p&gt;

&lt;p&gt;The whole file will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Script to create a directory in home with given name and a file containing list of files present in /var/www/html&lt;/span&gt;
&lt;span class="nv"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Aastha"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/&lt;span class="nv"&gt;$NAME&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /var/www/html&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/&lt;span class="nv"&gt;$NAME&lt;/span&gt;/file_list.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Saving the file
&lt;/h3&gt;

&lt;p&gt;We are done with all the statements, let's save and close the file. Press &lt;code&gt;Esc&lt;/code&gt; then type &lt;code&gt;:wq&lt;/code&gt; that is write and quit and press enter.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Executing the script
&lt;/h3&gt;

&lt;p&gt;To execute the script first we will need to change its permissions by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x list_files.sh 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which will grant executing permissions to all.&lt;/p&gt;

&lt;p&gt;Now let's execute the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./list_files.sh 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it! You can see a file is created in the specified directory.&lt;/p&gt;

&lt;p&gt;This was just a basic shell script in the next article we'll see how to &lt;a href="https://dev.to/shriaas2898/taking-command-line-arguments-using-flags-in-bash-121"&gt;take command line arguments using flags&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Resetting admin password in Drupal</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Wed, 04 Nov 2020 09:28:17 +0000</pubDate>
      <link>https://dev.to/shriaas2898/resetting-admin-password-in-drupal-using-sql-532j</link>
      <guid>https://dev.to/shriaas2898/resetting-admin-password-in-drupal-using-sql-532j</guid>
      <description>&lt;p&gt;Often when you are working on a local Drupal site you may forget your admin password and you haven't setup SMTP yet, in this case there are multiple ways to recover your admin password, this article we'll see how to reset the admin password by &lt;strong&gt;changing password in database&lt;/strong&gt; and resetting password &lt;strong&gt;using drush&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using SQL/Database
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisite:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Access to your drupal site's  codebase i.e the  project folder of your drupal site&lt;/li&gt;
&lt;li&gt;Access to database which is used by your drupal site&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Generating password hash
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to your site's document root and execute
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php core/scripts/password-hash.sh 'newpasswd'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;'newpasswd'&lt;/code&gt; with your password.&lt;/p&gt;

&lt;p&gt;You will see the output similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;password: newpasswd         hash: $S$Eno1EhlPNMqE2RfDOBT13tzGCAdN9PgKqJFGI.4sBSj1XgJfPH68
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$S$Eno1EhlPNMqE2RfDOBT13tzGCAdN9PgKqJFGI.4sBSj1XgJfPH68&lt;/code&gt; is the hash which we need to update in the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating password in database
&lt;/h3&gt;

&lt;p&gt;You can either use GUI like phpmyadmin and change &lt;code&gt;pass&lt;/code&gt; = &lt;code&gt;$S$Eno1EhlPNMqE2RfDOBT13tzGCAdN9PgKqJFGI.4sBSj1XgJfPH68&lt;/code&gt; in the &lt;code&gt;users_field_data&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;uid&lt;/code&gt; of admin is 1 by default in drupal. The same mechanism can be used to change password of any user by supplying the appropriate &lt;code&gt;uid&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;OR&lt;br&gt;
You can use mysql command line and execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE users_field_data 
SET pass='$S$Eno1EhlPNMqE2RfDOBT13tzGCAdN9PgKqJFGI.4sBSj1XgJfPH68' 
WHERE uid = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Clearing the cache
&lt;/h3&gt;

&lt;p&gt;Even after updating the password in &lt;code&gt;users_field_data&lt;/code&gt; table,may still won't allow you to login this is because the login system is referring to the password stored in &lt;code&gt;cache_entity&lt;/code&gt; table and not &lt;code&gt;users_field_data&lt;/code&gt;, so you will need to delete the record in &lt;code&gt;cache_entity&lt;/code&gt; using gui, or by using mysql command line and executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM cache_entity WHERE cid = 'values:user:1';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  For drupal 7 or older
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Generating password hash
&lt;/h3&gt;

&lt;p&gt;Go to your site's document root and execute&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php scripts/password-hash.sh 'newpasswd'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;'newpasswd'&lt;/code&gt; with your password.&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating password in database
&lt;/h3&gt;

&lt;p&gt;You need to make the changes mentioned for Drupal 8 or newer  in &lt;code&gt;users&lt;/code&gt; table instead of &lt;code&gt;users_field_data&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you have exceeded your login attempts you may need to delete corresponding records from &lt;code&gt;flood&lt;/code&gt; table.&lt;br&gt;
This flood table records username and ip which has failed login attempts.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using Drush
&lt;/h2&gt;

&lt;p&gt;If you have &lt;a href="https://www.drush.org/"&gt;drush&lt;/a&gt; installed with your drupal installation you can easily reset the password for any user even the admin&lt;/p&gt;

&lt;p&gt;There are 2 ways of using drush to change password:&lt;/p&gt;
&lt;h3&gt;
  
  
  Using drush to generate password reset link
&lt;/h3&gt;

&lt;p&gt;You can generate a link to reset with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drush uli --name=&amp;lt;username&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drush uli --uid=&amp;lt;user id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace  and  with the username and the id of the user whose password needs to get reset. If you do not specify &lt;code&gt;uid&lt;/code&gt; or &lt;code&gt;name&lt;/code&gt; drush will operate on the user with &lt;code&gt;uid&lt;/code&gt; &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This will generate a &lt;em&gt;one-time login link&lt;/em&gt; which looks like this:&lt;br&gt;
&lt;code&gt;http://default/user/reset/2/1604915661/Ua9e50at_ggrlLqr5ulcX39CbpLjLO85Tczhz8nbdCM/login&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Replace &lt;code&gt;default&lt;/code&gt; with your hostname or IP and log in.&lt;/p&gt;

&lt;p&gt;Alternatively, you can use option &lt;code&gt;--uri &amp;lt;hostname/IP&amp;gt;&lt;/code&gt; to specify the hostname or IP of your website and drush will generate the link for your site.&lt;br&gt;&lt;br&gt;
Copy this link on your browser and you will get the password reset screen.&lt;/p&gt;
&lt;h3&gt;
  
  
  Using drush to reset password through the command line
&lt;/h3&gt;

&lt;p&gt;You can change the password of  &lt;code&gt;someuser&lt;/code&gt; to &lt;code&gt;somepass&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drush user:password someuser "somepass"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://enzo.weknowinc.com/articles/2014/12/07/resetting-the-administrator-password-with-sql-query-in-drupal-8"&gt;Resetting the administrator password with sql-query in Drupal 8&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.drupal.org/node/1023428"&gt;Resetting the administrator password with sql-query (Drupal 7)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.drupal.org/node/44164"&gt;Recovering the administrator password&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using github Workflow to Recognize Community Contributions </title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Thu, 17 Sep 2020 20:38:42 +0000</pubDate>
      <link>https://dev.to/shriaas2898/using-github-workflow-to-recognize-community-contributions-3ba2</link>
      <guid>https://dev.to/shriaas2898/using-github-workflow-to-recognize-community-contributions-3ba2</guid>
      <description>&lt;h3&gt;
  
  
  My Workflow
&lt;/h3&gt;

&lt;p&gt;Leader-board for Community Contributions&lt;br&gt;
Actions Used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;checkout&lt;/li&gt;
&lt;li&gt;setup-python&lt;/li&gt;
&lt;li&gt;peter-evans/close-issue&lt;/li&gt;
&lt;li&gt;peter-evans/create-or-update-comment&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;Wacky Wildcards&lt;/p&gt;

&lt;h3&gt;
  
  
  Yaml File or Link to Code
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;{% github https://github.com/devcpune/Awesome-DevC-Contributors/blob/master/.github/workflows/main.yml %}&lt;/code&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Resources / Info
&lt;/h3&gt;

&lt;p&gt;Workflow is currently in use by &lt;a href="https://github.com/devcpune/Awesome-DevC-Contributors"&gt;Awesome-DevC-Contributors&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/shriaas2898/how-i-used-github-workflow-to-recognize-community-contributions-30oc"&gt;Journey of the Leaderboard workflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>actionshackathon</category>
    </item>
    <item>
      <title>How I used github workflow to recognize community contributions(Part-1)</title>
      <dc:creator>Aastha Shrivastava</dc:creator>
      <pubDate>Thu, 17 Sep 2020 20:36:14 +0000</pubDate>
      <link>https://dev.to/shriaas2898/how-i-used-github-workflow-to-recognize-community-contributions-30oc</link>
      <guid>https://dev.to/shriaas2898/how-i-used-github-workflow-to-recognize-community-contributions-30oc</guid>
      <description>&lt;p&gt;Recently Developer Circles Facebook has concluded its Open Source Immersion Program, and we at DevC Pune thought to make a repository to recognize all the PRs made by the community during this program and decided to make a repository which has leader-board for the same, but collecting all the data was difficult and there comes GitHub workflows to the rescue which made ease the process of collecting data about PR and publishing on the repository. Enough with the stories! Let's talk about what we actually did.&lt;/p&gt;

&lt;p&gt;Before starting let's understand what is a &lt;strong&gt;workflow&lt;/strong&gt; and  how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a GitHub Workflow?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;GitHub Workflow&lt;/strong&gt; is a mechanism used for automating your projects life cycle, remember event handling in other languages like Java, JavaScript etc? Yep this is the same just with &lt;strong&gt;GitHub events&lt;/strong&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instead of &lt;code&gt;onClick&lt;/code&gt;, &lt;code&gt;onHover&lt;/code&gt; etc we have events like: &lt;code&gt;PR opened&lt;/code&gt;, &lt;code&gt;Issue opened&lt;/code&gt;, &lt;code&gt;Issue edited&lt;/code&gt; etc.&lt;/li&gt;
&lt;li&gt;When an event occurs, the workflow has a list of &lt;code&gt;jobs&lt;/code&gt; to be executed, in a job we can do some processing, and use some &lt;code&gt;actions&lt;/code&gt;, which are just like functions in our regular programming language.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How does a GitHub Workflow works?
&lt;/h2&gt;

&lt;p&gt;Every workflow needs to have a &lt;code&gt;.yml&lt;/code&gt; which contains various sections of identifying the event and list of jobs reacting based upon the event. The yml file can even call another script to do some processing. When a job is executed it creates an instance of you repo on cloud, like a docker image, and now this is instance is just like a copy of your repo on a local machine, once you are done with processing you have to push the changes back to GitHub to see the changes. So you can use this instance to to perform anything which you do on your terminal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a yml file
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the first line we have to specify the name of the workflow:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;add-project&lt;/span&gt;
&lt;span class="c1"&gt;# This workflow gets executed when someone opens an issue for adding a project&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also add some comment to describe what that workflow is doing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can define an event on which a workflow will be triggered like this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;issues&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;types&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;opened&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;edited&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now comes the list of &lt;code&gt;jobs&lt;/code&gt;, we can define a &lt;code&gt;job&lt;/code&gt; as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;add_project_job&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;startsWith(github.event.issue.title, 'add|')&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;add-project&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;add_project_job&lt;/code&gt; is the name of job. We can also specify condition which decides if certain job will be executed or not.&lt;br&gt;
The &lt;code&gt;runs-on&lt;/code&gt; parameter specify the environment which will be created to run the job. Next we have to define steps which will be executed inside a job.&lt;/p&gt;

&lt;p&gt;And that is the basic structure of a GitHub workflow. We'll discuss the whole workflow in detail in the next part! Till then keep automating!&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.github.com/en/actions/learn-github-actions"&gt;Official Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/devcpune/Awesome-DevC-Contributors/blob/master/.github/workflows/main.yml#L29"&gt;Link to Full Code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>actionshackathon</category>
      <category>github</category>
      <category>workflows</category>
      <category>leaderboardworkflow</category>
    </item>
  </channel>
</rss>
