<?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: wadakatu</title>
    <description>The latest articles on DEV Community by wadakatu (@wadakatu).</description>
    <link>https://dev.to/wadakatu</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%2F805171%2F0d3c6ecc-b57f-4cd8-a0ee-59151e4439d3.jpeg</url>
      <title>DEV Community: wadakatu</title>
      <link>https://dev.to/wadakatu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wadakatu"/>
    <language>en</language>
    <item>
      <title>Lumen (Laravel) v10 to v11: Contextual Binding Changes and Solutions.</title>
      <dc:creator>wadakatu</dc:creator>
      <pubDate>Mon, 14 Apr 2025 02:06:10 +0000</pubDate>
      <link>https://dev.to/wadakatu/lumen-laravel-v10-to-v11-contextual-binding-changes-and-solutions-4o7j</link>
      <guid>https://dev.to/wadakatu/lumen-laravel-v10-to-v11-contextual-binding-changes-and-solutions-4o7j</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When upgrading from Lumen v10 to v11, have you ever been confused by unexpected behavior?&lt;br&gt;&lt;br&gt;
I encountered this issue myself when the changes to Contextual Binding caused previously functional code to stop working.&lt;/p&gt;

&lt;p&gt;In this article, I will explain the changes to Contextual Binding with detailed sample code. We’ll look at how it worked in v10, the issues that arise in v11, and how to fix them step by step.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt; If you’d like to learn more about the basics of Contextual Binding, please refer to the &lt;a href="https://laravel.com/docs/10.x/container#contextual-binding" rel="noopener noreferrer"&gt;official Laravel documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Background of the Changes
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;【Key Changes】

Lumen v10: &lt;span class="sb"&gt;`when`&lt;/span&gt; method-based Contextual Binding applied across the entire DI chain (including indirect dependencies).

Lumen v11: &lt;span class="sb"&gt;`when`&lt;/span&gt; method-based Contextual Binding applies only when directly injected into the specified class.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In Lumen v10, the &lt;code&gt;when&lt;/code&gt; method allowed Contextual Binding to propagate across the entire dependency injection (DI) chain.&lt;br&gt;&lt;br&gt;
In other words, a concrete class specified for one class's dependency was also reflected in subsequent layers of the DI chain.&lt;/p&gt;

&lt;p&gt;However, as of v11, this behavior has changed. The &lt;code&gt;when&lt;/code&gt; method now applies only to cases where the specified class is directly injected.&lt;br&gt;&lt;br&gt;
As a result, code that previously worked might stop functioning as intended.&lt;/p&gt;
&lt;h3&gt;
  
  
  Dependency Diagram
&lt;/h3&gt;

&lt;p&gt;Here’s a diagram showing the dependencies discussed in this article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Behavior in v10:
CreditController ──depends→ MoneyService ──depends→ PaymentInterface
     │                                                 ↑
     └────────────when().needs()───────────────────────┘
     (The PaymentInterface binding is correctly applied from CreditController)

Behavior in v11:
CreditController ──depends→ MoneyService ──depends→ PaymentInterface
     │                       │                         ↑
     └─when().needs()─╳      └─when().needs()──────────┘
     (The binding only applies to direct dependencies)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s explore specific cases where this issue arises, along with code examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example Code in v10
&lt;/h2&gt;

&lt;p&gt;First, let’s look at example code that worked correctly in Lumen v10.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuration in AppServiceProvider
&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;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PaymentInterface&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="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$app&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="k"&gt;new&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;PaymentInterface&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;paymentMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'default'&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;span class="p"&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="n"&gt;app&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CreditController&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PaymentInterface&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;give&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="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;PaymentInterface&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;paymentMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'credit card'&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;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;PaymentInterface&lt;/code&gt; is configured to switch its concrete class based on &lt;code&gt;CreditController&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  CreditController
&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;CreditController&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;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;MoneyService&lt;/span&gt; &lt;span class="nv"&gt;$moneyService&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;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&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="n"&gt;moneyService&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paymentMethod&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;code&gt;CreditController&lt;/code&gt; injects &lt;code&gt;MoneyService&lt;/code&gt;, which internally calls the &lt;code&gt;paymentMethod&lt;/code&gt; of &lt;code&gt;PaymentInterface&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  MoneyService
&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;MoneyService&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;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;PaymentInterface&lt;/span&gt; &lt;span class="nv"&gt;$paymentInterface&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;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;paymentMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&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="n"&gt;paymentInterface&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paymentMethod&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;code&gt;MoneyService&lt;/code&gt; is a class that depends on &lt;code&gt;PaymentInterface&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution Result
&lt;/h3&gt;

