<?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: El Morjani Mohamed</title>
    <description>The latest articles on DEV Community by El Morjani Mohamed (@elmorjanimohamed).</description>
    <link>https://dev.to/elmorjanimohamed</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%2F1480160%2F7e576696-7029-49dd-a923-db8ff243aaa7.png</url>
      <title>DEV Community: El Morjani Mohamed</title>
      <link>https://dev.to/elmorjanimohamed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elmorjanimohamed"/>
    <language>en</language>
    <item>
      <title>How to Apply S3 Bucket Policies Using AWS CLI</title>
      <dc:creator>El Morjani Mohamed</dc:creator>
      <pubDate>Tue, 01 Oct 2024 10:24:16 +0000</pubDate>
      <link>https://dev.to/elmorjanimohamed/how-to-apply-s3-bucket-policies-using-aws-cli-1l3e</link>
      <guid>https://dev.to/elmorjanimohamed/how-to-apply-s3-bucket-policies-using-aws-cli-1l3e</guid>
      <description>&lt;p&gt;Managing access control for your Amazon S3 buckets is essential for maintaining security in your AWS environment. In this article, I'll guide you through applying two different S3 bucket policies using the AWS CLI. One policy will allow access from a specific IP address, and the other will restrict access to specific objects (like images) from a designated domain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create and Apply the &lt;code&gt;policy.json&lt;/code&gt; File
&lt;/h2&gt;

&lt;p&gt;The first policy we'll create allows access to your S3 bucket only from a specific IP address. Below is an example of a policy you can use.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;policy.json&lt;/code&gt;
&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;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow specific IP"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&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;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"IPAllow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"s3:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Resource"&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;"arn:aws:s3:::devops22-cli-bucket/*"&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;"Condition"&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;"IpAddress"&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;"aws:SourceIp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"102.51.8.73"&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;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;This policy grants permission to all S3 actions (&lt;code&gt;"s3:*"&lt;/code&gt;) on the &lt;code&gt;devops22-cli-bucket&lt;/code&gt; for the IP address &lt;code&gt;102.51.8.73&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Apply the &lt;code&gt;policy.json&lt;/code&gt; Using AWS CLI
&lt;/h3&gt;

&lt;p&gt;To apply this policy to your S3 bucket, execute the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3api put-bucket-policy &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--policy&lt;/span&gt; file://policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command applies the policy defined in &lt;code&gt;policy.json&lt;/code&gt; to the &lt;code&gt;devops22-cli-bucket&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create and Apply the &lt;code&gt;domain_policy.json&lt;/code&gt; File
&lt;/h2&gt;

