<?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: Yasser Elgammal</title>
    <description>The latest articles on DEV Community by Yasser Elgammal (@yasserelgammal).</description>
    <link>https://dev.to/yasserelgammal</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%2F137473%2Fe33f993a-26f8-40c6-8642-722f1fef577e.jpg</url>
      <title>DEV Community: Yasser Elgammal</title>
      <link>https://dev.to/yasserelgammal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yasserelgammal"/>
    <language>en</language>
    <item>
      <title>Green Framework: Simple &amp; Modern PHP Framework for Fast Development</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Tue, 07 Apr 2026 00:25:58 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/green-framework-simple-modern-php-framework-for-fast-development-g0f</link>
      <guid>https://dev.to/yasserelgammal/green-framework-simple-modern-php-framework-for-fast-development-g0f</guid>
      <description>&lt;p&gt;&lt;strong&gt;Green Framework&lt;/strong&gt; is a simple and modern PHP framework built to make development faster and easier.&lt;/p&gt;

&lt;p&gt;It focuses on clean code and uses modern PHP features like &lt;strong&gt;Attributes&lt;/strong&gt;, so you can define things like routes directly inside your controllers without extra files.&lt;/p&gt;

&lt;h3&gt;
  
  
  🚀 Why use Green?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Simple and lightweight
&lt;/li&gt;
&lt;li&gt;Clean and readable code
&lt;/li&gt;
&lt;li&gt;Fast to build with
&lt;/li&gt;
&lt;li&gt;Great for small to medium projects
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ⚡ Installation
&lt;/h2&gt;

&lt;p&gt;You can install &lt;strong&gt;Green Framework&lt;/strong&gt; 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 create-project yasser-elgammal/green
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📚 Documentation
&lt;/h2&gt;

&lt;p&gt;You can view the full documentation and explore the project on GitHub:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/YasserElgammal/green" rel="noopener noreferrer"&gt;Project link on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to explore the code, open issues, or contribute to the project 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 Conclusion
&lt;/h3&gt;

&lt;p&gt;Green Framework is a good choice if you want a clean and simple way to build modern PHP applications without unnecessary complexity.&lt;/p&gt;

</description>
      <category>php</category>
      <category>programming</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Introducing a Rate Limiter Library for Go</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Sun, 18 Jan 2026 22:41:52 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/introducing-a-rate-limiter-library-for-go-42nf</link>
      <guid>https://dev.to/yasserelgammal/introducing-a-rate-limiter-library-for-go-42nf</guid>
      <description>&lt;p&gt;In modern backend systems, &lt;strong&gt;rate limiting&lt;/strong&gt; is essential.&lt;br&gt;&lt;br&gt;
Without it, APIs are exposed to abuse, resource exhaustion, and unfair usage.&lt;/p&gt;

&lt;p&gt;That’s why I built a &lt;strong&gt;production-ready, thread-safe rate limiter library in Go&lt;/strong&gt;, based on the &lt;strong&gt;Token Bucket algorithm&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Token Bucket?
&lt;/h2&gt;

&lt;p&gt;I chose the Token Bucket algorithm because it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allows controlled &lt;strong&gt;bursts of traffic&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Provides &lt;strong&gt;smooth request flow&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Is widely used in production systems&lt;/li&gt;
&lt;li&gt;Is simple to understand and reason about&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each client gets a bucket of tokens that refills over time.&lt;br&gt;&lt;br&gt;
Requests consume tokens — once the bucket is empty, requests are rejected.&lt;/p&gt;




&lt;h2&gt;
  
  
  Library Highlights
&lt;/h2&gt;

&lt;p&gt;This library focuses on correctness and simplicity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Production-ready &amp;amp; thread-safe&lt;/li&gt;
&lt;li&gt;Token Bucket algorithm with burst support&lt;/li&gt;
&lt;li&gt;Fast in-memory storage&lt;/li&gt;
&lt;li&gt;Detailed rate limit results (remaining, retry-after, reset time)&lt;/li&gt;
&lt;li&gt;Extensive unit tests and race-condition testing&lt;/li&gt;
&lt;li&gt;Optional cleanup for stale entries&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;limiter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Rate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Duration&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Second&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Burst&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewMemoryStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Minute&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;rateLimiter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;limiter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewTokenBucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rateLimiter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"user123"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Request allowed"&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;With just a few lines, you get a reliable rate limiter ready for production.&lt;/p&gt;




