The Blog

Writing about PHP, Laravel, software architecture, and everything I learn along the way.

search
Oct 23, 2025

How to structure Laravel API with Spatie Data

Why Spatie Data fits modern Laravel APIs

In modern Laravel apps, we want clear boundaries: controllers should coordinate, actions should do work, and data should move in and out in a predictable way. Spatie’s laravel-data package gives you Data objects (like DTOs) with helpful features: typed properties, validation, casting, and easy serialization. That means less glue code and fewer bugs from loose arrays.

Data classes help you:

  • Build explicit contracts for requests and responses.
  • Keep controllers thin by hydrating input into typed objects.
  • Serialize output in a consistent shape (including nested relations).
  • Add transformations and default values in one place.
  • Reduce drift between your docs, your code, and what clients actually get.

The result? A clean API that is easy to maintain, test, and scale.


Sep 30, 2025

How to render realtime record with firebase in react the right way

If you’ve ever worked with Firebase Realtime Database, you know how magical it feels to see data update instantly in your app. But here’s the catch: once your database starts growing to thousands or even millions of records, that magic can quickly turn into lag, unnecessary bandwidth costs, and frustrated users.

A common mistake is to subscribe to an entire node and dump everything into state. It works fine when your dataset is small — but at scale, you’ll end up trying to render way more than your UI (or your users) can handle.

The good news? You don’t have to choose between “realtime” and “performance.” With the right approach, you can keep your app fast, efficient, and responsive even as your database grows.

Sep 23, 2025

Outbound AI Agents with VICIdial + Ultravox

I’ve been experimenting with combining VICIdial (classic Asterisk-based dialer) with Ultravox (speech-language model for real-time voice AI). The goal: let the dialer place calls, route live answers to an AI bot, and then transfer to a human closer when needed.

Most call centers still run VICIdial, one of the most reliable dialers out there. But what if every live answer could be handled first by an AI agent—qualifying, answering FAQs, even delivering compliance lines—before a closer picks up?

Sep 06, 2025

How to create an MCP server with PHP

One of the biggest challenges in AI adoption is connecting models with the right tools and data securely. That’s where MCP comes in.

Model Context Protocol (MCP) is a new open standard designed by Anthropic to improve how AI models access and interact with external information and tools. At its core, MCP is about making AI agents more capable, scalable, and secure by decoupling the agent from the messy context management and custom tool integrations that developers currently juggle.

Jul 31, 2025

How to Safely Build Dynamic Tracking Links with Query Parameters in JavaScript

When working with affiliate platforms like Everflow, it's common to dynamically append tracking parameters (e.g., sub1, sub2) to a base tracking link.

At first glance, this seems straightforward: simply concatenate the parameters with an ampersand (&). But if you’re not careful, you could end up with broken links, double question marks (??), or missing values. In this post, we’ll explore a safe, modern way to build URLs with query parameters using JavaScript’s URL and URLSearchParams APIs.

Jul 20, 2025

Trigger Outbound Calls from Laravel Using VICIdial API Wrapper

VICIdial is one of the most powerful open-source contact center solutions in the world, but integrating it with modern web applications like Laravel can be a challenge—especially if you're trying to initiate outbound calls programmatically.

In this post, you'll learn how to trigger outbound calls from Laravel using the masterfermin02/vicidial-api-wrapper package and VICIdial’s external_dial Non-Agent API function.