Overview Transitioning a local Laravel project into a production-ready API for platforms like RapidAPI requires more than just functional code. It demands standardization, rigorous versioning, and comprehensive documentation. This process demonstrates how to transform a basic PHP backend into a commercial-grade product using Codex CLI to accelerate the heavy lifting of boilerplate and documentation. Prerequisites To follow this workflow, you should be comfortable with Laravel 11 fundamentals, basic terminal usage, and the Composer package manager. You will also need a RapidAPI account to test the final deployment and local access to an AI agent like Codex CLI to replicate the automated refactoring steps. Key Libraries & Tools * **Laravel**: The primary PHP framework providing the application structure. * **Codex CLI**: An AI-driven terminal agent used for refactoring routes and generating docblocks. * **Scramble**: A documentation package that generates OpenAPI (Swagger) files automatically from Laravel code without manual YAML authoring. * **RapidAPI**: The marketplace platform where the API is hosted and monetized. Code Walkthrough Step 1: Initialize and Version After running `laravel new` and `php artisan install:api`, the first task is establishing a versioned prefix. This ensures future updates don't break existing client integrations. ```php // bootstrap/app.php or routes/api.php Route::prefix('v1')->group(function () { Route::post('/clean-text', [TextCleanerController::class, 'handle']); }); ``` Step 2: Health Monitoring Public platforms require a health check endpoint to monitor uptime. This simple route returns a `200 OK` status to verify the service is alive. ```php // routes/api.php Route::get('/health', function () { return response()->json(['status' => 'ok']); }); ``` Step 3: Automated Documentation Using Scramble, we add PHP docblocks to controllers. The AI agent can analyze the Scramble documentation and apply these tags automatically. ```php /** * Clean Text * * This endpoint removes whitespace and normalizes text input. * @bodyParam text string required The raw text to clean. */ public function handle(Request $request) { // Logic here } ``` Syntax Notes Notice the use of **Laravel's Route::prefix**; this is a best practice for API longevity. Additionally, the **Scramble** package relies on specific `@bodyParam` and `@response` tags within docblocks to build the OpenAPI JSON schema. Using an AI agent to write these prevents syntax errors in the documentation that could cause RapidAPI import failures. Tips & Gotchas * **Environment Sync**: Ensure your `APP_ENV` is set correctly. Scramble often restricts documentation access in production environments by default; you must configure the gate in the `ScrambleServiceProvider` to allow RapidAPI to fetch the schema. * **Testing Versions**: When refactoring to a `/v1/` prefix, update your Pest or PHPUnit tests immediately. Use a global variable for the version string to avoid hardcoding it in every test file.
Pest
Products
- Apr 20, 2026
- Apr 9, 2026
- Mar 20, 2026
- Mar 19, 2026
- Mar 14, 2026
Overview: The Context Gap in AI Development AI agents have changed how we write code, but they often struggle with the nuances of specific frameworks. Standard models like Claude 3.5 Sonnet or GPT-4o possess vast general knowledge but lack the hyper-specific context of your local Laravel project. This lead to hallucinations, outdated syntax, or the AI suggesting patterns that conflict with your application's architecture. Laravel Boost solves this by acting as a bridge. It injects project-specific metadata, documentation, and "skills" directly into your AI agent's reasoning loop. Instead of manually feeding documentation to a chat window, Boost automates the context delivery. Version 2.0 introduces a major shift from a monolithic guideline approach to a modular, "skills-first" architecture. This reduces context bloat, saves on token costs, and makes the AI significantly more accurate by only providing the information it needs at that exact moment. Prerequisites To follow this guide and implement Boost 2.0, you should be comfortable with the following: * **PHP 8.2+:** Boost 2.0 has officially dropped support for PHP 8.1. * **Laravel 11 or 12:** Older versions like Laravel 10 are supported only by legacy versions of Boost (v1.x). * **Composer:** Basic knowledge of managing PHP dependencies. * **AI Coding Agents:** Familiarity with tools like Cursor, Claude Code, GitHub Copilot, or Juni. Key Libraries & Tools * **Laravel Boost:** The core CLI tool and package that manages AI context and skills. * **Laravel MCP:** A package for building Model Context Protocol servers, allowing AI agents to interact with your app's internal state (routes, database schemas, etc.). * **Remotion:** A React-based framework for programmatic video creation, often used as a demonstration of complex AI skill integration. * **Prism:** A Laravel package for working with LLMs, used to demonstrate how documentation can be bundled directly into vendor folders for AI consumption. Code Walkthrough: Installing and Configuring Boost 2.0 Setting up Boost 2.0 is a methodical process. It begins with the Laravel installer and moves into a randomized, aesthetically pleasing configuration CLI. 1. Installation First, ensure your Laravel installer is up to date to access the built-in Boost prompts during new project creation. If you are adding it to an existing project, use Composer: ```bash composer require laravel/boost --dev ``` 2. Initialization Run the install command to start the interactive configuration. ```bash php artisan boost:install ``` This command triggers a CLI interface featuring randomized gradients—a touch of "developer joy" added by Pushpak Chhajed. You will be prompted to select which features to configure: AI Guidelines, Agent Skills, or the MCP server. 3. Selecting Your AI Agent Boost 2.0 simplifies agent selection. Instead of choosing both an IDE and an agent, you now choose the specific agentic tool you use daily, such as Claude Code or Cursor. Boost will then automatically determine the correct file paths for these tools. 4. Automated Skill Syncing To ensure your AI context stays updated as your project evolves, add the update command to your `composer.json` file: ```json "scripts": { "post-update-cmd": [ "@php artisan boost:update" ] } ``` This ensures that every time you update your dependencies, Boost re-scans your `composer.json` and syncs the relevant skills for packages like Inertia, Tailwind CSS, or Livewire. Deep Dive into Skills vs. Guidelines Understanding the distinction between these two features is critical for a clean development workflow. Guidelines: The Global Rules Guidelines are persistent. They contain high-level rules that the AI should *always* know. For example, if you always use Pest for testing or strictly follow an Action-based architecture, these belong in your guidelines. However, shoving every package's documentation into a guideline leads to "context fatigue," where the AI becomes overwhelmed and starts to hallucinate. Skills: The On-Demand Context Skills are modular Markdown files. They aren't loaded into the AI's memory until they are needed. Each skill has a name and a description in its front matter. When you ask the AI to "build a new UI component with Tailwind," the agent sees the keyword "Tailwind," looks at its available skills, and activates the Tailwind CSS skill. This keeps the prompt lean and the output precise. Syntax Notes: Custom Skill Creation Creating a custom skill allows you to automate highly specific tasks, like generating pull request descriptions or adhering to internal API versioning standards. Skills rely on a specific Markdown front matter format. ```markdown --- name: my-custom-skill description: Use this skill when generating API endpoints or PR descriptions. --- My Custom Skill Rules - Always use the `App\Actions` namespace for business logic. - Ensure all API responses are wrapped in a standard `JsonResource`. - Pull Request descriptions must include a 'Breaking Changes' section. ``` When you save this in a local `.boost/skills` directory and run `php artisan boost:update`, Boost replicates this file into the hidden configuration folders of your chosen AI agents (e.g., `.cursor/rules` or `.claudecode/skills`). Practical Examples Automating Pull Requests You can create a skill that teaches an agent how to use the GitHub CLI. By invoking the skill with a slash command (e.g., `/create-pr`), the AI can analyze your staged changes, write a formatted description, and execute the CLI command to open the PR. Package-Specific Intelligence If you build a project using Filament, you don't want the AI thinking about Filament when you are just debugging a console command. By using a Filament skill, the AI only accesses those specific layout and component rules when you are actively working on the admin panel. Tips & Gotchas * **Git Management:** Never commit the auto-generated agent folders (like `.cursor/rules`) to your repository. These are local mirrors. Only commit the `.boost` folder and your `boost.json` file. This allows your teammates to run `boost:install` and get the exact same AI behavior on their machines. * **Hallucination Prevention:** If your AI starts ignoring your project structure, check your guideline length. If it exceeds 500 lines, move package-specific rules into individual skills. * **Legacy Projects:** Do not attempt to use Boost 2.0 on Laravel 10 projects. The dependency tree for the new MCP features and skills requires the modern internals found in Laravel 11 and up. * **Manual Invocation:** If an agent fails to auto-detect a skill, you can usually force it by using a slash command in the chat interface. Most modern agents support `/` to list and select active skills.
Jan 30, 2026Synchronizing AI Logic Managing multiple AI coding assistants like Claude Dev, Cursor, and Open Code often leads to context fragmentation. You define project rules in one tool, but another remains oblivious. Laravel Boost 2.0 solves this by acting as the single source of truth. It synchronizes project-specific logic across all your agents simultaneously, ensuring every tool understands your architectural decisions without manual configuration. Guidelines vs. Agent Skills In earlier versions, Laravel Boost relied heavily on guidelines—global context loaded at the start of every chat. This often bloated the context window and wasted tokens. Boost 2.0 introduces **Agent Skills**, a specialized format based on the emerging Open Code standard. Unlike guidelines, skills load dynamically. Your agent only accesses the Livewire or Pest skill when the current task actually requires that specific expertise. This makes your prompts roughly 40% leaner while maintaining high precision. Implementation and CLI Workflow Setting up Boost 2.0 is straightforward for both new and existing projects. For current applications, use Composer to upgrade the package. If you are starting fresh with the Laravel installer, the setup process now prompts you to configure Boost features immediately. ```bash Add a third-party skill from the community php artisan boost:add-skill remote-dev/remotion Sync changes after manual overrides php artisan boost:update ``` When you add skills, Boost handles the messy work of directory mapping. It knows Claude Dev expects files in `.claudecode/` while others might look in `.ai/`. You manage one `skill.md` file, and Boost distributes it to the correct hidden directories. Custom Overrides and Best Practices Standardized skills are excellent, but your team might have unique conventions. You can override any default skill by mirroring its folder structure within your project's local directory. By placing a custom `skill.md` in your local path and running the update command, you force the AI agents to prioritize your specific instructions over the defaults. For team collaboration, keep your `.ai/` folder in version control but add individual agent folders (like `.claudecode/` or `.cursor/`) to your `.gitignore` to avoid environment conflicts.
Jan 28, 2026Overview: Why Your AI Agent Needs a Boost AI models like Claude and GPT-4 are powerful, but they arrive at your codebase as strangers. They possess a massive, static library of internet-scale training data, but they lack the specific, real-time context of your unique Laravel application. This gap often leads to what developers call "hallucinations"—code that looks correct but fails to follow your team's conventions or uses deprecated patterns. Laravel Boost is designed to solve this context deficiency. It acts as a bridge, packaging your application's routes, configuration, and coding standards into a format that AI agents can ingest and act upon. With the release of Boost 2.0, the focus has shifted from merely providing static instructions to implementing dynamic **Skills** and the **Model Context Protocol (MCP)**. This evolution allows developers to manage the "Context Window"—the finite memory of an AI model—with surgical precision, ensuring the agent only sees what it needs to see to complete a specific task. Prerequisites: Setting the Stage To effectively implement Laravel Boost 2.0, you should have a baseline understanding of the following: * **Modern PHP & Laravel**: Familiarity with PHP 8.2 and Laravel 12 is essential, as Boost 2.0 has moved away from supporting older versions to utilize the latest framework features. * **AI Coding Tools**: You should be using an AI-capable editor or agent such as Claude Dev, Cursor, GitHub Copilot, or Windsurf. * **Command Line Basics**: You will need to interact with the terminal to run Artisan commands for installation and synchronization. Key Libraries & Tools * **Laravel Boost**: The core package that manages guidelines, skills, and the MCP server for AI integration. * **Laravel MCP**: A foundational package that implements the Model Context Protocol, allowing external systems (like your app) to communicate with AI models. * **Composer**: Used for managing dependencies and third-party AI skills. * **MCP Inspector**: A utility for debugging the connection between your editor and the MCP server. Code Walkthrough: Installation and Configuration Setting up Laravel Boost 2.0 is a methodical process. It begins with a standard installation and moves into configuring how the AI interacts with your files. Step 1: Installation Run the following command in your project root: ```bash composer require laravel/boost --dev php artisan boost:install ``` During installation, the CLI will prompt you to select which AI agents you are using (e.g., Cursor, Claude). This is critical because each agent looks for context in different locations—Cursor uses `.cursorrules`, while others might look for `agents.md`. Step 2: Synchronizing Skills and Guidelines Whenever you update your configuration or add custom rules, you must run the update command to rebuild the context files that the AI reads: ```bash php artisan boost:update ``` This command scans your `AI/guidelines` and `AI/skills` directories, composing a unified markdown file (like `claudedev.md`) that represents the current state of your project's rules. Step 3: Customizing Business Logic One of the most powerful features of Boost 2.0 is the ability to inject custom business context. You can publish the configuration file to unlock this: ```bash php artisan vendor:publish --tag=boost-config ``` Inside `config/boost.php`, you can add a `purpose` key. This is where you tell the AI exactly what the app does—for example, "This project is a logistics platform for tracking international shipping containers." ```php return [ 'purpose' => 'A financial dashboard for tracking cryptocurrency tax compliance.', 'coding_style' => 'Spatie', // ... other config ]; ``` Syntax Notes: The Architecture of a Skill A **Skill** in Boost 2.0 is a specialized markdown file that the AI can "invoke" only when needed. This prevents the context window from being cluttered with irrelevant information. The syntax follows a specific pattern: ```markdown Name: Inertia Vue Development Description: Use this skill when building or modifying Vue components within the Inertia.js stack. Implementation Guidelines - Always use the <script setup> syntax. - Utilize Tailwind CSS for all styling. - Ensure all components are stored in the resources/js/Pages directory. ``` The AI reads the `# Description` to decide if the skill is relevant to your current prompt. If you ask to fix a CSS bug, it will pull in the **Tailwind Skill** but ignore the **Database Skill**, saving thousands of tokens. Practical Examples: Real-World Agent Workflows Automated Refactoring with Verification Don't just ask an AI to refactor code; ask it to verify its work using the tools provided by Laravel Boost. A high-level prompt might look like this: "Refactor the `OrderController@store` method to use a Form Request. Use the **Laravel Skill** for validation patterns. Once completed, use the **Tinker Tool** via MCP to create a test order and ensure the database record is created correctly." Documentation Ingestion If you are using a new package that the AI hasn't been trained on, you can use the `search_docs` tool provided by the Boost MCP server. The agent can query the latest Laravel documentation in real-time to find the correct syntax for Laravel 12 features like Pest integration or the newest Inertia helpers. Tips & Gotchas: Navigating the AI Frontier * **The Context Trap**: Be careful not to put too much in your `guidelines`. If your `agents.md` file becomes 10,000 lines long, the AI will lose the thread of your conversation. Move specific package logic into **Skills** so they are only loaded on demand. * **Plan Mode First**: Always use "Plan Mode" in your AI editor before letting it write code. This allows the agent to outline its approach based on the Boost guidelines before it commits to a file structure. * **Sync Often**: If you change a route name or a config value, run `php artisan boost:update`. If you don't, the AI will be working from a "ghost" version of your app's previous state. * **Override Wisely**: Boost comes with sensible defaults for Tailwind and Pest. However, if your team has a unique way of writing tests, create a custom file in `AI/skills/pest.md` to override the default Laravel Boost behavior.
Jan 28, 2026Overview: Scaffolding with Purpose Starting a web application from a blank slate is often a waste of valuable engineering time. Laravel Starter Kits solve this by providing a professional, pre-configured foundation. They don't just give you a folder structure; they deliver fully functional authentication, dashboard layouts, and profile management out of the box. This allows you to skip the boilerplate and move straight into the unique business logic of your project. Prerequisites To follow along, you should have a baseline understanding of: - **PHP 8.2+** and basic Laravel architecture. - Command-line interface basics. - Familiarity with frontend concepts like React, Vue, or Livewire. Key Libraries & Tools - Inertia.js: Bridges the gap between your server-side Laravel code and modern frontend frameworks like Vue or React. - Fortify: A headless authentication backend that handles registration, password resets, and two-factor authentication. - Pest: A developer-focused testing framework with a clean, expressive syntax. - Laravel Volt: An elegantly thin API for writing functional Livewire components. Code Walkthrough: Installation and Customization Project Initiation Use the Laravel installer to trigger the interactive setup. This is where you'll define your tech stack and authentication preferences. ```bash laravel new my-app ``` During this process, the CLI prompts you to choose between Livewire, React, or Vue. Choosing Livewire with **Volt** provides a unified PHP experience without needing a heavy JavaScript build step. Customizing Authentication Features Once the project is created, customization happens through configuration files. For example, if your application doesn't require two-factor authentication, you can disable it in `config/fortify.php`. ```php // config/fortify.php 'features' => [ Features::registration(), Features::resetPasswords(), // Features::twoFactorAuthentication([ // 'confirm' => true, // 'confirmPassword' => true, // ]), ], ``` By commenting out the feature, the associated UI elements in the settings dashboard disappear automatically. This "toggle-on, toggle-off" approach keeps your codebase clean and relevant. Syntax Notes Laravel uses **fluent configuration** and **service providers**. The `FortifyServiceProvider` is your primary hub for mapping views to your authentication logic. You'll notice the use of PHP **Attributes** or functional closures when using Volt, which keeps component logic and templates in the same file for faster iteration. Practical Examples - **SaaS MVP**: Rapidly deploy a dashboard where users can sign up and manage their billing profiles. - **Admin Panels**: Use the pre-built layouts to create internal tools with minimal CSS effort. - **Learning Lab**: Examine the starter kit's source code to see how Laravel experts structure routes, controllers, and tests. Tips & Gotchas - **Security First**: If you use WorkOS instead of built-in auth, remember you'll need to manage external API keys in your `.env` file. - **Testing**: Always run `php artisan test` after modifying authentication actions to ensure you haven't broken the registration flow. - **Framework Lock-in**: Choose your frontend stack (React vs. Vue) carefully during installation; switching stacks later requires manual migration of all components.
Dec 24, 2025Overview: The Context Gap in AI Development Standard AI models often stumble when working with Laravel because they lack two critical components: up-to-date documentation and framework-specific context. Generic agents rely on static training data, which means they are unaware of the latest features like request batching in Laravel 12. Laravel Boost bridges this gap by providing Model Context Protocol (MCP) servers and tailored guidelines directly to your AI agent, transforming it from a general coder into a framework expert. Prerequisites To follow this guide, you should be comfortable with the Artisan CLI and have a basic understanding of Composer package management. You will also need an AI-capable code editor such as Cursor or Claude Code. Key Libraries & Tools - **Laravel Boost**: The core package that provides tools and context to AI agents. - **Claude Code**: A command-line AI agent from Anthropic that integrates with MCP servers. - **Pest**: A testing framework for PHP included in the automated guidelines. - **Tailwind CSS**: A utility-first CSS framework supported by Boost's styling guidelines. Installation and Configuration After adding the package via Composer, you initialize the environment using a specialized Artisan command. This process generates specific guidelines by scanning your `composer.json` to see exactly which versions of tools like PHP or Alpine.js you are using. ```bash php artisan boost:install ``` During setup, you select your preferred editor and agent. Boost then injects best practices into your workspace, ensuring the AI adheres to the latest community standards and version-specific syntax. The Power of MCP Tools Once connected to the Model Context Protocol server, your agent gains "superpowers" through specialized tools: - **Search Docs**: Allows the AI to query the live Laravel documentation for brand-new features. - **Database Query**: Enables the agent to check record counts or table structures directly. - **Tinker**: Lets the AI run Laravel Tinker commands to test logic without creating temporary files. - **Browser Logs**: Helps the agent read error logs to debug issues autonomously. Syntax Notes & Best Practices Boost focuses on **version-aware syntax**. If your project uses Laravel 12, the AI will prioritize new hooks and features over deprecated Laravel 11 patterns. It also enforces strict testing standards for Pest, ensuring your generated tests are modern and readable. Tips & Gotchas Always ensure your MCP server is actually connected in your editor settings. If the AI claims it doesn't know about a feature, check if the `search_docs` tool is active. Using the **Tinker tool** is significantly safer than letting an AI create random PHP scripts, as it prevents leftover "junk" files from cluttering your production-ready codebase.
Dec 23, 2025Overview Standard PHP-FPM setups follow a shared-nothing architecture, where Laravel bootstraps the entire framework, loads service providers, and hits the database for every single incoming request. While this ensures isolation, it creates a performance ceiling. Laravel Octane shatters this ceiling by keeping your application resident in memory. By using high-performance application servers, Octane eliminates the bootstrapping overhead, allowing your application to stay 'warm' and respond with sub-millisecond latency. Prerequisites To follow along, you should be comfortable with the PHP ecosystem and basic Laravel CLI operations. You will need a local development environment capable of running modern PHP versions and a basic understanding of how web servers interact with application code. Key Libraries & Tools * Laravel Octane: The core package that integrates persistent application servers into Laravel. * FrankenPHP: A modern application server written in Go that supports the 103 Early Hints and features a built-in Caddy server. * Swoole / RoadRunner: Alternative high-performance runtimes supported by Octane. * Pest: A testing framework for PHP; we use the `stress` plugin here to benchmark performance. Code Walkthrough Before installing Octane, a baseline test on a fresh installation shows roughly 340 requests per second. Once you install Octane and a server like FrankenPHP, you start the server via the Artisan CLI: ```bash php artisan octane:start ``` This command initializes the persistent workers. To verify the performance gains, use the Pest stress plugin to simulate high traffic: ```bash ./vendor/bin/pest stress http://localhost:8000 --concurrency=10 ``` In our benchmarks, the response time dropped from 28ms under load to a mere 2ms, while the throughput jumped to over 1,500 requests per second. This represents a massive leap in efficiency without changing a single line of business logic. Syntax Notes Octane introduces the concept of long-lived processes. You must be careful with **static variables** and **singleton** services. Because the application doesn't reboot between requests, any data stored in a static property will persist to the next user's request. Always use the `app()` container to resolve dependencies rather than storing state in static classes. Practical Examples Octane is a perfect fit for high-traffic APIs, real-time notification systems, or microservices where every millisecond counts. It allows Laravel to compete directly with Go or Node.js in terms of raw throughput while maintaining the developer-friendly syntax of the PHP ecosystem. Tips & Gotchas Memory leaks are your primary enemy in a persistent environment. Monitor your application's memory usage during stress tests. If you find memory growing indefinitely, check for circular references or global arrays that never get cleared. Using `octane:start --watch` during development will automatically restart the server when you change your code, ensuring you always see the latest logic.
Dec 8, 2025Overview AI coding agents are shifting from simple autocomplete helpers to sophisticated architectural assistants. This transition demands a new set of workflows that prioritize context over raw syntax. For Laravel developers, this means moving beyond basic copilot functionality and embracing tools that understand the framework's specific conventions. By utilizing Laravel Boost and high-level agents like Cursor, Claude Code, and Codex CLI, developers can automate the repetitive scaffolding of CRUD operations, validation logic, and API resources while maintaining strict control over the code quality. Prerequisites To follow this guide effectively, you should possess a baseline understanding of the following: * **PHP & Laravel**: Familiarity with Eloquent models, migrations, and API resource structures. * **Terminal Proficiency**: Ability to run composer commands and navigate CLI interfaces. * **Git Basics**: Understanding of branching and commits, as AI-generated code should always be tracked for easy rollback. * **Node/NPM**: Required for installing various CLI-based agents. Key Libraries & Tools * **Laravel Boost**: A specialized package that generates `.mdc` and `.md` guideline files to ensure AI models follow modern Laravel conventions. * **Cursor**: A fork of VS Code that integrates AI deep into the editor's UI for "tab-tab-tab" workflows. * **Claude Code**: An agent from Anthropic that operates entirely within the terminal, focusing on agentic task completion. * **Codex CLI**: OpenAI's command-line interface powered by GPT-4o (and later versions) for high-accuracy code generation. * **Laravel Idea**: A powerful plugin for PHPStorm that provides deep framework integration. Solving the Context Problem with Laravel Boost The primary failure point for AI is "stale knowledge." Models trained on Laravel 11 might hallucinate syntax when working in a Laravel 12 environment. Laravel Boost solves this by injecting your specific project context into the AI's prompts. When you run the installation command, the package scans your `composer.json` to detect exactly which versions of Livewire, Tailwind, or Pest you are using. It then generates specific guideline files for your IDE of choice. This ensures the AI doesn't suggest outdated patterns like `DB::table()` when your team prefers modern Eloquent query builders. ```bash composer require laravel-boost php artisan boost:install ``` Code Walkthrough: Generating a CRUD API When using an agent like Cursor, the most efficient path is a combination of manual scaffolding and AI refinement. Instead of asking the AI to build everything from scratch, start with the core model and migration. 1. Scaffolding the Core Run the standard Artisan command to ensure the foundation is deterministic. ```bash php artisan make:model Post -m ``` 2. Defining the Migration with AI Autocomplete Open the migration file and let the AI suggest fields. By simply hitting `Tab`, the AI recognizes common Laravel patterns like `user_id` foreign keys and `string` title fields based on the model name. 3. Agentic Resource Generation Open the Agent window (`Cmd+I`) and provide a high-context prompt. Specifying the use of Form Requests is critical to avoid bloated controllers. ```markdown Generate a CRUD API for the Post model. - Use API Resources for the response. - Place validation in separate Form Request classes. - Ensure the controller is in the API namespace. ``` 4. Refining the Resource If the generated PostResource includes sensitive data like timestamps, you can use Claude Code to refine it without leaving the terminal: ```bash Inside Claude Code CLI In @app/Http/Resources/PostResource.php, remove the created_at and updated_at fields from the return array. ``` Syntax Notes * **Slash Commands**: Agents like Claude Code use commands like `/usage` to monitor token limits or `/clear` to reset the context window. * **Markdown Guidelines**: Most agents look for a `.cursorrules` or `claude.md` file. These are standard Markdown files that dictate coding style, such as "Use Pest for testing" or "Prefer constructor injection." * **MCP (Model Context Protocol)**: Some tools use MCP to allow the AI to search documentation or run local commands directly. Practical Examples * **Test-Driven Scaffolding**: Use Codex CLI to generate both the controller and a corresponding Pest test suite. The agent will run the tests automatically and fix the code until they pass. * **Plan Mode Execution**: For complex features like a multi-step checkout, enter "Plan Mode." This allows you to verify the AI's architectural logic (e.g., service classes vs. jobs) before any files are actually modified. Tips & Gotchas * **Vibe Coding vs. Precision**: Avoid long-running chat sessions. As the conversation grows, the "context pollution" increases, leading to hallucinations and higher token costs. Use the `/new` command or open a new chat window for every distinct task. * **Pricing Horror Stories**: Cursor pricing can be volatile if you use expensive models like Claude 3.5 Sonnet for small tasks. Monitor your dashboard frequently. For minor refactors, switch to cheaper models like Grok Code or Composer-01. * **Git Integration**: Always commit your work before triggering an agent. While Cursor offers an "Undo" button, it only reverts the most recent block of changes. A Git rollback is the only reliable way to recover from an AI that has accidentally modified 20 different files.
Nov 20, 2025The New Frontier of AI-Native Development The relationship between developers and their code is undergoing a fundamental transformation. We are moving past the era of simple auto-completion and into a world where AI agents act as full-fledged pair programmers. Ashley Hindle, leading the AI initiatives at Laravel, describes this shift not as a replacement of the developer's craft, but as an expansion of their capabilities. The challenge remains that while Large Language Models (LLMs) are becoming increasingly sophisticated, they often lack the specific, up-to-date context of a framework's evolving ecosystem. They might know PHP, but they might not know the breaking changes in the latest version of Pest or the specific architectural nuances of a Filament project. This is where Laravel Boost enters the scene. It is not an LLM itself; rather, it is a sophisticated bridge. By providing a composer package that injects guidelines, tools, and version-specific documentation directly into the AI agent's context, it eliminates the "hallucination gap" that occurs when an AI relies on stale training data. The goal is simple: make the AI agent a more competent contributor by giving it the same reference materials a human developer would use. This approach moves development from "vibe coding"—relying on the AI's best guess—to a deterministic, high-quality workflow grounded in the actual state of the codebase and the framework. The Architecture of Context: Ingestion and Vector Search To understand how Boost works, we must look at the ingestion pipeline that powers its documentation search. Unlike static documentation, the information fed to an AI agent needs to be formatted for retrieval. Ashley Hindle explains that the team uses Laravel Cloud to host an API that serves as the central nervous system for documentation. The pipeline downloads markdown files from GitHub APIs and processes them through a recursive text splitter. This "chunking" is vital because an AI cannot ingest a 50-page manual in one go and expect to find a specific method signature accurately. These chunks are then vectorized using OpenAI embedding models and stored in PostgreSQL via PGVector. Interestingly, the team does not rely solely on vector search. They employ a hybrid approach that includes Postgres full-text search with GIN indexes. This dual-layer strategy ensures that both semantic meaning (found through embeddings) and specific syntax or keyword matches (found through full-text search) are captured. For a developer, this means when the AI searches for a specific Inertia.js helper, it finds the exact documentation snippet relevant to their specific version, rather than a generic or outdated example. Mastering the Model Context Protocol (MCP) A core technical pillar of Boost is the Model Context Protocol (MCP). Think of MCP as a standardized way for an AI agent to "talk" to a server and use its features. Ashley Hindle uses a physical analogy: if the AI is the brain, MCP provides the hands. It allows the agent to ask, "What are you capable of?" and receive a list of tools—such as searching documentation, scanning a `composer.lock` file, or checking Tailwind CSS configurations. The brilliance of the MCP implementation in Boost lies in its invisibility. When a developer installs Boost, it auto-detects system-installed IDEs and agents like Cursor, Claude Code, or PHPStorm and configures the MCP server automatically. The AI agent then decides when to call these tools based on the user's prompt. If you ask the AI to write a test, it sees the `search_docs` tool in its inventory, notices you have Pest installed, and retrieves the latest Pest documentation before writing a single line of code. This autonomous decision-making by the AI, guided by the tool descriptions provided by Boost, creates a seamless experience where the developer doesn't have to manually prompt the AI to "look at the docs." Guidelines vs. Tools: The Art of Nudging There is a subtle but critical distinction between providing an AI with a tool and providing it with a guideline. A tool is a functional capability, while a guideline is a set of behavioral rules. Ashley Hindle discovered during development that tools alone weren't enough. An AI might have access to documentation but still write code in an old style. By providing specific guidelines—often delivered via `claude.md` or `custom-instructions` files—Boost "nudges" the AI to follow modern conventions. These guidelines are dynamically generated based on the project's specific dependencies. If a project uses Livewire, Boost includes Livewire guidelines; if it uses React, it swaps them. This prevents context bloat, ensuring the AI isn't distracted by irrelevant rules. Furthermore, Boost is designed to respect the "existing conventions" of a codebase. Guidelines often tell the AI to look at sibling controllers or existing patterns first. This ensures that the AI doesn't just write "perfect" Laravel code, but code that actually fits the specific project it is working in. The team is currently working on an override system that allows developers to provide their own custom blade files for guidelines, ensuring that team-specific standards take precedence over defaults. The Economics of Tokens and Efficiency A common concern with AI-assisted development is the cost and token usage. Adding thousands of lines of documentation and guidelines to every request sounds expensive. However, Ashley Hindle argues that Boost often pays for itself. While the guidelines might add roughly 2,000 tokens to a request—a small fraction of the 200,000+ context windows in modern models like Claude 3.5 Sonnet—they significantly reduce the number of failed attempts. When an AI has the correct context, it gets the code right on the first try. Without Boost, a developer might go through five or six back-and-forth prompts to correct the AI's hallucinations, consuming far more tokens in the long run. Additionally, many providers now support prompt caching. Because the Boost guidelines remain consistent across a session, they are frequently cached at the API level, often resulting in a 90% discount on those tokens. The efficiency isn't just financial; it's temporal. The developer stays in the "flow state" because they aren't constantly acting as a human debugger for the AI's mistakes. Future Horizons: Benchmarks and Package Integration The roadmap for Laravel Boost is ambitious. One of the most significant upcoming projects is "Boost Benchmarks." Ashley Hindle is building a comprehensive suite of projects and evaluations to move beyond "gut feel" testing. This will allow the team to statistically prove that one version of Boost is, for example, 20% more accurate at fixing bugs in Filament than the previous version. It will also provide data on which LLMs—be it Claude, GPT-4o, or Gemini—perform best with specific Laravel tasks. Another major shift is the move toward a package-contributed guideline system. The Laravel team cannot write and maintain guidelines for every package in the ecosystem. The goal is to create an API that allows package creators—like Spatie—to include their own Boost-compatible guidelines within their repositories. When a developer runs `boost install`, the system will detect these third-party packages and automatically pull in the author-approved AI instructions. This decentralization will ensure that the entire PHP ecosystem can become AI-native, with every package providing the necessary context for agents to use it effectively. As context windows continue to expand toward the millions, the bottleneck will no longer be how much the AI can remember, but how accurately we can feed it the truth.
Aug 30, 2025Overview Software development is a balancing act between the pursuit of technical excellence and the unrelenting demands of business stakeholders. In the Laravel ecosystem, we often start projects with a sense of architectural purity, only to watch it erode as deadlines tighten and feature requests pile up. This tutorial explores how to preserve Laravel's inherent elegance even when business requirements become messy. We will cover practical strategies for refactoring bloated controllers, implementing type-safe enums, utilizing Eloquent scopes, and shifting the developer mindset from writing code for computers to writing code for humans. Prerequisites To get the most out of this guide, you should have a solid foundation in the following: - **PHP 8.2+**: Familiarity with modern PHP features like type hinting, attributes, and enums. - **Laravel Framework**: Understanding of the Request-Response lifecycle, Controllers, and Eloquent ORM. - **Basic Testing Concepts**: Awareness of automated testing and the differences between feature and unit tests. Key Libraries & Tools - **Laravel**: The primary PHP framework used for building expressive web applications. - **Pest**: A delightful PHP testing framework focused on simplicity and readability. - **PHPUnit**: The industry-standard testing framework for PHP. - **Laravel Shift**: An automated service for upgrading Laravel applications and generating test boilerplate. - **PHPStan**: A static analysis tool that finds bugs in your code without writing tests. - **Laravel Pint**: An opinionated PHP code style fixer for Laravel. Code Walkthrough: Cleaning the Controller Junk Drawer One of the most common signs of a decaying application is the "Fat Controller." As business needs evolve, we often add custom methods to our controllers that fall outside the standard CRUD lifecycle. This turns a once-focused class into a junk drawer of unrelated logic. 1. Embracing Resourceful Controllers Instead of adding custom methods like `markAsPaid()` to an `InvoiceController`, we should lean into Laravel's resourceful routing. Every action can be viewed as a resource. If you need to mark an invoice as paid, that is essentially a "Payment" resource being created or an "Invoice Status" being updated. ```php // Instead of this in InvoiceController: public function markAsPaid(Invoice $invoice) { $invoice->update(['status' => 'paid']); return back(); } ``` We should extract this into an invocable controller. This keeps the primary `InvoiceController` strictly limited to `index`, `create`, `store`, `show`, `edit`, `update`, and `destroy`. ```php namespace App\Http\Controllers; use App\Models\Invoice; use Illuminate\Http\Request; class InvoicePaymentController extends Controller { public function __invoke(Request $request, Invoice $invoice) { $invoice->markAsPaid(); return back()->with('status', 'Invoice paid!'); } } ``` 2. Moving Validation to Form Requests Validation often takes up significant vertical space in controller methods. By moving this logic to a Form Request, you decouple validation from the execution logic. ```php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rules\Enum; use App\Enums\InvoiceStatus; class StoreInvoiceRequest extends FormRequest { public function rules(): array { return [ 'client_id' => ['required', 'exists:clients,id'], 'amount' => ['required', 'numeric', 'min:0'], 'status' => ['required', new Enum(InvoiceStatus::class)], ]; } } ``` In your controller, you simply type-hint the request: ```php public function store(StoreInvoiceRequest $request) { Invoice::create($request->validated()); return redirect()->route('invoices.index'); } ``` 3. Eliminating Magic Strings with Enums Magic strings are "typo time bombs." Hard-coding statuses like `'pending'` throughout your app makes refactoring impossible. Native PHP enums provide type safety and allow Laravel to handle model casting automatically. ```php namespace App\Enums; enum InvoiceStatus: string { case Draft = 'draft'; case Pending = 'pending'; case Paid = 'paid'; case Cancelled = 'cancelled'; } ``` Cast the attribute in your Eloquent model: ```php protected function casts(): array { return [ 'status' => InvoiceStatus::class, ]; } ``` Advanced Eloquent: Scopes Over Repositories Many developers reach for the Repository Pattern to abstract query logic. In Laravel, this often creates an unnecessary wrapper around Eloquent, which is already an implementation of the Active Record pattern. Instead, use **Local Scopes** to build a fluent query interface. The Problem with Boolean Flags Avoid methods that take multiple boolean flags, such as `getInvoices(true, false, true)`. These are unreadable for humans. Instead, use chainable scopes that describe the business intent. ```php // Using new Laravel 12 Scoped Attribute syntax use Illuminate\Database\Eloquent\Attributes\ScopedBy; #[Scoped] protected function overdue(Builder $query): void { $query->where('due_date', '<', now()); } #[Scoped] protected function forClient(Builder $query, int $clientId): void { $query->where('client_id', $clientId); } ``` You can then chain these in your controller for maximum readability: ```php $invoices = Invoice::overdue()->forClient($id)->get(); ``` Syntax Notes - **Invocable Controllers**: Using the `__invoke` method allows a controller to handle exactly one action, which is perfect for specialized business logic. - **Docblocks vs. Native Types**: Prefer native PHP type hints (e.g., `string $name`) over docblocks. Only use docblocks when the native type system cannot express the complexity (e.g., generics or specific array shapes). - **Attribute-based Scopes**: Laravel 12 introduces attributes for scopes, allowing you to define them as protected methods without the `scope` prefix, further cleaning up the model's public API. Practical Examples: The Clearance Envelope In engineering, a "clearance envelope" is a zone around a moving object (like a roller coaster) that must remain unobstructed. Your code should have a similar envelope provided by automated tests. Before shipping a feature, use Pest to simulate every possible "rider" (user input) and ensure the "track" (logic) doesn't break. ```php // Pest Example: Testing an edge case it('allows admins to see all invoice statuses', function () { $admin = User::factory()->admin()->create(); $response = $this->actingAs($admin) ->get('/api/invoice-statuses'); $response->assertJson(InvoiceStatus::cases()); }); ``` Tips & Gotchas - **The Debt Trap**: Choosing convenience over cleanliness is a loan against your future productivity. The interest on that debt compounds until the application is impossible to maintain. - **The "Permission to be Messy" Rule**: It is okay to write "garbage" code while you are still discovering the business requirements. However, you must take out the trash (refactor) before the code reaches production. - **Selling Clean Code**: Never ask a stakeholder for "time to refactor." Instead, sell them on "velocity." Explain that cleaning a specific module will allow the team to ship features in 3 days instead of 3 weeks. Align technical elegance with business deliverability. - **Avoid TODOs**: Comments like `// TODO: Fix this hack` are rarely addressed. If a task is worth doing, do it now. If it's too big, create a failing test with `$this->todo()` in Pest to keep it visible in your CI pipeline.
Aug 27, 2025The Unification of Modern Web Development Web development often feels like a sprawling construction site where every trade speaks a different language. Laravel has long served as the general contractor that brings sanity to this chaos, but Laracon US 2025 marks a moment where the framework is moving beyond simple coordination toward total integration. The event served as a showcase for a philosophy that prioritizes developer speed without sacrificing the artisanal quality of the final product. This isn't just about writing code faster; it is about creating an environment where the tools get out of the way so the developer can focus on the problem at hand. From the high-performance internals of Vue.js to the radical simplicity of Livewire 4, the recurring theme is the removal of friction. Developers are being equipped with "chainsaws"—powerful, automated tools that can clear entire forests of boilerplate code in seconds. However, as the ecosystem matures, the challenge shifts from how to write code to how to manage the vast capabilities now at our fingertips. The transition from manual labor to high-level orchestration is the defining characteristic of this new era in the PHP and JavaScript ecosystems. JavaScript Tooling and the VoidZero Vision Evan You, the creator of Vue and Vite, introduced a transformative vision for the future of JavaScript infrastructure through his new venture, VoidZero. For years, the JavaScript ecosystem has been plagued by fragmentation. To build a modern application, a developer must stitch together a dozen disparate tools: parsers, transformers, minifiers, and bundlers, each written in different languages with varying levels of performance. It is a fragile pipeline that often breaks under the weight of its own complexity. VoidZero aims to unify this entire stack under a single, high-performance architecture written primarily in Rust. At the heart of this initiative is **Rolldown**, a new bundler designed to combine the extreme speed of **esbuild** with the sophisticated feature set of **Rollup**. This is not merely a theoretical exercise in performance; it represents a fundamental shift in how production builds are handled. By aligning the APIs and behaviors across development and production, VoidZero eliminates the "works in dev, breaks in prod" nightmare that has haunted JavaScript developers for a decade. Furthermore, the introduction of **Vapor Mode** for Vue 3.6 demonstrates a commitment to performance that rivals even the most lightweight modern frameworks. By compiling Vue components directly to efficient DOM-manipulation code and bypassing the virtual DOM where appropriate, Vue.js is reclaiming its position at the absolute edge of performance benchmarks. This granular opt-in approach allows developers to maintain the stability of their existing applications while selectively "supercharging" performance-critical pages. The Logic of Vibe Coding and AI on a Leash One of the most discussed concepts at the conference was "vibe coding," a term popularized by Andre Karpathy that describes a workflow where AI agents do the heavy lifting while the human developer focuses on the high-level intent. While the term may sound casual, the underlying technical reality is anything but. It represents a shift from imperative programming—telling the computer *how* to do something—to declarative intent—telling the computer *what* you want to achieve. Colin D. Carlo provided a rigorous framework for navigating this new reality. He argued that to use AI effectively, we must move beyond the "copy-paste" era of ChatGPT and into the integrated era of agents. Modern models like Claude 3.5 Sonnet are now scoring over 70% on the **SWE-bench**, meaning they can identify, locate, and fix real-world bugs in production repositories with high accuracy. This isn't just an assistant; it is a pair programmer with a photographic memory of your entire codebase. However, the power of these agents requires a new set of disciplines. Dave Hicking emphasized that while AI can generate code, it cannot generate "taste." Taste is the result of expertise, judgment, and human empathy. The future belongs to the developer who can keep the AI on a leash—directing its raw power toward meaningful ends while maintaining the rigorous standards of software engineering. The "chainsaw" of vibe coding is incredibly efficient, but without a steady human hand, it is also the fastest way to create technical debt. Livewire 4 and the Death of the Virtual DOM Caleb Porzio took the stage to announce Livewire 4, a release that aims to unify the diverse ways developers currently build components. The introducing of the **Single File Component** (SFC) in Livewire is a major step toward reducing the cognitive load of switching between class files and template files. By collocating logic, template, and even tests into a single directory or file, Livewire is embracing a pattern that has proven successful in the Vue and React ecosystems. Perhaps the most technically impressive feature introduced was **Blaze**, a compiler optimization that utilizes "code folding." In traditional Blade rendering, every component call involves a significant runtime overhead of resolving views, merging arrays, and checking conditions. Blaze analyzes the template at compile-time and "folds" static components directly into pure PHP strings. The results are staggering: a page with 25,000 components that previously took 500 milliseconds to render can now be processed in under 20 milliseconds. It effectively vaporizes the runtime cost of components, making architectural decisions about component size and frequency irrelevant to performance. Livewire 4 also introduces **Islands**, a feature that allows developers to isolate expensive parts of a page. By wrapping a slow database query in an island tag, the rest of the page remains reactive and instant. When the user interacts with the island, only that specific part of the DOM is updated, without triggering a full-page rerender. This brings the performance characteristics of sophisticated Single Page Applications (SPAs) to the traditional server-side rendering model, proving that the "Livewire way" is not just easier to write, but increasingly faster to run. Mastering the Terminal Workflow While high-level frameworks and AI agents capture the headlines, the day-to-day efficiency of a developer often comes down to their mastery of basic tools. Alex Six made a compelling case for the terminal as the ultimate productivity multiplier. By leveraging Tmux, a terminal multiplexer, developers can move away from a cluttered desktop of a dozen terminal tabs toward a structured, persistent, and portable environment. Tmux operates on a client-server architecture, meaning your development sessions live on even if your terminal emulator crashes or your laptop dies. This persistence is a massive boon for "deep work," allowing a developer to switch between different projects and feature branches without losing their context. When combined with tools like **Git Worktrees**, Tmux allows a developer to have multiple versions of the same codebase open simultaneously, each with its own dedicated terminal session and environment. It is a level of organization that makes the transition between complex tasks seamless and error-free. Resilience and Global Ambition The closing sessions of the conference focused on the "why" behind the software we build. Whether it was Susanna's fast-paced deep dive into resilient code—anticipating failures before they crash the application—or Tom Kra's inside look at the scaling of Laravel as a company, the message was clear: we are building for a global audience that expects perfection. Laravel is no longer a niche framework for hobbyists; it is an enterprise-ready powerhouse that powers some of the largest web properties in the world. Will King provided the ultimate distillation of the conference's spirit: "No one can be ambitious for you." The tools have never been better, the community has never been larger, and the barrier to entry has never been lower. Whether you are building a randomly generated dungeon based on audio frequencies or a multi-million dollar SAS platform, the framework for ambitious projects is ready. The only remaining variable is the human artisan at the keyboard.
Jul 31, 2025