<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Anwar Hossain</title>
    <description>The latest articles on Forem by Anwar Hossain (@anwarsr).</description>
    <link>https://forem.com/anwarsr</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%2F760933%2F366b67f1-a40e-4dc2-b015-7186407f7392.jpg</url>
      <title>Forem: Anwar Hossain</title>
      <link>https://forem.com/anwarsr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anwarsr"/>
    <language>en</language>
    <item>
      <title>🚀 React 19 is about to revolutionize the way we build web applications!</title>
      <dc:creator>Anwar Hossain</dc:creator>
      <pubDate>Fri, 13 Sep 2024 04:49:35 +0000</pubDate>
      <link>https://forem.com/anwarsr/react-19-is-about-to-revolutionize-the-way-we-build-web-applications-5b2b</link>
      <guid>https://forem.com/anwarsr/react-19-is-about-to-revolutionize-the-way-we-build-web-applications-5b2b</guid>
      <description>&lt;p&gt;One of the most exciting features of this release is the &lt;code&gt;React Compiler&lt;/code&gt;, which takes React to a whole new level. Traditionally, React handled the bundling process, making code browser-ready. But with the new React Compiler, the magic happens during compilation. It transforms React code directly into highly optimized HTML, CSS, and JavaScript, resulting in a dramatic boost in performance. 🔥&lt;/p&gt;

&lt;p&gt;This concept isn’t entirely new—Svelte has had a similar compiler for some time, which is why it’s known for being lightning fast compared to traditional React setups. But now, with React 19, that speed gap is closing, and React apps will become supercharged without needing major manual optimizations. ⚡&lt;/p&gt;

&lt;p&gt;Another common challenge React developers face is unwanted re-renders when the state changes. In earlier versions, we used Memoization (with hooks like &lt;code&gt;useMemo&lt;/code&gt;) to prevent unnecessary re-renders, especially for expensive components or calculations. This optimization technique allows React to cache expensive calculations and reuse the results.&lt;/p&gt;

&lt;p&gt;But here's the game-changer: In React 19, much of this will happen automatically! No more worrying about manually adding &lt;code&gt;useMemo&lt;/code&gt;or other hooks to optimize performance—React will handle it for you. This built-in optimization will make it easier to build faster and more efficient applications with less effort. 🎯&lt;/p&gt;

&lt;p&gt;With these updates, React continues to push boundaries, blending developer experience with performance enhancements, and I can’t wait to see how these changes reshape the ecosystem.&lt;/p&gt;

&lt;p&gt;What are your thoughts on these new features? Let’s discuss how React 19 might influence our future development workflows! 💬&lt;/p&gt;

&lt;h1&gt;
  
  
  React19 #webdevelopment #frontend #performance #ReactJS #innovation #softwareengineering
&lt;/h1&gt;

</description>
      <category>react19</category>
      <category>webdev</category>
      <category>performance</category>
      <category>react</category>
    </item>
    <item>
      <title>🚀 Unleashing the Power of AWS Lambda for Image Compression in Laravel Application 🚀</title>
      <dc:creator>Anwar Hossain</dc:creator>
      <pubDate>Tue, 27 Feb 2024 04:18:08 +0000</pubDate>
      <link>https://forem.com/anwarsr/unleashing-the-power-of-aws-lambda-for-image-compression-in-laravel-application-27fi</link>
      <guid>https://forem.com/anwarsr/unleashing-the-power-of-aws-lambda-for-image-compression-in-laravel-application-27fi</guid>
      <description>&lt;p&gt;Hey Dev community! 👋 Today, let's explore the magic of AWS Lambda and seamlessly integrate it into a Laravel application for uploading raw images to S3 and compressing them on the fly! 🖼️💡&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up Your Laravel Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ensure you have a Laravel project up and running. If not, use Composer to create a new project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer create-project &lt;span class="nt"&gt;--prefer-dist&lt;/span&gt; laravel/laravel my-laravel-app

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Configure AWS S3 Bucket&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create an S3 bucket on AWS to store both raw and compressed images. Note down your access key, secret key, and bucket name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Integrate AWS SDK in Laravel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install the AWS SDK for PHP (Bref) using Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require bref/bref

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