&lt;h2&gt;
  
  
  Perfect For
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;REST APIs&lt;/li&gt;
&lt;li&gt;Go microservices&lt;/li&gt;
&lt;li&gt;Public-facing services&lt;/li&gt;
&lt;li&gt;Internal tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anything that needs &lt;strong&gt;fair and controlled request handling&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Open Source
&lt;/h2&gt;

&lt;p&gt;The project is open source under the MIT license and open for contributions.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/yasserelgammal/rate-limiter" rel="noopener noreferrer"&gt;https://github.com/yasserelgammal/rate-limiter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you find it useful, feel free to leave a ⭐️&lt;br&gt;&lt;br&gt;
It really helps support open-source work.&lt;/p&gt;

</description>
      <category>go</category>
      <category>opensource</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Technical Debt in Modern Software Development</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Thu, 15 Jan 2026 19:15:10 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/understanding-technical-debt-in-modern-software-development-19id</link>
      <guid>https://dev.to/yasserelgammal/understanding-technical-debt-in-modern-software-development-19id</guid>
      <description>&lt;p&gt;&lt;strong&gt;Technical Debt&lt;/strong&gt; is one of the most important concepts in software engineering and product development. It refers to the &lt;strong&gt;future cost&lt;/strong&gt; created when development teams choose quick, temporary, or sub-optimal solutions instead of implementing the best long-term approach.&lt;/p&gt;

&lt;p&gt;This article explains the meaning of technical debt, why it happens, its risks, and best practices to manage it effectively.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Technical Debt? — Definition
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Technical Debt&lt;/strong&gt; is the “extra work” a team will have to do later because they took shortcuts during development.&lt;/p&gt;

&lt;p&gt;Just like financial debt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You borrow time now (by coding quickly)&lt;/li&gt;
&lt;li&gt;You pay back more time later (due to fixes, refactoring, bugs)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Does Technical Debt Happen?
&lt;/h2&gt;

&lt;p&gt;Technical debt is not always caused by mistakes—it often results from business needs. Common causes include:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Tight deadlines
&lt;/h3&gt;

&lt;p&gt;Teams prioritize delivery speed over clean architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Changing requirements
&lt;/h3&gt;

&lt;p&gt;Unclear or shifting requirements lead to temporary solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Legacy systems
&lt;/h3&gt;

&lt;p&gt;Old technologies and outdated code create unavoidable debt.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Lack of testing
&lt;/h3&gt;

&lt;p&gt;Skipping automated tests increases future risks.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Quick fixes
&lt;/h3&gt;

&lt;p&gt;Temporary patches remain longer than expected.&lt;/p&gt;




&lt;h2&gt;
  
  
  Examples of Technical Debt
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Hard-to-read or unmaintainable code
&lt;/li&gt;
&lt;li&gt;Missing documentation
&lt;/li&gt;
&lt;li&gt;Poor architecture or structure
&lt;/li&gt;
&lt;li&gt;Using deprecated libraries
&lt;/li&gt;
&lt;li&gt;Duplicated logic
&lt;/li&gt;
&lt;li&gt;Large modules without clear separation
&lt;/li&gt;
&lt;li&gt;No automated testing
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These issues may not break the system today, but they slow development dramatically over time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Technical Debt Matters (Business Impact)
&lt;/h2&gt;

&lt;p&gt;Technical debt has a direct impact on product quality and delivery speed:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Slower development
&lt;/h3&gt;

&lt;p&gt;New features take longer because the codebase becomes harder to modify.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. More bugs
&lt;/h3&gt;

&lt;p&gt;Quick solutions often introduce hidden issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Higher maintenance cost
&lt;/h3&gt;

&lt;p&gt;Developers spend more time fixing issues than building features.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Reduced system stability
&lt;/h3&gt;

&lt;p&gt;Legacy components become fragile.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Lower team morale
&lt;/h3&gt;

&lt;p&gt;Developers become frustrated when working with messy or outdated code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Is Technical Debt Always Bad?
&lt;/h2&gt;

