Skip to main content

Posts

Showing posts with the label Architecture

Strangler Fig Pattern: Sharing Auth Sessions Between Legacy PHP and Next.js

  The Strangler Fig pattern is the de facto standard for migrating legacy monoliths, but it hits a concrete wall immediately: Authentication. You have a legacy PHP application (Laravel, Symfony, or vanilla) serving the root domain. You deploy a Next.js App Router instance to handle specific routes (e.g.,  /dashboard/analytics ). You configure your load balancer (Nginx/AWS ALB) to route traffic correctly. The browser sends the  PHPSESSID  (or  laravel_session ) cookie to the Next.js server. However, your Next.js application treats the user as unauthenticated. The Root Cause: Serialization Incompatibility The issue is not network reachability or cookie scope. If both apps sit on  example.com , the browser transmits the cookies to both backends. The failure occurs at the  deserialization layer . Storage Format:  PHP sessions are typically stored on the file system ( /var/lib/php/sessions ) or Redis. PHP uses a proprietary serialization format (e.g.,...