&lt;p&gt;When this code is executed in Lumen v10, calling the &lt;code&gt;index&lt;/code&gt; method of &lt;code&gt;CreditController&lt;/code&gt; correctly returns &lt;code&gt;'credit card'&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Issues in v11
&lt;/h2&gt;

&lt;p&gt;What happens if we run the same code in Lumen v11?&lt;/p&gt;

&lt;h3&gt;
  
  
  Cause of the Issue
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;CreditController&lt;/code&gt; injects &lt;code&gt;MoneyService&lt;/code&gt;, which in turn injects &lt;code&gt;PaymentInterface&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
However, in v11, the &lt;code&gt;when&lt;/code&gt; method applies only when directly injecting into the specified class. Therefore, even though &lt;code&gt;CreditController&lt;/code&gt; is the basis of the configuration, the &lt;code&gt;PaymentInterface&lt;/code&gt; passed to &lt;code&gt;MoneyService&lt;/code&gt; remains the default, and &lt;code&gt;'default'&lt;/code&gt; is returned.&lt;/p&gt;
&lt;h3&gt;
  
  
  Execution Result
&lt;/h3&gt;

&lt;p&gt;Calling &lt;code&gt;CreditController&lt;/code&gt; returns &lt;code&gt;'default'&lt;/code&gt; instead of the expected &lt;code&gt;'credit card'&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example of a Failing Test
&lt;/h3&gt;

&lt;p&gt;No explicit error message appears, but the return value differs from expectations. For example, the following test will fail:&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;// Test code&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;testCreditControllerReturnsCorrectPaymentMethod&lt;/span&gt;&lt;span class="p"&gt;()&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;=&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="s1"&gt;'/credit'&lt;/span&gt;&lt;span class="p"&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;assertEquals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'credit card'&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;getContent&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="c1"&gt;// Fails in v11 - 'default' is returned&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In real-world environments, this discrepancy can cause features to break, requiring time-consuming debugging.&lt;/p&gt;




&lt;h2&gt;
  
  
  Fixed Code Example (v11-Compatible)
&lt;/h2&gt;

&lt;p&gt;How can we make this code work correctly in Lumen v11?&lt;br&gt;&lt;br&gt;
The fix is simple: change the basis of the &lt;code&gt;when&lt;/code&gt; method to &lt;code&gt;MoneyService&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuration in AppServiceProvider
&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;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PaymentInterface&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="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$app&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="k"&gt;new&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;PaymentInterface&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;paymentMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'default'&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;span class="p"&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="n"&gt;app&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CreditController&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;needs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MoneyService&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;give&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="nv"&gt;$creditCardInterface&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;PaymentInterface&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;paymentMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'credit card'&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MoneyService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$creditCardInterface&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Key Fix

&lt;span class="sb"&gt;`needs(PaymentInterface::class)`&lt;/span&gt; → &lt;span class="sb"&gt;`needs(MoneyService::class)`&lt;/span&gt;

Consider the DI chain, and specify the class that directly requires the interface.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key here is changing the basis of the &lt;code&gt;needs&lt;/code&gt; method from &lt;code&gt;PaymentInterface&lt;/code&gt; to &lt;code&gt;MoneyService&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
This ensures that the correctly configured &lt;code&gt;PaymentInterface&lt;/code&gt; is injected into &lt;code&gt;MoneyService&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  CreditController
&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;CreditController&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;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;MoneyService&lt;/span&gt; &lt;span class="nv"&gt;$moneyService&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;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&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="n"&gt;moneyService&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paymentMethod&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;
  
  
  MoneyService