&lt;p&gt;No, sometimes it’s &lt;strong&gt;strategic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Teams may intentionally take technical debt to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Release an MVP quickly
&lt;/li&gt;
&lt;li&gt;Validate an idea
&lt;/li&gt;
&lt;li&gt;Meet urgent business requirements
&lt;/li&gt;
&lt;li&gt;Beat a competitor to market
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But like real debt, it must be &lt;strong&gt;tracked and repaid&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Manage and Reduce Technical Debt
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Plan regular refactoring
&lt;/h3&gt;

&lt;p&gt;Allocate time each sprint for code improvements.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Enforce clean code standards
&lt;/h3&gt;

&lt;p&gt;Use style guides, naming conventions, and architecture rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Write automated tests
&lt;/h3&gt;

&lt;p&gt;Unit tests, integration tests, and CI pipelines reduce long-term risk.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Track technical debt
&lt;/h3&gt;

&lt;p&gt;Use backlog items, documentation, or dashboards.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Educate stakeholders
&lt;/h3&gt;

&lt;p&gt;Explain the business impact of unmanaged technical debt.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Avoid “quick fixes” mentality
&lt;/h3&gt;

&lt;p&gt;Make temporary solutions clearly documented and time-boxed.&lt;/p&gt;




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

&lt;p&gt;Technical Debt is a natural part of any software project. It becomes dangerous only when ignored.&lt;br&gt;&lt;br&gt;
By understanding its causes and actively managing it through refactoring, testing, and good engineering practices, teams can build scalable, stable, and future-proof systems.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>performance</category>
      <category>softwareengineering</category>
      <category>software</category>
    </item>
    <item>
      <title>Boost Your Laravel Productivity with “Laravel Debug Remover” VSCode Extension</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Tue, 18 Nov 2025 23:07:59 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/boost-your-laravel-productivity-with-laravel-debug-remover-vscode-extension-154g</link>
      <guid>https://dev.to/yasserelgammal/boost-your-laravel-productivity-with-laravel-debug-remover-vscode-extension-154g</guid>
      <description>&lt;p&gt;Debugging with &lt;code&gt;dd()&lt;/code&gt; is part of every Laravel developer’s workflow.&lt;br&gt;
But forgetting a debug statement inside a controller or Blade file can break production or interrupt API responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Laravel Debug Remover&lt;/strong&gt; automatically scans and removes all &lt;code&gt;dd()&lt;/code&gt; debug statements from your PHP and Blade files.&lt;/p&gt;




&lt;h3&gt;
  
  
  Key Features
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Two Modes
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Current File&lt;/strong&gt; – Cleans debug statements only in the file you're working on
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Entire Workspace&lt;/strong&gt; – Scans and cleans your whole project&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Smart Exclusions
&lt;/h4&gt;

&lt;p&gt;Automatically skips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;vendor&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;node_modules&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;storage&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bootstrap/cache&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can customize the ignored folders from the extension settings.&lt;/p&gt;

&lt;h4&gt;
  
  
  Fully Configurable
&lt;/h4&gt;

&lt;p&gt;Add your own directory exclusions via &lt;code&gt;settings.json&lt;/code&gt;.&lt;br&gt;
Perfect for large Laravel or monolithic codebases.&lt;/p&gt;

&lt;h4&gt;
  
  
  High Performance
&lt;/h4&gt;

&lt;p&gt;Fast and optimized scanning — ideal for projects with hundreds of files.&lt;/p&gt;




&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;Press &lt;strong&gt;CTRL + P&lt;/strong&gt; and choose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Remove all debug statements (Current File)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Remove all debug statements (Entire Workspace)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Supports Both PHP &amp;amp; Blade
&lt;/h3&gt;

&lt;p&gt;Blade templates are parsed safely without breaking UI or logic.&lt;br&gt;
The extension intelligently handles both PHP and Blade syntaxes.&lt;/p&gt;




&lt;h3&gt;
  
  
  Download
&lt;/h3&gt;