&lt;p&gt;Next, let's create a policy that limits access to &lt;code&gt;.jpg&lt;/code&gt; images in the S3 bucket, allowing requests only from a specific domain. This is particularly useful if you want to limit access to certain resources based on the referring domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;domain_policy.json&lt;/code&gt;
&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;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow cloudntaivebasecamp.com to access the images"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&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;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow only GET requests originating from specific domain"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Action"&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="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:s3:::devops22-cli-bucket/*.jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Condition"&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;"StringLike"&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;"aws:Referer"&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="s2"&gt;"https://example.com/*"&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;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;This policy allows &lt;code&gt;GET&lt;/code&gt; requests for &lt;code&gt;.jpg&lt;/code&gt; files within the &lt;code&gt;devops22-cli-bucket&lt;/code&gt; only from the domain &lt;code&gt;example.com&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Apply the &lt;code&gt;domain_policy.json&lt;/code&gt; Using AWS CLI
&lt;/h3&gt;

&lt;p&gt;To apply this domain-based policy, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3api put-bucket-policy &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--policy&lt;/span&gt; file://domain_policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;By using the AWS CLI, you can easily apply bucket policies that control access to your S3 resources. In this article, we covered two examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A policy allowing access from a specific IP address.&lt;/li&gt;
&lt;li&gt;A policy restricting access to certain resources from a specific domain.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These are just two examples of how you can fine-tune your access control policies using S3's flexible policy system. Feel free to adapt these examples to meet the security requirements of your own environment.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>cli</category>
    </item>
    <item>
      <title>🚀 Mastering AWS S3 with the CLI: A Simple Guide to Creating &amp; Managing Buckets 💻</title>
      <dc:creator>El Morjani Mohamed</dc:creator>
      <pubDate>Sun, 29 Sep 2024 20:49:14 +0000</pubDate>
      <link>https://dev.to/elmorjanimohamed/mastering-aws-s3-with-the-cli-a-simple-guide-to-creating-managing-buckets-42k</link>
      <guid>https://dev.to/elmorjanimohamed/mastering-aws-s3-with-the-cli-a-simple-guide-to-creating-managing-buckets-42k</guid>
      <description>&lt;p&gt;As developers, we often find ourselves managing cloud storage. AWS S3 is a popular choice due to its flexibility, scalability, and security. Here's a quick breakdown of how to create, configure, and manage an S3 bucket using AWS CLI! 👇&lt;/p&gt;

&lt;h3&gt;
  
  
  🛠️ Steps to Create and Manage a Bucket:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a new S3 bucket&lt;/strong&gt; in your desired region:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws s3api create-bucket &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--region&lt;/span&gt; eu-north-1 &lt;span class="nt"&gt;--create-bucket-configuration&lt;/span&gt; &lt;span class="nv"&gt;LocationConstraint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;eu-north-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;List your buckets&lt;/strong&gt; to ensure it's created successfully:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws s3 &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Secure your bucket&lt;/strong&gt; by blocking all public access:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws s3api put-public-access-block &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--public-access-block-configuration&lt;/span&gt; &lt;span class="s2"&gt;"BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Upload files&lt;/strong&gt; into your S3 bucket (like images or documents):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws s3api put-object &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--content-type&lt;/span&gt; image/jpeg &lt;span class="nt"&gt;--key&lt;/span&gt; s3Devops22.jpg &lt;span class="nt"&gt;--body&lt;/span&gt; /path/to/your/image.jpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Manage permissions&lt;/strong&gt; to control public or private access to your files. For instance, making an object publicly readable:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws s3api put-object-acl &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--key&lt;/span&gt; s3Devops22.jpg &lt;span class="nt"&gt;--acl&lt;/span&gt; public-read
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Delete files or buckets&lt;/strong&gt; when no longer needed:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws s3api delete-object &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--key&lt;/span&gt; s3Devops22.jpg
   aws s3api delete-bucket &lt;span class="nt"&gt;--bucket&lt;/span&gt; devops22-cli-bucket &lt;span class="nt"&gt;--region&lt;/span&gt; eu-north-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  💡 Why use AWS CLI for S3?
&lt;/h3&gt;

&lt;p&gt;The AWS CLI provides a fast, scriptable interface for managing your resources efficiently—whether you're creating, securing, or optimizing your buckets. It's ideal for developers who want control and automation in their cloud workflows.&lt;/p&gt;

&lt;p&gt;Let’s keep sharing tips and improving our DevOps skills! 🔥 &lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudcomputing</category>
      <category>devops</category>
      <category>s3bucket</category>
    </item>
    <item>
      <title>𝗟𝗮𝗿𝗮𝘃𝗲𝗹 𝗧𝗶𝗽💡: 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲 𝗙𝗮𝗸𝗲 𝗨𝘀𝗲𝗿 𝗔𝗴𝗲𝗻𝘁𝘀</title>
      <dc:creator>El Morjani Mohamed</dc:creator>
      <pubDate>Wed, 24 Jul 2024 08:01:03 +0000</pubDate>
      <link>https://dev.to/elmorjanimohamed/-4bid</link>
      <guid>https://dev.to/elmorjanimohamed/-4bid</guid>
      <description>&lt;p&gt;Did you know you can generate fake user agents for your tests using Laravel? Since Laravel leverages FakerPHP under the hood, this feature is both powerful and easy to implement. 🚀&lt;/p&gt;

&lt;p&gt;In this snippet, we're using FakerPHP to generate various fake user agents for different browsers. This can be particularly useful when writing tests that need to simulate requests from different browsers and devices.&lt;/p&gt;

&lt;p&gt;By incorporating fake user agents into your testing strategy, you can simulate diverse browsing environments and improve the robustness of your applications.&lt;/p&gt;

&lt;p&gt;Happy coding! 💻&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci7u13yt9ihhq4jmheba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci7u13yt9ihhq4jmheba.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>🚀 Laravel Tip💡: Extract Validated Input Elegantly</title>
      <dc:creator>El Morjani Mohamed</dc:creator>
      <pubDate>Sun, 21 Jul 2024 18:26:54 +0000</pubDate>
      <link>https://dev.to/elmorjanimohamed/laravel-tip-extract-validated-input-elegantly-434g</link>
      <guid>https://dev.to/elmorjanimohamed/laravel-tip-extract-validated-input-elegantly-434g</guid>
      <description>&lt;p&gt;As developers, we often need to extract only a few items from a validated request. Instead of manually unsetting or filtering, Laravel provides a clean and efficient way to do this using the safe() method. Here’s how:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Extract only specific fields
$validated = $request-&amp;gt;safe()-&amp;gt;only(['name', 'email']);

// Extract all fields except specified ones
$validated = $request-&amp;gt;safe()-&amp;gt;except(['name', 'email']);

// Extract all validated input
$validated = $request-&amp;gt;safe()-&amp;gt;all();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using safe() makes your code cleaner and ensures you're only working with validated data, enhancing both security and code clarity.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>development</category>
    </item>
    <item>
      <title>Laravel Tip💡: Extract Validated Input Elegantly</title>
      <dc:creator>El Morjani Mohamed</dc:creator>
      <pubDate>Sun, 21 Jul 2024 18:17:53 +0000</pubDate>
      <link>https://dev.to/elmorjanimohamed/laravel-tip-extract-validated-input-elegantly-5631</link>
      <guid>https://dev.to/elmorjanimohamed/laravel-tip-extract-validated-input-elegantly-5631</guid>
      <description>&lt;p&gt;We often redirect our users to specific routes using the "redirect()" method. Did you know there is a shorter and more expressive method called "to_route"? 🚀&lt;br&gt;
&lt;/p&gt;

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

// 🚀 Instead of this
return redirect()-&amp;gt;route('profile');

// ✨ You can do this
return to_route('profile');
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both snippets achieve the same result, but to_route makes your code cleaner and more readable. Small changes can have a big impact! 😊&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>development</category>
    </item>
    <item>
      <title>Revamp Your GitHub: Elevate Your README!</title>
      <dc:creator>El Morjani Mohamed</dc:creator>
      <pubDate>Thu, 09 May 2024 10:46:23 +0000</pubDate>
      <link>https://dev.to/elmorjanimohamed/revamp-your-github-elevate-your-readme-11f4</link>
      <guid>https://dev.to/elmorjanimohamed/revamp-your-github-elevate-your-readme-11f4</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1oj461wrymncce71m3t.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1oj461wrymncce71m3t.jpeg" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Greetings everyone,&lt;/p&gt;

&lt;p&gt;I hope this message finds you well. Today, I'd like to delve into the realm of GitHub. As I embark on my journey to further my studies as a developer, I recognize the significance of maintaining an updated and polished GitHub profile.&lt;/p&gt;

&lt;p&gt;While I created my GitHub account a year ago, I admit that I initially underestimated the importance of maintaining it. However, this year signifies a pivotal moment as I dedicate myself to consistently updating it with my ongoing projects and endeavors.&lt;/p&gt;

&lt;p&gt;In my efforts to revamp my profile, I've taken the initiative to refine my bio, update my &lt;a href="https://github.com/ElmorjaniMohamed"&gt;README&lt;/a&gt;, and ensure that my projects are up-to-date. My aim is for my GitHub profile to serve as a true reflection of my identity and aspirations.&lt;/p&gt;

&lt;p&gt;As I undergo these changes, I find myself pondering the question: "What constitutes best practices on GitHub? What attributes are sought after in the market?" This contemplation has prompted me to reach out to you all for insights. I invite you to share your tips and recommendations in the comments below.&lt;/p&gt;

&lt;p&gt;Furthermore, if you're inclined, I would greatly appreciate any feedback on how &lt;a href="https://github.com/ElmorjaniMohamed"&gt;I can enhance my profile&lt;/a&gt;. Please feel free to drop your GitHub profiles in the comments so that we can all engage, inspire, and connect.&lt;/p&gt;

&lt;p&gt;Thank you for your time and contributions.&lt;/p&gt;

&lt;p&gt;Warm regards, Mohamed EL Morjani&lt;/p&gt;

</description>
      <category>github</category>
      <category>networking</category>
      <category>socialmedia</category>
      <category>git</category>
    </item>
  </channel>
</rss>
