<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Arun Tyagi - Laravel & SaaS]]></title><description><![CDATA[Arun Tyagi - Laravel & SaaS]]></description><link>https://aruntyagi-laravel.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 19:39:57 GMT</lastBuildDate><atom:link href="https://aruntyagi-laravel.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Securing a Laravel API before launch: a 10-point checklist]]></title><description><![CDATA[Most Laravel APIs I review aren't hacked through anything clever. They leak because of defaults nobody changed. Here's the checklist I run before an API…]]></description><link>https://aruntyagi-laravel.hashnode.dev/securing-a-laravel-api-before-launch-a-10-point-checklist</link><guid isPermaLink="true">https://aruntyagi-laravel.hashnode.dev/securing-a-laravel-api-before-launch-a-10-point-checklist</guid><category><![CDATA[Laravel]]></category><category><![CDATA[Security]]></category><category><![CDATA[APIs]]></category><category><![CDATA[PHP]]></category><dc:creator><![CDATA[Arun Tyagi]]></dc:creator><pubDate>Fri, 20 Nov 2026 16:20:46 GMT</pubDate><content:encoded><![CDATA[<p>Most Laravel APIs I review aren't hacked through anything clever. They leak because of defaults nobody changed. Here's the checklist I run before an API goes live for a client's mobile app or SPA.</p>
<h2>1. <code>APP_DEBUG=false</code> in production</h2>
<p>With debug on, a single exception can show your <code>.env</code> values, SQL queries and file paths to anyone. Check it on the live server, not just in the repo.</p>
<h2>2. Pick one auth approach and use it properly</h2>
<ul>
<li><strong>Sanctum</strong> for your own SPA or mobile app</li>
<li><strong>Passport</strong> only if third parties need OAuth</li>
</ul>
<p>Give tokens <strong>abilities</strong> (<code>$user-&gt;createToken('app', ['orders:read'])</code>) and check them, rather than giving every token full access.</p>
<h2>3. Authorize every resource, not just "logged in"</h2>
<p><code>auth:sanctum</code> only proves <em>who</em> the user is. Use Policies so user A can't fetch <code>/api/orders/125</code> that belongs to user B:</p>
<pre><code class="language-php">public function show(Order $order)
{
    $this-&gt;authorize('view', $order);
    return new OrderResource($order);
}
</code></pre>
<p>This IDOR bug is the single most common issue I find.</p>
<h2>4. Never return raw models</h2>
<p><code>return $user;</code> can expose fields you forgot existed. Use API Resources and whitelist the fields you return.</p>
<h2>5. Validate everything with Form Requests</h2>
<p>Also guard against mass assignment: use <code>$fillable</code>, never <code>$guarded = []</code> on models that take user input.</p>
<h2>6. Rate limiting</h2>
<p>Laravel ships with it, so use it, and be stricter on login and OTP routes:</p>
<pre><code class="language-php">RateLimiter::for('login', fn ($request) =&gt;
    Limit::perMinute(5)-&gt;by($request-&gt;ip())
);
</code></pre>
<h2>7. CORS: list your real origins</h2>
<p><code>'allowed_origins' =&gt; ['*']</code> with credentials is asking for trouble. Put your actual front-end domains in <code>config/cors.php</code>.</p>
<h2>8. HTTPS only, and secure cookies</h2>
<p>Force HTTPS at the server or load balancer. For Sanctum SPA auth, set <code>SESSION_SECURE_COOKIE=true</code> and the correct <code>SANCTUM_STATEFUL_DOMAINS</code>.</p>
<h2>9. Secrets out of the repo</h2>
<p><code>.env</code> should never be committed. Rotate any key that ever was. Keep payment-gateway and SMS keys on the server only.</p>
<h2>10. Log and alert</h2>
<p>Log failed logins and 403s, and use an error tracker (Sentry, Flare or Bugsnag). You want to hear about a spike in 401s before your users do.</p>
<hr />
<p><strong>Bonus:</strong> run <code>composer audit</code> before every release. It flags packages with known vulnerabilities in seconds.</p>
<p>I build and secure Laravel APIs for startups and businesses across Delhi NCR. More about my work here: <a href="https://aruntyagi.com/laravel-developer-delhi-ncr">Laravel developer in Delhi NCR</a>.</p>
<p><em>Arun Tyagi is a freelance Laravel developer in Noida, India.</em></p>
]]></content:encoded></item><item><title><![CDATA[Your developer disappeared? A checklist for taking over an existing Laravel project]]></title><description><![CDATA[A surprising number of my projects start with: "Our previous developer stopped replying, and the app is live." Taking over someone else's Laravel codebase…]]></description><link>https://aruntyagi-laravel.hashnode.dev/your-developer-disappeared-a-checklist-for-taking-over-an-existing-laravel-project</link><guid isPermaLink="true">https://aruntyagi-laravel.hashnode.dev/your-developer-disappeared-a-checklist-for-taking-over-an-existing-laravel-project</guid><dc:creator><![CDATA[Arun Tyagi]]></dc:creator><pubDate>Tue, 17 Nov 2026 17:08:56 GMT</pubDate><content:encoded><![CDATA[<p>A surprising number of my projects start with: <em>"Our previous developer stopped replying, and the app is live."</em> Taking over someone else's Laravel codebase is very doable, but only if you do it in the right order. Here's the checklist I follow.</p>
<h2>1. Secure access before touching code</h2>
<p>Get these into the <strong>owner's</strong> name first:</p>
<ul>
<li>Domain registrar and DNS</li>
<li>Hosting / server (SSH keys, control panel)</li>
<li>Git repository (GitHub, GitLab, Bitbucket)</li>
<li>Database credentials and backups</li>
<li>Third-party accounts: payment gateway, email provider, SMS, cloud storage</li>
</ul>
<p>Rotate passwords and API keys the old developer had, and remove their SSH keys from the server.</p>
<h2>2. Take a full backup</h2>
<p>Before running a single command: a database dump, a copy of <code>storage/</code> and uploaded files, and the current <code>.env</code>. Store them somewhere off the server.</p>
<h2>3. Find out what's actually running</h2>
<ul>
<li><code>php artisan --version</code> and <code>php -v</code>. Old Laravel on old PHP is the most common situation.</li>
<li><code>composer outdated</code> to see how far behind the dependencies are.</li>
<li>Compare the code on the server with the repository. Hot-fixes made directly on production are very common.</li>
<li>Check <code>crontab -l</code> and the queue workers (Supervisor / Horizon). Scheduled jobs are the easiest thing to break unknowingly.</li>
</ul>
<h2>4. Get it running locally</h2>
<p>If the project doesn't boot on a fresh machine from the repo and a sanitized database copy, that's your first task. Write down every step in a <code>README</code>. That document is half the value of a takeover.</p>
<h2>5. Add a safety net</h2>
<p>Before fixing anything, write a few smoke tests: login, the main create/update flow, one payment or checkout path and one queued job. Set up error tracking (Sentry, Flare or at least proper log monitoring).</p>
<h2>6. Only then: fix, upgrade, improve</h2>
<p>Prioritize in this order:</p>
<ol>
<li>Security issues (exposed <code>.env</code>, debug mode on in production, unpatched packages)</li>
<li>Bugs that are costing money right now</li>
<li>Performance problems (N+1 queries, missing indexes, no caching)</li>
<li>Version upgrades, one major version at a time</li>
<li>New features</li>
</ol>
<hr />
<p>If you're in this situation right now, I've written up how I handle Laravel maintenance and takeovers here: <a href="https://aruntyagi.com/maintenance-support">Website maintenance &amp; support</a>.</p>
<p><em>Arun Tyagi is a freelance Laravel developer in Noida, India.</em></p>
]]></content:encoded></item><item><title><![CDATA[The N+1 query problem in Laravel: how to spot it in 5 minutes on a client app]]></title><description><![CDATA[When a client says "the dashboard got slow after we added more customers", the cause is usually not the server. Nine times out of ten it's an N+1 query…]]></description><link>https://aruntyagi-laravel.hashnode.dev/the-n-1-query-problem-in-laravel-how-to-spot-it-in-5-minutes-on-a-client-app</link><guid isPermaLink="true">https://aruntyagi-laravel.hashnode.dev/the-n-1-query-problem-in-laravel-how-to-spot-it-in-5-minutes-on-a-client-app</guid><category><![CDATA[laravelphp]]></category><category><![CDATA[performance]]></category><dc:creator><![CDATA[Arun Tyagi]]></dc:creator><pubDate>Fri, 13 Nov 2026 03:28:09 GMT</pubDate><content:encoded><![CDATA[<p>When a client says "the dashboard got slow after we added more customers", the cause is usually not the server. Nine times out of ten it's an N+1 query hiding in a Blade loop. Here's the quick routine I use on any Laravel app I inherit.</p>
<h2>What N+1 looks like</h2>
<pre><code class="language-php">$orders = Order::latest()-&gt;take(50)-&gt;get();

foreach ($orders as $order) {
    echo $order-&gt;customer-&gt;name; // one extra query per order
}
</code></pre>
<p>That's 1 query for the orders plus 50 for the customers. With 500 orders, it's 501 queries on one page.</p>
<h2>Step 1: Make Laravel tell you</h2>
<p>In <code>AppServiceProvider::boot()</code>, during development only:</p>
<pre><code class="language-php">use Illuminate\Database\Eloquent\Model;

Model::preventLazyLoading(! app()-&gt;isProduction());
</code></pre>
<p>Now any lazy-loaded relationship throws an exception locally, so you see the problem the moment the page loads instead of in production.</p>
<h2>Step 2: Count queries on the slow page</h2>
<p>Install Laravel Debugbar or Telescope locally and open the slow page. If the query count grows with the number of rows on screen, you've found an N+1.</p>
<h2>Step 3: Fix it with eager loading</h2>
<pre><code class="language-php">$orders = Order::with('customer')-&gt;latest()-&gt;take(50)-&gt;get();
</code></pre>
<p>Two queries instead of fifty-one. For nested relationships, use <code>with('customer.company')</code>. For counts, use <code>withCount('items')</code> instead of <code>$order-&gt;items-&gt;count()</code> in the loop.</p>
<h2>Step 4: Watch for the hidden ones</h2>
<ul>
<li><strong>Accessors and appended attributes</strong> that touch a relationship.</li>
<li><strong>API Resources</strong> that include relationships without <code>whenLoaded()</code>.</li>
<li><strong>Policies</strong> called inside loops (<code>@can</code> in Blade) that query the database.</li>
</ul>
<h2>Why this matters for SaaS</h2>
<p>In a multi-tenant SaaS, every customer adds rows. An N+1 that was invisible with 10 test records becomes a timeout with 10,000 real ones. Catching it early is far cheaper than scaling the server.</p>
<hr />
<p>I've written a longer walkthrough with more real-world examples here: <a href="https://aruntyagi.com/blog/how-to-fix-the-n1-query-problem-in-laravel">How to fix the N+1 query problem in Laravel</a>.</p>
<p><em>Arun Tyagi is a freelance Laravel and SaaS developer in Noida, India.</em></p>
]]></content:encoded></item></channel></rss>