&lt;p&gt;📥 &lt;strong&gt;VSCode Marketplace:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=6233c1c4-89f3-48cf-8c88-156b07876860.laravel-debug-remover" rel="noopener noreferrer"&gt;Download from VSCode Marketplace&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;This extension solves a common and painful issue every Laravel developer faces.&lt;br&gt;
If it prevents a production mistake or speeds up your workflow, then it has achieved its goal.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>vscode</category>
      <category>softwaredevelopment</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Introducing Lara SMS – A Flexible Laravel SMS Gateway Package</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Fri, 24 Oct 2025 16:44:11 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/introducing-lara-sms-a-flexible-laravel-sms-gateway-package-2gd1</link>
      <guid>https://dev.to/yasserelgammal/introducing-lara-sms-a-flexible-laravel-sms-gateway-package-2gd1</guid>
      <description>&lt;p&gt;I’m excited to introduce my new Laravel package, Lara SMS, designed to make SMS integration in Laravel projects easier, cleaner, and more flexible.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;💡 Why Lara SMS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Integrating SMS gateways can often be repetitive and inconsistent across projects.&lt;br&gt;
Lara SMS provides a unified and expressive API that allows you to send messages through multiple gateways, all while keeping your codebase elegant and maintainable.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;⚙️ Key Features&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ Multi-provider support&lt;br&gt;
Built using the Strategy Pattern, allowing seamless integration with multiple SMS gateways.&lt;/p&gt;

&lt;p&gt;✅ Fluent Builder&lt;br&gt;
Provides a clean and expressive syntax for message construction using a chainable, fluent interface.&lt;/p&gt;

&lt;p&gt;✅ Fallback Strategies&lt;br&gt;
Choose between “Try All” or “Fail Fast” approaches when handling failed gateway attempts.&lt;/p&gt;

&lt;p&gt;✅ Automatic Retries&lt;br&gt;
Automatically retries sending messages on temporary failures to ensure reliability.&lt;/p&gt;

&lt;p&gt;✅ Comprehensive Logging&lt;br&gt;
Tracks and logs all SMS operations for better monitoring and debugging.&lt;/p&gt;



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

&lt;p&gt;Install the package via Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require yasser-elgammal/lara-sms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🧠 Behind the Scenes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This project taught me a lot about designing scalable and extendable Laravel packages, particularly around architectural design patterns like Strategy and Builder.&lt;/p&gt;

&lt;p&gt;My goal was to create something that’s both powerful and developer-friendly, making SMS workflows in Laravel projects smoother than ever.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔗 GitHub:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/yasserelgammal/lara-sms" rel="noopener noreferrer"&gt;https://github.com/yasserelgammal/lara-sms&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;💬 Feedback Welcome&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m always open to feedback, ideas, and contributions.&lt;br&gt;
If Lara SMS helps simplify your workflow or if you have suggestions for improvement, I’d love to hear from you!&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>github</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Monitor and Save Server Disk Space in Laravel</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Wed, 10 Sep 2025 16:59:07 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/how-to-monitor-and-save-server-disk-space-in-laravel-52g9</link>
      <guid>https://dev.to/yasserelgammal/how-to-monitor-and-save-server-disk-space-in-laravel-52g9</guid>
      <description>&lt;p&gt;When working on &lt;strong&gt;Laravel projects&lt;/strong&gt;, it’s important to keep an eye on your server’s storage usage. Large folders can easily go unnoticed until your server starts running out of space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s a small Laravel helper that:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculates the size of each folder inside &lt;code&gt;storage/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Displays both raw size (bytes) and a &lt;strong&gt;human-readable format&lt;/strong&gt; (KB / MB / GB).&lt;/li&gt;
&lt;li&gt;Allows sorting results &lt;strong&gt;ascending or descending&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This helps a lot when monitoring a live server, so you can quickly find which folders are consuming the most space.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Full code:&lt;/strong&gt; 👇&lt;br&gt;
👉 &lt;a href="https://gist.github.com/YasserElgammal/8629ce93ce9f8b6e9afba89cf7a756f1" rel="noopener noreferrer"&gt;View the code on Gist&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚡ This is a lightweight utility, but it can save you time and help keep your servers clean.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;ul&gt;
&lt;li&gt;The code works starting from &lt;strong&gt;Laravel 10+&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This is just a &lt;strong&gt;small idea&lt;/strong&gt;, and of course, it’s open for customization or further development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🙏 If you found this useful, share it with your network it might save someone else hours of debugging or running out of server space.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why Should You Use Traits in PHP? - 5 Reasons</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Wed, 13 Aug 2025 11:23:47 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/why-should-you-use-traits-in-php-5-reasons-3b13</link>
      <guid>https://dev.to/yasserelgammal/why-should-you-use-traits-in-php-5-reasons-3b13</guid>
      <description>&lt;h3&gt;
  
  
  Introduction:
&lt;/h3&gt;

&lt;p&gt;In PHP, traits are a powerful tool for reusing code across different classes. They help you keep your codebase clean, flexible, and easy to maintain, &lt;strong&gt;Here are five key reasons to use them:&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Reuse code in multiple classes without copying it
&lt;/h3&gt;

&lt;p&gt;Traits let you write a method once and use it in many classes, so you don’t have to duplicate the same logic everywhere.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Avoid single inheritance limit
&lt;/h3&gt;

&lt;p&gt;Since PHP only allows one parent class, traits give you a way to add functionality from multiple sources at the same time.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Keep code DRY (Don’t Repeat Yourself)
&lt;/h3&gt;

&lt;p&gt;Putting shared methods in a trait ensures you write them once and reuse them, reducing the chance of mistakes or inconsistencies.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Mix behaviors into unrelated classes
&lt;/h3&gt;

&lt;p&gt;Traits allow you to add the same features to classes that are not related in the inheritance hierarchy.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Easy to maintain
&lt;/h3&gt;

&lt;p&gt;If you need to update a shared method, you just change it in the trait, and all classes using it automatically get the update.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;PHP traits let you share and reuse methods across multiple unrelated classes, bypassing the single inheritance limit. They help keep code DRY by centralizing common logic, making it easier to maintain—any change in the trait applies to all classes using it.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>laravel</category>
      <category>php</category>
    </item>
    <item>
      <title>How to Structure Your Tests Using AAA (Arrange / Act / Assert)</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Sat, 02 Aug 2025 06:27:45 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/how-to-structure-your-tests-using-aaa-arrange-act-assert-17j4</link>
      <guid>https://dev.to/yasserelgammal/how-to-structure-your-tests-using-aaa-arrange-act-assert-17j4</guid>
      <description>&lt;p&gt;When writing Unit or Feature tests in Laravel, one of the most effective ways to keep your tests clean and easy to follow is by using the &lt;strong&gt;AAA pattern&lt;/strong&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;AAA&lt;/strong&gt; stands for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Arrange&lt;/strong&gt; : Set up your data and dependencies&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Act&lt;/strong&gt; : Execute the behavior or function you want to test&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assert&lt;/strong&gt; : Verify that the result matches your expectations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This &lt;strong&gt;structure&lt;/strong&gt; makes your &lt;strong&gt;tests&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easier to read&lt;/li&gt;
&lt;li&gt;Easier to maintain&lt;/li&gt;
&lt;li&gt;Easier to debug&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Use AAA?
&lt;/h2&gt;

&lt;p&gt;It helps you avoid writing "messy" tests where setup, execution, and assertions are all mixed together.&lt;/p&gt;

&lt;p&gt;By clearly separating the 3 phases of testing, you're more likely to catch bugs early, understand what each test is doing at a glance, and maintain consistency across your codebase.&lt;/p&gt;




&lt;h2&gt;
  
  
  Laravel Example
&lt;/h2&gt;

&lt;p&gt;Here’s a simple &lt;code&gt;Feature Test&lt;/code&gt; example following the AAA pattern:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;test_run_todo_show&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Arrange&lt;/span&gt;
    &lt;span class="nv"&gt;$todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&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;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Act&lt;/span&gt;
    &lt;span class="nv"&gt;$response&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;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/todos/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$todo&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Assert&lt;/span&gt;
    &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertStatus&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="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertViewIs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'todos.show'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertSee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$todo&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;title&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;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The AAA pattern stands for Arrange, Act, Assert.&lt;br&gt;
