<?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: Md Foisal</title>
    <description>The latest articles on DEV Community by Md Foisal (@foisal).</description>
    <link>https://dev.to/foisal</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1688567%2F3860f995-dcf4-4b04-b112-9a1d32ab9514.png</url>
      <title>DEV Community: Md Foisal</title>
      <link>https://dev.to/foisal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/foisal"/>
    <language>en</language>
    <item>
      <title>Tandoor House: one restaurant, seven screens, built in Laravel and React</title>
      <dc:creator>Md Foisal</dc:creator>
      <pubDate>Sat, 28 Nov 2026 09:17:26 +0000</pubDate>
      <link>https://dev.to/foisal/tandoor-house-one-restaurant-seven-screens-built-in-laravel-and-react-104n</link>
      <guid>https://dev.to/foisal/tandoor-house-one-restaurant-seven-screens-built-in-laravel-and-react-104n</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/NwxVs3GprHQ" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;A restaurant on a busy night is seven different jobs happening at once. The guest orders, the cashier takes money, the kitchen cooks, the waiter seats people, the rider delivers, the manager watches stock and the owner wants numbers. Tandoor House gives each of those people their own screen in one app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it covers:&lt;/strong&gt; ordering for delivery, pickup, dine-in and table QR; table booking with deposits; cashier; kitchen display; waiter floor plan; rider runs; manager stock and rota; owner reports.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One decision that shaped it:&lt;/strong&gt; every automation has its own on and off switch. A restaurant owner does not trust software that does things on its own on day one. So nothing runs by itself until the owner turns it on, one rule at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stack:&lt;/strong&gt; Laravel 13, React 19, Inertia 3, TypeScript strict, Tailwind 4, Reverb for live updates, Stripe in test mode, 7 roles. The README states 2,508 Pest tests and PHPStan level 7.&lt;/p&gt;

&lt;p&gt;It started as a test brief at the office for a made-up UK restaurant, so all data in the film is demo data.&lt;/p&gt;

&lt;p&gt;Live demo: &lt;a href="https://tandoorhouse.onrender.com" rel="noopener noreferrer"&gt;https://tandoorhouse.onrender.com&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/Md-Foisal/tandoor-house" rel="noopener noreferrer"&gt;https://github.com/Md-Foisal/tandoor-house&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>react</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Why env() returns null in production after php artisan config:cache</title>
      <dc:creator>Md Foisal</dc:creator>
      <pubDate>Thu, 26 Nov 2026 15:44:26 +0000</pubDate>
      <link>https://dev.to/foisal/why-env-returns-null-in-production-after-php-artisan-configcache-90d</link>
      <guid>https://dev.to/foisal/why-env-returns-null-in-production-after-php-artisan-configcache-90d</guid>
      <description>&lt;p&gt;It works on your laptop. You deploy. Now your API key is &lt;code&gt;null&lt;/code&gt;, and nothing in the code changed.&lt;/p&gt;

&lt;p&gt;Very often the reason is one function: &lt;code&gt;env()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What config:cache does
&lt;/h2&gt;

&lt;p&gt;In production most Laravel apps run this during deploy:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;It takes every file in &lt;code&gt;config/&lt;/code&gt; and writes them into one cached PHP file. Laravel loads that one file instead of many, so every request starts a bit faster.&lt;/p&gt;

&lt;p&gt;There is one side effect. Once the config is cached, Laravel does not load your &lt;code&gt;.env&lt;/code&gt; file anymore. The Laravel docs say it directly: after caching, &lt;code&gt;env()&lt;/code&gt; only returns real system level environment variables.&lt;/p&gt;

&lt;p&gt;So any &lt;code&gt;env()&lt;/code&gt; call outside &lt;code&gt;config/&lt;/code&gt; now reads from nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the bug looks
&lt;/h2&gt;

&lt;p&gt;Say a service calls a payment API:&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;// app/Services/PaymentClient.php&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PaymentClient&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="nf"&gt;charge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$amount&lt;/span&gt;&lt;span class="p"&gt;)&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="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT_API_KEY'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// fine locally, null after config:cache&lt;/span&gt;

        &lt;span class="nc"&gt;Http&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;withToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;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;'https://api.example.com/charges'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'amount'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$amount&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="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;On your machine there is no cached config, so Laravel reads &lt;code&gt;.env&lt;/code&gt; and &lt;code&gt;$key&lt;/code&gt; has a value. In production the config is cached, &lt;code&gt;.env&lt;/code&gt; is skipped, and &lt;code&gt;$key&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt;. The request goes out with no token and the API answers 401.&lt;/p&gt;

&lt;p&gt;The code did not change. Only the way Laravel boots changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Two rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Call env() only inside config files.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config/services.php&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'payment'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'key'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT_API_KEY'&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="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;When &lt;code&gt;config:cache&lt;/code&gt; runs, this line runs once, reads the value, and the value is saved inside the cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Everywhere else, read it with config().&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/Services/PaymentClient.php&lt;/span&gt;
&lt;span class="nv"&gt;$key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.payment.key'&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;config()&lt;/code&gt; reads from the cache in production and from the config files locally, so it gives the same answer in both places.&lt;/p&gt;

&lt;h2&gt;
  
  
  A check before every deploy
&lt;/h2&gt;

&lt;p&gt;Search for &lt;code&gt;env(&lt;/code&gt; outside &lt;code&gt;config/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -rn &lt;span class="s2"&gt;"env("&lt;/span&gt; app routes resources database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anything it finds should move into a config file and be read with &lt;code&gt;config()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can also make your laptop behave like production for a minute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan config:cache
php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If something breaks now, it would have broken after deploy. Clear it again when you are done:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  One more thing to remember
&lt;/h2&gt;

&lt;p&gt;After you change &lt;code&gt;.env&lt;/code&gt; on the server, the app still uses the old cached values. Run &lt;code&gt;php artisan config:cache&lt;/code&gt; again as part of the deploy, every time.&lt;/p&gt;




&lt;p&gt;I build web apps in Laravel and MERN and design the system before the code. More of my work: &lt;a href="https://github.com/Md-Foisal" rel="noopener noreferrer"&gt;https://github.com/Md-Foisal&lt;/a&gt;&lt;/p&gt;

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