&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;MoneyService&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;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;PaymentInterface&lt;/span&gt; &lt;span class="nv"&gt;$paymentInterface&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;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;paymentMethod&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&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="n"&gt;paymentInterface&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paymentMethod&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;
  
  
  Execution Result
&lt;/h3&gt;

&lt;p&gt;With this fixed code, calling the &lt;code&gt;index&lt;/code&gt; method of &lt;code&gt;CreditController&lt;/code&gt; correctly returns &lt;code&gt;'credit card'&lt;/code&gt;.&lt;/p&gt;




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

&lt;p&gt;In summary, Lumen v11 enforces stricter scoping for Contextual Binding.&lt;br&gt;&lt;br&gt;
As a result, when using the &lt;code&gt;when&lt;/code&gt; method, you need to carefully specify the correct class within the DI chain.&lt;/p&gt;

&lt;p&gt;If you’ve encountered this behavior during an upgrade, please share your experience in the comments! If you know of alternative solutions or related documentation, feel free to share those as well :)&lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://laravel.com/docs/10.x/container#contextual-binding" rel="noopener noreferrer"&gt;Laravel v10 Contextual Binding Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://laravel.com/docs/11.x/container#contextual-binding" rel="noopener noreferrer"&gt;Laravel v11 Contextual Binding Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>lumen</category>
      <category>servicecontainer</category>
    </item>
    <item>
      <title>How to Handle Excessive Warning Messages When Running `pecl install grpc`</title>
      <dc:creator>wadakatu</dc:creator>
      <pubDate>Wed, 25 Dec 2024 17:42:14 +0000</pubDate>
      <link>https://dev.to/wadakatu/how-to-handle-excessive-warning-messages-when-running-pecl-install-grpc-44jb</link>
      <guid>https://dev.to/wadakatu/how-to-handle-excessive-warning-messages-when-running-pecl-install-grpc-44jb</guid>
      <description>&lt;h2&gt;
  
  
  Overwhelming Warning Messages Can Be a Nuisance
&lt;/h2&gt;

&lt;p&gt;When running pecl install grpc, you might encounter an avalanche of warning messages like these:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#7 67.72 /tmp/pear/temp/grpc/src/core/lib/promise/detail/promise_factory.h:174:5: warning: 'always_inline' function might not be inlinable [-Wattributes]&lt;/span&gt;

&lt;span class="c"&gt;#7 352.5 /tmp/pear/temp/grpc/src/core/lib/event_engine/forkable.h:61:34: warning: 'unused' attribute ignored [-Wattributes]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There can be hundreds of these warnings, flooding your logs. This has been especially problematic during deployment, where CI/CD pipelines would exceed log limits, causing errors and halting the process.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Root Cause
&lt;/h2&gt;

&lt;p&gt;Searching for the warning messages online points to GCC, the GNU Compiler Collection.&lt;/p&gt;

&lt;p&gt;It turns out these warnings are generated by the compiler when building gRPC's source code. Since the warnings originate from gRPC’s source code, it’s not feasible for users to fix the source code directly to suppress the warnings.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Fortunately, GCC provides several options to suppress warning messages, which you can pass to the compiler during the build process:&lt;/p&gt;

&lt;p&gt;Warning Options in GCC Documentation&lt;/p&gt;

&lt;p&gt;However, there’s no straightforward way to pass these options directly when running pecl install grpc. If you know of one, please let me know—I’ll celebrate with tears of joy! 🥹&lt;/p&gt;

&lt;p&gt;So, what now?&lt;/p&gt;