It separates test setup, execution, and verification for clarity and maintainability.&lt;br&gt;
This structure improves readability, consistency, and debugging.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>tutorial</category>
      <category>testing</category>
    </item>
    <item>
      <title>How Laravel Loads and Caches Translation Files in Localization</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Wed, 30 Jul 2025 16:53:38 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/how-laravel-loads-and-caches-translation-files-in-localization-4gk</link>
      <guid>https://dev.to/yasserelgammal/how-laravel-loads-and-caches-translation-files-in-localization-4gk</guid>
      <description>&lt;p&gt;&lt;strong&gt;Localization&lt;/strong&gt; is one of Laravel's powerful features, allowing developers to support multiple languages seamlessly using either PHP array files or JSON files.&lt;/p&gt;

&lt;p&gt;But one question that often comes up is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Does Laravel cache translations? And how does it handle large translation files?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s break it down and understand what actually happens under the hood.&lt;/p&gt;




&lt;h2&gt;
  
  
  Laravel Supports Two Types of Translation Files
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1️⃣ PHP Array Files
&lt;/h3&gt;

&lt;p&gt;Located in:&lt;br&gt;
&lt;code&gt;/lang/{locale}/messages.php&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Structure:&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'welcome'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Welcome to our website'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'login'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Login here'&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;Usage:&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="nf"&gt;__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'messages.welcome'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2️⃣ JSON Files
&lt;/h3&gt;

&lt;p&gt;Located in:&lt;br&gt;
&lt;code&gt;/lang/{locale}.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Structure:&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Welcome"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Welcome to our website"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Login"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Login here"&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;Usage:&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="nf"&gt;__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Welcome'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  When Does Laravel Load Translation Files?
&lt;/h2&gt;

&lt;p&gt;Laravel &lt;strong&gt;does not load all translation files at once&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It loads a translation file &lt;strong&gt;only when a key is requested from it&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Then it stores the entire file content in memory (an internal PHP array) for the &lt;strong&gt;rest of the current request&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This behavior is implemented inside the &lt;code&gt;Illuminate\Translation\FileLoader&lt;/code&gt; and &lt;code&gt;Translator&lt;/code&gt; classes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Internally&lt;/strong&gt;, Laravel stores loaded translations in a private property like &lt;code&gt;$loaded&lt;/code&gt;, and avoids loading the same file twice during one request.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What Is Runtime Cache?
&lt;/h2&gt;

&lt;p&gt;Runtime cache means that Laravel keeps the translations in memory &lt;strong&gt;only during the current HTTP request&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you call:&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="nf"&gt;__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'messages.welcome'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multiple times during the same request, Laravel will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load the file &lt;strong&gt;once&lt;/strong&gt; via &lt;code&gt;require&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Reuse the cached values in memory for any further translation calls.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This boosts performance by avoiding redundant file reads.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Once the request ends, this cache is &lt;strong&gt;discarded&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Laravel Does NOT Persist Translation Cache
&lt;/h2&gt;

&lt;p&gt;Unlike routes, config, or compiled views, &lt;strong&gt;Laravel does not cache translations to disk&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;There is no &lt;code&gt;php artisan translations:cache&lt;/code&gt; command, and no &lt;code&gt;bootstrap/cache&lt;/code&gt; storage for translations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because translation files are often small, and caching them permanently can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complicated dynamic multilingual updates.&lt;/li&gt;
&lt;li&gt;Increase risk of stale data if edited manually.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What About Large Translation Files?
&lt;/h2&gt;