&lt;/div&gt;



&lt;p&gt;Configure your AWS credentials in the &lt;strong&gt;&lt;code&gt;.env&lt;/code&gt;&lt;/strong&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_DEFAULT_REGION=your-region # e.g., 'us-east-1'
AWS_BUCKET=your-s3-bucket-name

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Upload Image to S3 in Laravel Controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In your Laravel controller, use the AWS SDK to upload the raw image to S3:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example Laravel Controller&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Http\Request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Aws\S3\S3Client&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ImageController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;uploadToS3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'image'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'raw/'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getClientOriginalName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="nv"&gt;$s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;S3Client&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="s1"&gt;'region'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'filesystems.disks.s3.region'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="s1"&gt;'version'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'latest'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;

        &lt;span class="nv"&gt;$s3&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;putObject&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="s1"&gt;'Bucket'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'filesystems.disks.s3.bucket'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="s1"&gt;'Key'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Body'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="s1"&gt;'ACL'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'public-read'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;

        &lt;span class="c1"&gt;// Your logic for further processing or response&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Set Up AWS Lambda for Image Compression&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create an AWS Lambda function with permissions to access your S3 bucket. Implement image compression using the Intervention Image library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Trigger Lambda on S3 Object Creation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Configure an S3 event trigger to invoke your Lambda function whenever a new object is created in the bucket.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lambda Function for Image Compression:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Http\Controllers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Http\Request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Support\Facades\Storage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Intervention\Image\Facades\Image&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ImageController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;compressImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Get the S3 bucket and key from the request&lt;/span&gt;
        &lt;span class="nv"&gt;$bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bucket'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'key'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Download the image from S3&lt;/span&gt;
        &lt;span class="nv"&gt;$s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Storage&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;disk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'s3'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$imageData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$s3&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Compress the image using Intervention Image&lt;/span&gt;
        &lt;span class="nv"&gt;$compressedImageData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;compressImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$imageData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Upload the compressed image back to S3&lt;/span&gt;
        &lt;span class="nv"&gt;$compressedKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'compressed/'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$s3&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$compressedKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$compressedImageData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'message'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Image compression successful!'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;compressImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$imageData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Load the image from raw data&lt;/span&gt;
        &lt;span class="nv"&gt;$image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Image&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$imageData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Apply your compression logic here&lt;/span&gt;
        &lt;span class="c1"&gt;// Example: Resize the image to a maximum width/height of 500px while maintaining aspect ratio&lt;/span&gt;
        &lt;span class="nv"&gt;$image&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;resize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$constraint&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$constraint&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;aspectRatio&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nv"&gt;$constraint&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;upsize&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="c1"&gt;// Save the compressed image to a temporary location in memory&lt;/span&gt;
        &lt;span class="nv"&gt;$compressedImageData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$image&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'jpg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Adjust format and quality as needed&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$compressedImageData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Access Compressed Image:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you upload an image to the 'raw/' directory in S3, the Lambda function will be triggered.&lt;/p&gt;

&lt;p&gt;The compressed image will be stored in the 'compressed/' directory.&lt;/p&gt;

&lt;p&gt;To access the compressed image with lower size but the same quality, use the appropriate URL, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;https://your-s3-bucket.s3.amazonaws.com/compressed/your-image.jpg

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

&lt;/div&gt;



&lt;p&gt;Now, your Lambda function will automatically compress images upon upload to S3, maintaining quality while reducing file size. Adjust the compression logic in the Lambda function as needed for your specific use case. Feel free to connect for more details or discussions! 🚀👨‍💻&lt;/p&gt;

&lt;h1&gt;
  
  
  AWSLambda #ImageCompression #Serverless #S3 #LaravelApplication #TechInnovation
&lt;/h1&gt;

