<?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[Amjad]]></title><description><![CDATA[software engineering]]></description><link>https://blog.amjad.codes</link><image><url>https://cloudmate-test.s3.us-east-1.amazonaws.com/uploads/logos/623660408e4fae3f767ddf9f/def48ac5-b60b-415c-8119-1eaf79194e34.png</url><title>Amjad</title><link>https://blog.amjad.codes</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 22:30:31 GMT</lastBuildDate><atom:link href="https://blog.amjad.codes/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Monitor Your Laravel App with LaraScope]]></title><description><![CDATA[You've deployed your Laravel app. Users are hitting your endpoints. But do you know which routes are slow? How many SQL queries a single request fires? How much memory it's consuming?
Most of the time]]></description><link>https://blog.amjad.codes/larascope</link><guid isPermaLink="true">https://blog.amjad.codes/larascope</guid><category><![CDATA[Laravel]]></category><category><![CDATA[PHP]]></category><category><![CDATA[monitoring]]></category><category><![CDATA[http]]></category><category><![CDATA[SQL]]></category><dc:creator><![CDATA[Amjad AH]]></dc:creator><pubDate>Mon, 20 Apr 2026 00:23:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/623660408e4fae3f767ddf9f/cfb409fd-2d40-4846-bcfd-20e82c06678e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You've deployed your Laravel app. Users are hitting your endpoints. But do you know which routes are slow? How many SQL queries a single request fires? How much memory it's consuming?</p>
<p>Most of the time, we find out about these things <em>after</em> something breaks. LaraScope fixes that, it's a Laravel package I built to give you real-time visibility into every HTTP request your app handles, with zero setup friction.</p>
<p>In this article, I'll walk you through what LaraScope does, how it works, and how to get it running in your project in under 5 minutes.</p>
<hr />
<h2>The Problem</h2>
<p>Debugging performance issues in Laravel usually means one of the following:</p>
<ul>
<li><p>Dumping queries with <code>DB::enableQueryLog()</code> and forgetting to remove it</p>
</li>
<li><p>Installing Laravel Telescope (great tool, but heavy if you only care about HTTP + SQL)</p>
</li>
<li><p>Paying for an external APM service and sending your data to a third party</p>
</li>
</ul>
<p>I wanted something in the middle, <strong>lightweight, self-hosted, and focused</strong>.</p>
<hr />
<h2>Introducing LaraScope</h2>
<p>LaraScope is a Laravel package that automatically logs every HTTP request passing through your app, capturing:</p>
<ul>
<li><p>✅ HTTP method, URL, path, and named route</p>
</li>
<li><p>✅ Response status code</p>
</li>
<li><p>✅ Request duration (ms)</p>
</li>
<li><p>✅ Peak memory usage (MB)</p>
</li>
<li><p>✅ Every SQL query fired, with raw SQL, bindings, and execution time</p>
</li>
<li><p>✅ Slow query detection with a configurable threshold</p>
</li>
<li><p>✅ Authenticated user ID</p>
</li>
<li><p>✅ Request headers (with sensitive ones stripped by default)</p>
</li>
</ul>
<p>All of this is stored in <strong>your own database</strong>, and browsable through a <strong>built-in dashboard</strong>, no external service, no API key, no data leaving your infrastructure.</p>
<hr />
<h2>Installation</h2>
<p>Getting started is a single command:</p>
<pre><code class="language-shell">composer require amjad-ah/larascope
</code></pre>
<p>Then publish the config and migration:</p>
<pre><code class="language-shell">php artisan vendor:publish --tag=larascope-config
php artisan vendor:publish --tag=larascope-migrations
php artisan migrate
</code></pre>
<p>That's it. LaraScope <strong>automatically injects itself</strong> into your <code>web</code> and <code>api</code> middleware groups. No manual <code>Kernel.php</code> edits, no service provider registration, it just works.</p>
<hr />
<h2>The Dashboard</h2>
<p>Once installed, navigate to <code>/larascope</code> in your browser and you'll see the live request log.</p>
<img src="https://cdn.hashnode.com/uploads/covers/623660408e4fae3f767ddf9f/72eec0bb-9fa3-4bb3-a7cb-35b429993b85.png" alt="Dashboard overview — the main list view showing all logged requests with method, path, status code, duration, query count, and memory usage" style="display:block;margin:0 auto" />