&lt;p&gt;Laravel &lt;strong&gt;loads the full translation file when a key is requested&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your &lt;code&gt;messages.php&lt;/code&gt; file has 2000 keys, all of them will be loaded into memory when you use any one of them.&lt;/li&gt;
&lt;li&gt;This can have memory implications in huge apps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Practice&lt;/strong&gt;:&lt;br&gt;
Organize your translations into smaller, modular files like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;auth.php&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dashboard.php&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;messages.php&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then reference them as:&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="nf"&gt;__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'dashboard.title'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Quick Recap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Laravel supports both PHP arrays and JSON translation formats.&lt;/li&gt;
&lt;li&gt;Translation files are &lt;strong&gt;loaded only when a key is requested&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Laravel uses &lt;strong&gt;in-memory cache&lt;/strong&gt; for the duration of a single request.&lt;/li&gt;
&lt;li&gt;There is &lt;strong&gt;no persistent disk caching&lt;/strong&gt; for translations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split large translation files&lt;/strong&gt; into smaller files to improve maintainability and memory efficiency.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;If you found this &lt;strong&gt;helpful&lt;/strong&gt;, &lt;strong&gt;share&lt;/strong&gt; it with others it might help someone else too.&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/laravel/framework/blob/11.x/src/Illuminate/Translation/FileLoader.php" rel="noopener noreferrer"&gt;Laravel FileLoader on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/laravel/framework/blob/11.x/src/Illuminate/Translation/Translator.php" rel="noopener noreferrer"&gt;Laravel Translator Class&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>programming</category>
    </item>
    <item>
      <title>The Importance of Rate Limiting and How to Implement It in Laravel</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Thu, 24 Jul 2025 17:41:46 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/the-importance-of-rate-limiting-and-how-to-implement-it-in-laravel-2dp4</link>
      <guid>https://dev.to/yasserelgammal/the-importance-of-rate-limiting-and-how-to-implement-it-in-laravel-2dp4</guid>
      <description>&lt;p&gt;&lt;strong&gt;What Happens When Your API Gets Flooded?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When an API receives too many requests in a short amount of time either from a single user or a large number of users.. it can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Overload your server’s CPU and RAM،&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cause slowdowns or downtime،&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expose vulnerabilities to abuse or malicious attacks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Servers have limited resources. Without protection, excessive requests can crash your system or degrade performance for all users.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;The Solution is Rate Limiting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rate Limiting is a technique that restricts the number of requests a client can make to an API in a given time window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use Rate Limiting?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Protect your server from overload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prevent abuse and spam attacks,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensure fair usage across all users,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enhance security against DDoS and brute-force attacks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;How to Implement Rate Limiting in Laravel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Laravel makes rate limiting simple using its built in middleware and features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Rate Limit with Middleware&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Laravel uses throttle middleware to handle rate limits.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;routes/api.php&lt;/code&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="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'throttle:60,1'&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;group&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="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/user'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;UserController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'index'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/order'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;OrderController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'store'&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;This means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A user can make 60 requests per minute.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Customizing Rate Limits Per User&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can create dynamic rate limits based on the authenticated user:&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;App\Providers\RouteServiceProvider&lt;/code&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="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Cache\RateLimiting\Limit&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\RateLimiter&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;boot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;RateLimiter&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'api'&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;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Limit&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;perMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&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;by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;optional&lt;/span&gt;&lt;span class="p"&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;user&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&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;ip&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;Then apply it to your route:&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="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'throttle:api'&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;group&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="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Protected routes&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;Tips for Production&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Monitor rate limits with tools like Laravel Telescope or API Gateway logs,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Show meaningful error messages for 429 Too Many Requests,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine with IP banning CAPTCHA or authentication for added protection.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rate limiting isn’t just a performance technique, it's a security layer that protects your application and ensures a good experience for all users.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>php</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introducing Laravel Easy Wallet Package</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Tue, 22 Jul 2025 14:56:24 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/introducing-laravel-easy-wallet-package-30i4</link>
      <guid>https://dev.to/yasserelgammal/introducing-laravel-easy-wallet-package-30i4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Laravel Easy Wallet&lt;/strong&gt; is a simple and extensible wallet system for Laravel applications. It allows you to associate wallets with any model, manage balances, and record transactions with support for &lt;code&gt;credit&lt;/code&gt; and &lt;code&gt;debit&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  🚀 Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Attach a wallet to any Eloquent model (&lt;code&gt;walletable&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Automatically create a wallet if it doesn’t exist&lt;/li&gt;
&lt;li&gt;Credit and debit balance safely inside a DB transaction&lt;/li&gt;
&lt;li&gt;Transaction history tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📦 Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require yasser-elgammal/laravel-easy-wallet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  💸 Usage Example
&lt;/h3&gt;

&lt;h3&gt;
  
  
  1. Add Required Relation to related models
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;YasserElgammal\LaravelEasyWallet\Models\Wallet&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;wallet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&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;morphOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'walletable'&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;h3&gt;
  
  
  2. Credit Wallet
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;YasserElgammal\LaravelEasyWallet\Facades\EasyWallet&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;App\Models\User&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nc"&gt;EasyWallet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;credit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;100.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Initial deposit'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Debit Wallet
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;EasyWallet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;debit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;25.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Purchased course'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4. Transfer Between Wallets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$fromUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$toUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nc"&gt;EasyWallet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$fromUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$toUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;40.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Transfer to friend'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  5. Get Wallet Balance
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;EasyWallet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  📌 Why I Built It
&lt;/h3&gt;