</description>
      <category>lamda</category>
      <category>aws</category>
      <category>serverless</category>
      <category>laravel</category>
    </item>
    <item>
      <title>🚀Unlocking the Power of NGINX - A Web Server Marvel! 🚀</title>
      <dc:creator>Anwar Hossain</dc:creator>
      <pubDate>Sun, 25 Feb 2024 16:31:00 +0000</pubDate>
      <link>https://forem.com/anwarsr/unlocking-the-power-of-nginx-a-web-server-marvel-4j7n</link>
      <guid>https://forem.com/anwarsr/unlocking-the-power-of-nginx-a-web-server-marvel-4j7n</guid>
      <description>&lt;p&gt;Today, let's delve into the world of NGINX, a robust web server that goes beyond the basics. 🌐✨&lt;/p&gt;

&lt;p&gt;NGINX is more than just a web server; it's a high-performance, open-source solution that excels at serving static content, handling reverse proxying, and even managing load balancing. Let's explore its versatility with a few key scenarios.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;1. Serving Static Content with NGINX:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of NGINX's strengths is efficiently handling static content. Here's a snippet of NGINX configuration to serve static files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nginxCopy code
server {
    listen 80;
    server_name example.com;

    location / {
        root /path/to/your/static/files;
        index index.html;
    }
}

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

&lt;/div&gt;



&lt;p&gt;In this scenario, NGINX efficiently delivers static files like HTML, CSS, and images, enhancing your website's speed and responsiveness.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;2. Reverse Proxy Magic:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NGINX shines as a reverse proxy, mediating requests between clients and backend servers. Consider a scenario where you have a Node.js app running on &lt;strong&gt;&lt;code&gt;localhost:3000&lt;/code&gt;&lt;/strong&gt;. NGINX simplifies the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nginxCopy code
server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

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

&lt;/div&gt;



&lt;p&gt;Now, NGINX acts as a gateway, seamlessly directing traffic to your Node.js app. 🚪&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;3. Load Balancing Brilliance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine your application gaining popularity, and you need to distribute incoming traffic among multiple servers. NGINX simplifies load balancing with ease:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nginxCopy code
http {
    upstream backend {
        server server1.example.com;
        server server2.example.com;
        # Add more servers as needed
    }

    server {
        listen 80;
        server_name example.com;

        location / {
            proxy_pass http://backend;
        }
    }
}

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

&lt;/div&gt;



&lt;p&gt;NGINX ensures that each request is intelligently distributed across your backend servers, optimizing performance and maintaining stability. 🔄⚖️&lt;/p&gt;




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

&lt;p&gt;NGINX is a powerful ally in the realm of web servers, offering speed, flexibility, and reliability. Whether you're serving static content, acting as a reverse proxy, or managing load balancing, NGINX stands tall. Dive into its configurations, embrace the versatility, and elevate your web infrastructure. What's your favorite NGINX use case? Share your thoughts! 🚀💬 #NGINX #WebServers #TechInnovation&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>webserver</category>
      <category>nginx</category>
    </item>
    <item>
      <title>🚀 React Labs Update: Innovations and Progress in February 2024! 🚀</title>
      <dc:creator>Anwar Hossain</dc:creator>
      <pubDate>Sat, 24 Feb 2024 16:00:36 +0000</pubDate>
      <link>https://forem.com/anwarsr/react-labs-update-innovations-and-progress-in-february-2024-1mpj</link>
      <guid>https://forem.com/anwarsr/react-labs-update-innovations-and-progress-in-february-2024-1mpj</guid>
      <description>&lt;p&gt;Exciting developments in the React Labs world! Check out the latest post by Joseph Savona, Ricky Hanlon, Andrew Clark, Matt Carroll, and Dan Abramov on what's been brewing in React.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;React Compiler Goes Production!&lt;/strong&gt;&lt;br&gt;
The React Compiler, once a research project, now powers instagram.com! 🚀 Dive into the world of automatic UI re-renders without compromising React's core model. Read about the challenges, optimizations, and how it's shaping up for an open source release.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Revolutionizing Data Handling with Actions!&lt;/strong&gt;&lt;br&gt;
Explore the broader realm of "Actions" – a feature allowing synchronous or asynchronous functions to be tied to DOM elements. From &lt;/p&gt; actions to managing optimistic state updates with useOptimistic, React is evolving for cleaner, more efficient data handling. Available soon in the next React release!

