DEV Community

Brian Majasi
Brian Majasi

Posted on

How I Built a Custom PHP MVC Framework Without Composer (And Sold It for $8k)

Everyone says you need Laravel, Symfony, or WordPress to build a professional web app. They’re wrong. Recently, I built a custom SaaS-level platform for a high-end Safari operator. The requirements were strict: extreme speed, total ownership (no rented templates), and tight security for high-value invoicing. Here is how I architected a custom MVC framework from scratch using PHP 8, PDO, and zero external dependencies—no composer require in sight.

1. The Architecture: Why No Composer? "Modern frameworks are great, but they come with 'dependency hell.' For Mosmapson Tours, I needed a system that would be robust for years without breaking every time a vendor updated a minor package.

- The Stack: Core PHP, MySQL (PDO), Vanilla JS.
- The Asset: A drag-and-drop itinerary builder (Vanilla JS + SortableJS) and a custom CMS.
- The Pitch: Speed and Ownership. This isn't a WordPress site that gets hacked if you miss a plugin update.

2. The Router (The Heart of the System) Instead of a heavy routing engine, I built a lightweight regex router. It parses the URI and dispatches to the correct Controller class dynamically.

// Core Router Concept
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$parts = explode('/', trim($uri, '/'));

// Simple dispatch logic
$controllerName = ucfirst($parts[0]) . 'Controller';
if (class_exists($controllerName)) {
    $controller = new $controllerName();
    $controller->index();
} else {
    // Fallback to 404
}
Enter fullscreen mode Exit fullscreen mode

3. Security: The "Backbone" Approach SQL injection is the enemy. Since I wasn't using an ORM like Eloquent, I strictly used PDO with prepared statements. I also implemented a custom env.php loader to keep credentials out of the web root—vital for a platform managing invoices worth P100,000+.

*4. The "Smart Formatter" Feature *"The client needed to format itineraries quickly without a heavy WYSIWYG editor. I built a parser that converts simple syntax into styled HTML on the fly:

  • text converts to Bold Gold (Brand Identity).
  • + text converts to a ✅ Checkmark list item.

5. The Business Case : Technical excellence is useless if it doesn't sell. By avoiding WordPress, I sold the client on Performance and Security. They own the code, the database, and the IP. The site loads instantly, and the admin dashboard is tailored exactly to their fleet management needs.

Conclusion & Link "You don't always need a massive framework. Sometimes, a custom-built solution is the professional choice for high-end clients. View the full case study and the live site on my portfolio: www.sageandre.com

Top comments (0)