<p>The list gives you an at-a-glance view of every request: method badge, path, status code, how long it took, how many queries it ran, and peak memory. You can immediately spot the slow ones.</p>
<h3>Filtering</h3>
<p>The dashboard comes with built-in filters so you're not drowning in noise:</p>
<img src="https://cdn.hashnode.com/uploads/covers/623660408e4fae3f767ddf9f/09dc2150-608f-45bc-b2f0-d81d4db28da3.png" alt="Dashboard filters — showing the filter bar with HTTP method dropdown, status code input, and path search field" style="display:block;margin:0 auto" />

<p>You can filter by:</p>
<ul>
<li><p><strong>HTTP Method</strong>: show only <code>POST</code> or <code>GET</code> requests</p>
</li>
<li><p><strong>Status Code</strong>: find all <code>500</code> errors or <code>404</code>s in seconds</p>
</li>
<li><p><strong>Path</strong>: search by partial path, e.g. <code>/api/users</code></p>
</li>
</ul>
<blockquote>
<p>🚧 <strong>Coming soon:</strong> I'm working on advanced filters, think filtering by slow queries, response time ranges, and more. The goal is to make the dashboard a proper debugging tool, not just a log viewer.</p>
</blockquote>
<h3>Request Detail</h3>
<p>Click any entry to drill into the full detail view:</p>
<img src="https://cdn.hashnode.com/uploads/covers/623660408e4fae3f767ddf9f/47f84874-2ed6-412f-bc45-822b68916d39.png" alt="Request detail view — showing full URL, headers, all SQL queries with execution times, slow query badges, and memory usage" style="display:block;margin:0 auto" />

<p>Here you get:</p>
<ul>
<li><p>The full URL and route name</p>
</li>
<li><p>All SQL queries with their raw SQL, bindings, execution time, and a <strong>"slow"</strong> badge if they exceeded your threshold</p>
</li>
<li><p>Request headers (after filtering out <code>Authorization</code>, <code>Cookie</code>, and <code>X-CSRF-TOKEN</code>)</p>
</li>
<li><p>Peak memory usage</p>
</li>
<li><p>Total request duration</p>
</li>
</ul>
<hr />
<h2>Slow Query Detection</h2>
<p>One of my favourite features. Every captured SQL query is automatically compared against a configurable threshold:</p>
<pre><code class="language-php">// config/larascope.php
'queries' =&gt; [
    'enabled'           =&gt; true,
    'slow_threshold_ms' =&gt; 100, // flag any query taking over 100ms
],
</code></pre>
<p>If a query exceeds the threshold, it gets flagged as slow. The <code>RequestLog</code> model even exposes a helper for this:</p>
<pre><code class="language-php">$log-&gt;hasSlowQueries(); // true if any query was slow
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/623660408e4fae3f767ddf9f/1700b5d8-53a5-4d66-99f8-c005c1b123a7.png" alt="Slow query badge in the detail view — showing a query highlighted with a &quot;slow&quot; label and its execution time in red" style="display:block;margin:0 auto" />