&lt;p&gt;The answer came to me from a StackOverflow thread: Instead of letting pecl install handle everything, you can break the process into smaller steps and pass the options during the compilation phase.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://stackoverflow.com/a/47120441" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since gRPC is written in C++, we can use environment variables like CFLAGS and CXXFLAGS to specify options that suppress the warnings during compilation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://wiki.gentoo.org/wiki/GCC_optimization/ja" rel="noopener noreferrer"&gt;Gentoo Wiki on GCC Optimization&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;Let’s assume gRPC is being installed in a Dockerfile.&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;pecl &lt;span class="nb"&gt;install &lt;/span&gt;grpc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  After
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;pecl download grpc &lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;tar &lt;/span&gt;xzf &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;ls &lt;/span&gt;grpc-&lt;span class="k"&gt;*&lt;/span&gt;.tgz | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; grpc-&lt;span class="k"&gt;*&lt;/span&gt;/ | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; phpize &lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ./configure &lt;span class="nt"&gt;--with-php-config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/bin/php-config &lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;CFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-Wno-attributes -Wno-unused-parameter -Wno-deprecated-declarations -Wno-return-type"&lt;/span&gt; &lt;span class="nv"&gt;CXXFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-Wno-attributes -Wno-unused-parameter -Wno-deprecated-declarations -Wno-return-type"&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The after commands mimic what pecl install does internally, but with more control. Breaking down the process revealed just how much pecl install handles behind the scenes—impressive!&lt;/p&gt;

&lt;p&gt;The warnings appeared during the make phase, so I passed the suppression options via the CFLAGS and CXXFLAGS environment variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;make &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;CFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-Wno-attributes -Wno-unused-parameter -Wno-deprecated-declarations -Wno-return-type"&lt;/span&gt; &lt;span class="nv"&gt;CXXFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-Wno-attributes -Wno-unused-parameter -Wno-deprecated-declarations -Wno-return-type"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  How to Identify Suppression Options
&lt;/h4&gt;

&lt;p&gt;To determine which suppression options to use, look at the end of the warning messages. You’ll often see hints like [-Wattributes] or [-Wunused-parameter]. Add &lt;code&gt;no&lt;/code&gt; to the beginning of these, e.g., -Wno-attributes or -Wno-unused-parameter, to suppress them.&lt;/p&gt;

&lt;p&gt;For more details, refer to the official documentation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html" rel="noopener noreferrer"&gt;Warning Options in GCC Documentation&lt;/a&gt;&lt;/p&gt;




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

&lt;p&gt;With this approach, I successfully escaped the swamp of gRPC warning messages. However, this didn’t fully resolve the CI/CD log limit issue, which I’ll address in a future post.&lt;/p&gt;

&lt;p&gt;If this article helps even one person escape the gRPC warning message swamp, I’ll be delighted! 🙌&lt;/p&gt;

</description>
      <category>grpc</category>
      <category>php</category>
      <category>docker</category>
      <category>gcc</category>
    </item>
    <item>
      <title>Laravel 9, NO LTS Support!?</title>
      <dc:creator>wadakatu</dc:creator>
      <pubDate>Tue, 22 Feb 2022 15:36:00 +0000</pubDate>
      <link>https://dev.to/wadakatu/laravel-9-no-lts-support-1fll</link>
      <guid>https://dev.to/wadakatu/laravel-9-no-lts-support-1fll</guid>
      <description>&lt;h2&gt;
  
  
  Latest LTS finally!!
&lt;/h2&gt;

&lt;p&gt;Laravel 9 was finally released on February 22nd, 2022.&lt;/p&gt;

&lt;p&gt;At first, we are thrilled with &lt;strong&gt;LTS (Long Term Support) of Laravel 9&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, Mr.Otwell (The author of Laravel) &lt;strong&gt;decided to postpone the LTS&lt;/strong&gt;.&lt;/p&gt;

&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%2Fgh77yqoslpe6bzb6dcw3.png" 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%2Fgh77yqoslpe6bzb6dcw3.png" alt="RELEASE DIFF" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Postponed?
&lt;/h2&gt;

&lt;p&gt;You can find out the reason why the LTS is postponed on Mr.Otwell Tweet.&lt;/p&gt;

&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%2Fmbg8slxfn2l07e69vfjj.png" 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%2Fmbg8slxfn2l07e69vfjj.png" alt="Twitter" width="800" height="1289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In short, &lt;strong&gt;a &lt;a href="https://github.com/symfony/symfony/pull/45377" rel="noopener noreferrer"&gt;pull request&lt;/a&gt; on Symfony Repository&lt;/strong&gt; causes the postponement of the LTS.&lt;/p&gt;

