Search by

mkaram / laravel-snap

mohamedkaram123

Granular pattern and feature snapshotting system for Laravel.

v1.5.6 2026-08-27 02:58 UTC

This package is auto-updated.

Last update: 2026-08-27 03:09:46 UTC


README

Latest Version on Packagist Total Downloads PHP Versions Laravel Versions License

Granular pattern capture, architectural blueprint scaffolding, dependency-aware transplantation, and native AI MCP engine for Laravel.

Laravel Snap Demo

💡 Why Laravel Snap?

Moving features between Laravel applications (like Wallet, OTP, Subscription, or Invoicing) is traditionally messy:

  • You manually hunt down dozens of scattered files across app/, database/, and config/.
  • You waste time fixing namespaces, imports, and broken timestamps on migrations.
  • You run into Class not found errors when third-party packages are missing.

Laravel Snap turns any feature into a portable, dependency-aware architectural blueprint that you can snapshot and install into any target Laravel project in seconds.

✨ Key Features

  • 🔍 Deep Multi-Layer Discovery: Recursively scans Models, Services, Actions, Contracts, DTOs, Events, Controllers, Requests, Resources, Notifications, Jobs, Policies, Rules, Migrations, and Config.
  • ⚡ AST-Powered Skeleton Mode (--skeleton): Uses PHP Abstract Syntax Tree parsing (nikic/php-parser) to strip method bodies while keeping strict return types, docblocks, and properties intact — generating pristine domain interfaces ready for logic implementation.
  • 📦 Smart Dependency Resolver: Scans imported use statements against installed.json, identifies required 3rd-party Composer packages (e.g. stripe/stripe-php), and offers interactive auto-installation during setup.
  • ✅ Interactive File Selection: During snap:install, choose exactly which blueprint files to import (or press Enter to install all).
  • 🔄 Dynamic PSR-4 Namespace Translation: Tokenizes root namespaces on snapshot and rebinds them dynamically to match the target project's application namespace.
  • 🕒 Safe Database Migrations: Automatically recalculates migration timestamps upon installation to ensure correct schema execution order without conflicts.
  • 🤖 Native Model Context Protocol (MCP) Server: Seamless stdio integration with Cursor, Windsurf, and Claude Code to scaffold patterns right from your AI prompt.
  • 🐳 Docker & Team-Ready: Zero-config storage path resolution supporting Host OS, Docker containers, and project-level Git repository sharing.

🚀 Installation

Install the package via Composer into your Laravel application:

composer require mkaram/laravel-snap --dev

Optionally publish the config:

php artisan vendor:publish --tag=snap-config

🛠️ Quick Usage

1. Capture a feature (source project):

php artisan snap:pattern wallet --all
php artisan snap:pattern otp --skeleton
php artisan snap:pattern invoice --only=domain,database

2. List saved blueprints:

php artisan snap:list

3. Install into another Laravel app:

php artisan snap:install wallet
php artisan snap:install wallet --force
php artisan snap:install wallet --only=domain,database

During install, Snap may:

  • prompt to composer require missing packages
  • let you multi-select which files to import

4. Help dashboard:

php artisan snap

5. AI / MCP server (Cursor, Windsurf):

php artisan snap:mcp

🆕 What's New

  • Interactive multi-select file import on snap:install
  • snap command dashboard for quick command discovery
  • Full English code comments / docs across the package
  • Structured docs under docs/ (getting started, AST skeleton, deps, CLI, MCP)
  • Cross-platform storage via PathResolver (SNAP_STORAGE_PATH or ~/.laravel-snap/patterns)

📚 Documentation

Full guides live in docs/:

Guide Description
Introduction What Laravel Snap is and the problems it solves
AST Skeleton Mode --skeleton blueprints powered by nikic/php-parser
Dependency Resolution How Composer packages travel with a snapshot
CLI Reference snap:pattern, snap:install, and snap:list
Cursor & MCP Integration Native stdio MCP server for Cursor and Windsurf