<hr />
<h2>Privacy First</h2>
<p>LaraScope is designed to be production-safe out of the box.</p>
<p><strong>Request and response bodies are disabled by default.</strong> You have to explicitly opt in:</p>
<pre><code class="language-php">'logging' =&gt; [
    'include_request_headers' =&gt; true,
    'include_request_body'    =&gt; false,  // opt-in
    'include_response_body'   =&gt; false,  // opt-in

    // Sensitive headers are always stripped:
    'exclude_headers' =&gt; [
        'authorization',
        'cookie',
        'x-csrf-token',
    ],
],
</code></pre>
<p>You can also exclude entire paths or HTTP methods from being logged:</p>
<pre><code class="language-php">'exclude_paths'   =&gt; ['health', '_debugbar/*', 'telescope/*'],
'exclude_methods' =&gt; ['OPTIONS'],
</code></pre>
<blockquote>
<p>💡 Dashboard routes (<code>/larascope/*</code>) are always auto-excluded to prevent infinite log growth.</p>
</blockquote>
<hr />
<h2>Securing the Dashboard</h2>
<p>By default the dashboard is open. Before going to production, add <code>auth</code> to its middleware:</p>
<pre><code class="language-php">'dashboard' =&gt; [
    'path'       =&gt; env('LARASCOPE_DASHBOARD_PATH', 'larascope'),
    'middleware' =&gt; ['web', 'auth'], // 👈 add this
],
</code></pre>
<hr />
<h2>Keeping Logs Under Control</h2>
<p>LaraScope ships with a built-in prune command to clean up old records:</p>
<pre><code class="language-bash">php artisan larascope:prune
</code></pre>
<p>By default it retains 30 days of logs. Schedule it so you never have to think about it:</p>
<pre><code class="language-php">// routes/console.php (Laravel 11+)
Schedule::command('larascope:prune')-&gt;daily();
</code></pre>
<hr />
<h2>Octane Compatible</h2>
<p>LaraScope is built to work correctly with <strong>Laravel Octane</strong>. Since the middleware can be a singleton in a persistent runtime, every request resets its own state at the start of <code>handle()</code>, preventing query data from bleeding across requests.</p>
<hr />
<h2>LaraScope vs. Telescope</h2>
<p>A fair question: why not just use Telescope?</p>
<table>
<thead>
<tr>
<th>Feature</th>
<th>LaraScope</th>
<th>Telescope</th>
</tr>
</thead>
<tbody><tr>
<td>HTTP request logging</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>SQL query logging</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>Slow query flagging</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>Memory tracking</td>
<td>✅</td>
<td>❌</td>
</tr>
<tr>
<td>Jobs / Queues / Mail</td>
<td>❌</td>
<td>✅</td>
</tr>
<tr>
<td>Exception tracking</td>
<td>❌</td>
<td>✅</td>
</tr>
<tr>
<td>Built-in dashboard</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>Privacy defaults</td>
<td>Strict</td>
<td>Moderate</td>
</tr>
<tr>
<td>Setup overhead</td>
<td>Minimal</td>
<td>Moderate</td>
</tr>
</tbody></table>
<p>If you need full-stack observability, jobs, mail, notifications, exceptions, Telescope is the right call. If you want <strong>fast, focused HTTP + SQL monitoring</strong> with minimal setup, LaraScope is a great fit.</p>
<hr />
<h2>Wrapping Up</h2>
<p>LaraScope started as a personal tool because I kept reaching for <code>DB::enableQueryLog()</code> in the same five situations over and over. Packaging it up properly forced me to think about edge cases I hadn't considered, Octane state isolation, privacy defaults, log growth, and the result is something I actually use in my own projects.</p>
<p>If it solves a problem you've had, give it a try and drop a ⭐ on the repo.</p>
<p><strong>GitHub:</strong> <a href="https://github.com/amjadAH/larascope">github.com/amjadAH/larascope</a></p>
<pre><code class="language-bash">composer require amjad-ah/larascope
</code></pre>
<hr />
<p><em>Have a feature request or found a bug? Open an issue on GitHub, contributions are welcome!</em></p>
]]></content:encoded></item><item><title><![CDATA[ACID and BASE in Databases: Key Differences Explained]]></title><description><![CDATA[ACID and BASE are acronyms for different database properties, describing how the database behaves during processing a transaction,

ACID:
A: Atomicity:
it ensures that all steps or statements in a transaction are fully applied committed, or fully rev...]]></description><link>https://blog.amjad.codes/acid-vs-base</link><guid isPermaLink="true">https://blog.amjad.codes/acid-vs-base</guid><category><![CDATA[database]]></category><category><![CDATA[SQL]]></category><category><![CDATA[NoSQL]]></category><category><![CDATA[ACID Transactions]]></category><category><![CDATA[Databases]]></category><dc:creator><![CDATA[Amjad AH]]></dc:creator><pubDate>Sat, 25 Jan 2025 21:34:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/lRoX0shwjUQ/upload/364894ebe45bfdd8b8f7d26eb8a22a21.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>ACID</strong> and <strong>BASE</strong> are acronyms for different database properties, describing how the database behaves during processing a transaction,</p>
<hr />
<h2 id="heading-acid">ACID:</h2>
<h3 id="heading-a-atomicity">A: Atomicity:</h3>
<p>it ensures that all steps or statements in a transaction are fully applied <code>committed</code>, or fully reverted <code>rolled-back</code>,</p>
<p>for example, if we have an ordering system, which has <code>orders</code> table, and <code>order_items</code> table, while placing an order, we want to insert the order first, them the order items, imagine that the connection lost or any error occurred after inserting the order, now we have an empty order without any items in it, this is where we will need to roll-back the order insertion, to avoid the empty order.</p>
<h3 id="heading-c-consistency">C: Consistency:</h3>
<p>it ensures that the data integrity, even when we have multiple users using the system at the same time,</p>
<p>for example, let’s build on the example before, let’s imagine that <code>orders</code> table has a column named <code>total</code>, which refers to the total amount of the order, and <code>order_items</code> table has a column named <code>price</code>, the value of <code>orders.total</code> should be <strong>exactly</strong> <code>sum(order_items.price</code>.</p>
<h3 id="heading-i-isolation">I: Isolation:</h3>
<p>it ensures that any new transaction should wait for other transactions which are working on the same records to finish, to make sure that concurrent transactions <strong>don’t interfere with each</strong> other,</p>
<p>for example, let’s continue building on the same example, imagine a user is order the last item of a specific product, and at the same time another one is trying to buy the same product, the second transaction should wait for the first one to finish so it can proceed.</p>
<h3 id="heading-d-durability">D: Durability:</h3>
<p>it ensures that once a transaction is committed to the database, it will <strong>never</strong> get lost, even if the system experienced failure or anything,</p>
<p>for example, in the same ordering system, once you have placed an order, it can never be lost</p>
<hr />
<h2 id="heading-base">BASE:</h2>
<h3 id="heading-ba-basically-available">BA: Basically Available:</h3>
<p>it means that the system will <strong>always respond to requests</strong>, even if some parts of it are failing or operating with degraded performance. Instead of guaranteeing immediate consistency (like <strong>ACID</strong>), the system prioritizes <strong>availability</strong> by allowing temporary inconsistencies.</p>
<h3 id="heading-s-soft-state">S: Soft State:</h3>
<p>it means that the state of the data can be changed automatically, even without any external triggers or inputs, This contrasts with a <strong>strictly consistent state</strong> (like <strong>ACID</strong>), where the data is immediately consistent after each transaction.</p>
<h3 id="heading-e-eventually-consistent">E: <strong>Eventually consistent:</strong></h3>
<p>it means the system may allow <strong>temporarily</strong> inconsistent data, that will <strong>eventually</strong> converge to a consistent state after a period of time, as long as no new updates are made.</p>
<hr />
<h2 id="heading-key-differences-between-acid-and-base">Key Differences Between ACID and BASE:</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Feature</strong></td><td><strong>ACID</strong></td><td><strong>BASE</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Consistency</strong></td><td>strict and immediate</td><td>eventual</td></tr>
<tr>
<td><strong>Availability</strong></td><td>sacrifices availability</td><td>prioritiezes availability</td></tr>
<tr>
<td><strong>Complexity</strong></td><td>higher</td><td>simpler</td></tr>
<tr>
<td><strong>Use Cases</strong></td><td>finance, sensitive data…</td><td>social media, insensitive data…</td></tr>
<tr>
<td><strong>Performance</strong></td><td>slower, due to strict rules</td><td>faster</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item></channel></rss>