&lt;p&gt;👉 &lt;strong&gt;New Features in React Canary!&lt;/strong&gt;&lt;br&gt;
React Canary introduces exciting features like Directives, Document Metadata, Asset Loading, and Actions. Get a sneak peek into these features and how they seamlessly work together to elevate your React development experience.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;The Next Major Version: React 19!&lt;/strong&gt;&lt;br&gt;
React@canary is ready to ship to React@latest, marking the next major version, React 19. Brace yourselves for compatibility improvements, breaking changes, and long-awaited features like Web Components. Stay tuned for more insights into the release preparations.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Activity (formerly Offscreen): A Glimpse into the Future!&lt;/strong&gt;&lt;br&gt;
Get an update on the renamed "Activity" feature under research. Discover how it goes beyond the visible and inactive parts of your app, bringing a new perspective to app development.&lt;/p&gt;

&lt;p&gt;Exciting times ahead for the React community! Share your thoughts on these advancements and stay tuned for more updates. 🚀💻 #React #WebDevelopment #Innovation #React19 #Programming #TechUpdate&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>🚀 Exploring Multiple Inheritance in Laravel/PHP 🚀</title>
      <dc:creator>Anwar Hossain</dc:creator>
      <pubDate>Wed, 21 Feb 2024 17:06:36 +0000</pubDate>
      <link>https://forem.com/anwarsr/exploring-multiple-inheritance-in-laravelphp-gem</link>
      <guid>https://forem.com/anwarsr/exploring-multiple-inheritance-in-laravelphp-gem</guid>
      <description>&lt;p&gt;Hey fellow developers! 👋 Let's take a dive into a fascinating topic today: &lt;strong&gt;Multiple Inheritance&lt;/strong&gt; in PHP/Laravel. 🤯&lt;/p&gt;

&lt;p&gt;In traditional object-oriented programming, a class can inherit from only one parent class. However, there are situations where you might want functionality from multiple sources. Fear not! PHP offers a workaround using traits.&lt;/p&gt;

&lt;p&gt;💡 &lt;strong&gt;What are Traits?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Traits are a way to group functionality in a fine-grained and consistent way. They're like code snippets that you can reuse across multiple classes.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;Example: Combining Traits for Multiple Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you have classes &lt;strong&gt;&lt;code&gt;A&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;B&lt;/code&gt;&lt;/strong&gt;, each with distinct functionalities, and you want a new class &lt;strong&gt;&lt;code&gt;C&lt;/code&gt;&lt;/strong&gt; to inherit from both. Here's how you can achieve it using traits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;TraitA&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;methodA&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Functionality from Class A&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;trait&lt;/span&gt; &lt;span class="nc"&gt;TraitB&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;methodB&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Functionality from Class B&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;C&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;TraitA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;TraitB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Now, Class C has both methodA() and methodB()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;🚀 &lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code Reusability:&lt;/strong&gt; Traits allow you to reuse code in a modular way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoiding Diamond Problem:&lt;/strong&gt; Traits help to avoid the ambiguity that arises in traditional multiple inheritance scenarios.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Note:&lt;/strong&gt; While traits offer a powerful solution, use them judiciously to maintain code clarity and avoid complex hierarchies.&lt;/p&gt;

&lt;p&gt;What are your thoughts on using multiple inheritance in PHP/Laravel? Share your experiences or questions in the comments below! Let's keep the conversation going. Happy coding! 💻🌐&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>webdev</category>
      <category>tips</category>
    </item>
    <item>
      <title>Optimizing Laravel Performance: A Comprehensive Guide to Indexing</title>
      <dc:creator>Anwar Hossain</dc:creator>
      <pubDate>Sun, 11 Feb 2024 14:42:05 +0000</pubDate>
      <link>https://forem.com/anwarsr/optimizing-laravel-performance-a-comprehensive-guide-to-indexing-38k3</link>
      <guid>https://forem.com/anwarsr/optimizing-laravel-performance-a-comprehensive-guide-to-indexing-38k3</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp76ai6bx6b3chaco5y4d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp76ai6bx6b3chaco5y4d.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What is Indexing?&lt;/li&gt;