&lt;h2&gt;
  
  
  LTS Again?
&lt;/h2&gt;

&lt;p&gt;The answer is "Maybe or Maybe not".&lt;/p&gt;

&lt;p&gt;In my opinion, if the &lt;a href="https://github.com/symfony/symfony/pull/45377" rel="noopener noreferrer"&gt;PR&lt;/a&gt; were rejected, There would be high probability that the LTS comes back.&lt;/p&gt;

&lt;p&gt;What do you think about it?&lt;br&gt;
Feel free to leave your thought on discussion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update! PHP 8.1 needed from Symfony 6.1
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/symfony/symfony/pull/45377" rel="noopener noreferrer"&gt;PR&lt;/a&gt; was merged yesterday on Symfony.&lt;/p&gt;

&lt;p&gt;Therefore, PHP 8.1 will be the minimum requirement for Symfony 6.1.&lt;/p&gt;

&lt;p&gt;Read this article for more information.&lt;br&gt;
&lt;a href="https://symfony.com/blog/symfony-6-1-will-require-php-8-1" rel="noopener noreferrer"&gt;https://symfony.com/blog/symfony-6-1-will-require-php-8-1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Laravel, they have already merged a &lt;a href="https://github.com/laravel/framework/pull/41250" rel="noopener noreferrer"&gt;PR&lt;/a&gt; which changes the minimum PHP Version From 8.0 to 8.1 for Laravel 10.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>symfony</category>
      <category>laravel9</category>
    </item>
    <item>
      <title>[Laravel 8.x] Refactor Factory Call with One Command</title>
      <dc:creator>wadakatu</dc:creator>
      <pubDate>Thu, 03 Feb 2022 11:01:03 +0000</pubDate>
      <link>https://dev.to/wadakatu/laravel-8x-refactor-factory-call-with-one-command-4p8h</link>
      <guid>https://dev.to/wadakatu/laravel-8x-refactor-factory-call-with-one-command-4p8h</guid>
      <description>&lt;h2&gt;
  
  
  Factory call changed
&lt;/h2&gt;

&lt;p&gt;In Laravel 8.x, the style of factory call was changed from helper to static method.&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;//Laravel 7.x or earlier&lt;/span&gt;
&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;//Laravel 8.x&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;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;make&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It takes plenty of times to fetch this change into your application if you do by yourself.&lt;/p&gt;

&lt;p&gt;Don't worry. I made a package to refactor all of them with &lt;strong&gt;Just One Command.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Laravel-Factory-Refactor&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://packagist.org/packages/wadakatu/laravel-factory-refactor" rel="noopener noreferrer"&gt;https://packagist.org/packages/wadakatu/laravel-factory-refactor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This package will help you to refactor the style of factory call from helper to static method for Laravel 8.x.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Installation
&lt;/h3&gt;

&lt;p&gt;You can install the package via 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 wadakatu/laravel-factory-refactor &lt;span class="nt"&gt;--dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Run Artisan Command
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan refactor:factory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Voila, Refactor Completed !
&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;//Before&lt;/span&gt;
&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;App\Models\User&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="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&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="mi"&gt;10&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;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;App\Models\User&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="mi"&gt;10&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;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//After&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;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;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;App\Models\User&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;make&lt;/span&gt;&lt;span class="p"&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;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="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&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;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;App\Models\User&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="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&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;make&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In conclusion
&lt;/h2&gt;

&lt;p&gt;'Laravel-Factory-Refactor' is my first package ever in my life.&lt;/p&gt;

&lt;p&gt;From now on, I am going to do my best to update this package to make it better.&lt;br&gt;
I hope you are going to like it.&lt;/p&gt;

&lt;p&gt;Moreover, I am looking forward to getting stars in Github⭐️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/wadakatu/laravel-factory-refactor" rel="noopener noreferrer"&gt;https://github.com/wadakatu/laravel-factory-refactor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>opensource</category>
      <category>firstpost</category>
    </item>
  </channel>
</rss>