&lt;p&gt;I’ve worked on several projects that needed internal balance logic. Each time, I had to rewrite the same concepts. This package is my way of solving that once and for all — for myself and for the community.&lt;/p&gt;




&lt;h3&gt;
  
  
  📥 Contributions &amp;amp; Feedback
&lt;/h3&gt;

&lt;p&gt;I’d love your feedback! If you find this package useful or have suggestions, feel free to open an issue or PR on GitHub.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/yasser-elgammal/laravel-easy-wallet" rel="noopener noreferrer"&gt;github.com/yasser-elgammal/laravel-easy-wallet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Difference Between Helper Functions and Traits in PHP (Laravel)</title>
      <dc:creator>Yasser Elgammal</dc:creator>
      <pubDate>Sun, 29 Jun 2025 06:21:52 +0000</pubDate>
      <link>https://dev.to/yasserelgammal/helper-functions-vs-traits-in-php-laravel-11gc</link>
      <guid>https://dev.to/yasserelgammal/helper-functions-vs-traits-in-php-laravel-11gc</guid>
      <description>&lt;p&gt;As a Laravel developer, you often need to reuse code across different parts of your application. Two powerful tools at your disposal are &lt;strong&gt;Helper Functions&lt;/strong&gt; and &lt;strong&gt;Traits&lt;/strong&gt;. While they may seem similar at a glance, they serve different purposes and are best used in different scenarios.&lt;/p&gt;

&lt;p&gt;In this article, we’ll clearly explain the &lt;strong&gt;differences, use cases, and real-world examples&lt;/strong&gt; of both so you’ll know when to use each.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Helper Function?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Helper Function&lt;/strong&gt; is a globally available function that performs a common task. You don’t need to create an object or class to use it. Helper functions are ideal for simple, stateless tasks that you may need in multiple places.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Characteristics:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Global (accessible anywhere)&lt;/li&gt;
&lt;li&gt;Stateless (doesn’t rely on class properties)&lt;/li&gt;
&lt;li&gt;Simple to write and use&lt;/li&gt;
&lt;li&gt;Great for formatting, calculations, string manipulation, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example:
&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;// helpers.php&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;function_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'format_price'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;format_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;number_format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&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;h3&gt;
  
  
  Usage:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;format_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Outputs: 1,500.00&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is a Trait?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Trait&lt;/strong&gt; is a reusable piece of code that can be included in multiple classes. It’s especially useful when several classes need to share the same methods or behaviors.&lt;/p&gt;

&lt;p&gt;Unlike helper functions, traits &lt;strong&gt;can access class properties&lt;/strong&gt; using &lt;code&gt;$this&lt;/code&gt;, making them suitable for behaviors that depend on the object's internal state.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Characteristics:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used inside a class using &lt;code&gt;use&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Can access &lt;code&gt;$this&lt;/code&gt; and class properties&lt;/li&gt;
&lt;li&gt;Ideal for shared behaviors across models or services&lt;/li&gt;
&lt;li&gt;Keeps code modular and organized&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&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;HasSlug&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;generateSlug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;\Str&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$text&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;h3&gt;
  
  
  Usage:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostController&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;HasSlug&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;store&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;// Logic&lt;/span&gt;
        &lt;span class="nv"&gt;$slug&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;generateSlug&lt;/span&gt;&lt;span class="p"&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="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Other logic&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;h2&gt;
  
  
  When Should You Use Each?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;helper functions&lt;/strong&gt; when your logic is stateless and utility-based.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;traits&lt;/strong&gt; when you need to encapsulate reusable logic that depends on the class context or internal data.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Both &lt;strong&gt;helper functions&lt;/strong&gt; and &lt;strong&gt;traits&lt;/strong&gt; are incredibly useful in Laravel. The key is to use each where it fits best:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;helper functions&lt;/strong&gt; for quick, global logic.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;traits&lt;/strong&gt; to add reusable, object-specific behaviors to your classes they help you get around PHP’s single inheritance limitation.&lt;/li&gt;
&lt;/ul&gt;

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