&lt;li&gt;Importance in Laravel&lt;/li&gt;
&lt;li&gt;Types of Indexing in Laravel&lt;/li&gt;
&lt;li&gt;How to Create Indexes in Laravel&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;li&gt;Real-world Example&lt;/li&gt;
&lt;li&gt;Measurable Impact&lt;/li&gt;
&lt;li&gt;Performance Testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the realm of Laravel development, optimizing application performance is a constant endeavor. One powerful tool in our arsenal is indexing, a database optimization technique that significantly enhances the speed and efficiency of Laravel applications. This post provides an overview of the importance of indexing and its practical implementation in Laravel.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Indexing?
&lt;/h2&gt;

&lt;p&gt;At its core, indexing is a mechanism to improve the speed of data retrieval operations on a database table. It involves creating a data structure that provides quick lookup access to rows in a table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance in Laravel
&lt;/h2&gt;

&lt;p&gt;Laravel, being an expressive and elegant PHP framework, demands efficient handling of database operations. Indexing plays a pivotal role in optimizing queries, reducing response times, and ultimately enhancing the overall performance of Laravel applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Indexing in Laravel
&lt;/h2&gt;

&lt;p&gt;Laravel supports various types of indexes, including single-column indexes, composite indexes, and unique indexes. Understanding these types is crucial for making informed decisions based on the specific needs of your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Create Indexes in Laravel
&lt;/h2&gt;

&lt;p&gt;This section provides a step-by-step guide to creating indexes in Laravel, starting from migration commands. Practical examples are explored to illustrate the implementation and ensure a smooth integration into your projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;p&gt;While implementing indexing in Laravel, it's essential to follow best practices. Insights into when to use indexes, potential pitfalls to avoid, and common mistakes that developers might encounter are shared in this section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-world Example
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Boosting Laravel Application Performance with Indexing
&lt;/h3&gt;

&lt;p&gt;Let's bring the theory of indexing into the real world with a practical example from a Laravel application. Imagine you have a large e-commerce platform where the product catalog is extensive, and users frequently search for products based on various criteria.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario
&lt;/h3&gt;

&lt;p&gt;Without proper indexing, a simple query to retrieve products by category could lead to performance bottlenecks, especially as the catalog grows. Let's explore how implementing indexing can make a substantial impact.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before Indexing
&lt;/h3&gt;

&lt;p&gt;Consider the following query without any indexing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$categoryId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a scenario with a vast product catalog, this query might take a considerable amount of time, leading to slower response times and a less-than-ideal user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  After Implementing Indexing
&lt;/h3&gt;

&lt;p&gt;Now, let's introduce indexing to optimize the search:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Migration file&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By creating an index on the 'category_id' column, we significantly improve the performance of the query. Laravel can now swiftly locate and retrieve the relevant products associated with the specified category, resulting in a faster and more responsive application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Measurable Impact
&lt;/h3&gt;

&lt;p&gt;After implementing indexing, you may notice a substantial reduction in the query execution time, particularly when dealing with large datasets. Users searching for products within a specific category will experience quicker results, leading to a smoother and more satisfying user experience.&lt;/p&gt;

&lt;p&gt;This example illustrates how a seemingly simple indexing adjustment can have a profound impact on the performance of your Laravel application, making it crucial for scenarios where data retrieval speed is paramount.&lt;/p&gt;

&lt;p&gt;By incorporating such indexing strategies judiciously throughout your Laravel application, you can create a more efficient and responsive system, ensuring that your users have a seamless experience even as your dataset continues to grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Performance Testing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To validate the effectiveness of our indexing strategies, we'll explore performance testing. Learn how to measure and analyze the results, ensuring that your Laravel application not only looks good on the surface but performs exceptionally well under the hood.&lt;/p&gt;

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