Overview Laravel 13.20 introduces a major convenience for developers by adding first-party support for image processing. Historically, handling media uploads required juggling external dependencies, configuring raw drivers, and writing multi-step storage logic. While third-party options remain robust, this new native API brings image resizing, cropping, and format conversion directly into the core framework syntax, reducing boilerplate and unifying the developer experience. Prerequisites To make the most of this tutorial, you should understand: * Basic routing and controller architecture in the Laravel framework. * PHP file handling concepts. * How to manage packages via Composer. Key Libraries & Tools * **Laravel 13**: The PHP web framework hosting the new first-party image manipulation features. * **Intervention Image**: The underlying PHP library that Laravel uses as its core engine. * **Spatie Media Library**: An advanced media-to-model binding package for complex collection management. Code Walkthrough Let us compare the traditional, multi-step approach with the new native syntax. The Manual Route: Intervention Image Previously, managing a thumbnail with raw Intervention Image required manual driver setup, file name generation, and explicit step-by-step encoding: ```php // Using Intervention Image directly $manager = new ImageManager(new Driver()); $image = $manager->read($request->file('photo')); $thumbnail = $image->scale(width: 300); $encoded = $thumbnail->toWebp(); Storage::disk('public')->put('thumbnails/photo.webp', $encoded); ``` This works. However, it forces you to manage intermediate state variables and interface directly with driver specifics. The Native Solution: Laravel 13.20 The new API simplifies this process by integrating image manipulations straight into the request and file upload flow: ```php // The streamlined Laravel way $request->file('photo') ->storeProcessed('thumbnails', function ($image) { $image->width(300)->format('webp'); }); ``` This chained approach eliminates manual driver instantiation and works natively with Laravel's file storage layer. Syntax Notes The new helper methods chain directly onto the uploaded file instance. Behind the scenes, Laravel resolves the active image driver configuration (like GD or Imagick), processes the closure, and saves the file in one unified transaction. It acts as a clean, fluent wrapper. Practical Examples Use the native API for: * Creating instant `.webp` thumbnails during user profile uploads. * Standardizing incoming catalog photographs to uniform dimensions. * Stripping metadata to optimize storage efficiency on simple blogs. Tips & Gotchas Remember that this native tool does not replace Spatie Media Library. While Laravel handles the physical file conversion, it does not manage database relations, multiple collections, or polymorphic model links. Furthermore, you must still run `composer require intervention/image` in your project, as Laravel relies on it under the hood.
Pest
Products
Sep 2021 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Oct 2021 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Jan 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Feb 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Mar 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Jun 2024 • 2 videos
High activity month for Pest. Laravel among the most active voices, with 2 videos across 1 sources.
Jul 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Oct 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Nov 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Dec 2024 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Feb 2025 • 5 videos
High activity month for Pest. Laravel among the most active voices, with 5 videos across 1 sources.
Mar 2025 • 2 videos
High activity month for Pest. Laravel among the most active voices, with 2 videos across 1 sources.
Jul 2025 • 1 videos
Steady coverage of Pest. Laravel contributed to 1 videos from 1 sources.
Aug 2025 • 2 videos
High activity month for Pest. Laravel among the most active voices, with 2 videos across 1 sources.
Nov 2025 • 1 videos
Steady coverage of Pest. Laravel Daily contributed to 1 videos from 1 sources.
Dec 2025 • 3 videos
High activity month for Pest. Laravel among the most active voices, with 3 videos across 1 sources.
Jan 2026 • 3 videos
High activity month for Pest. Laravel among the most active voices, with 3 videos across 1 sources.
Mar 2026 • 3 videos
High activity month for Pest. AI Coding Daily, Laravel, and Laravel Daily among the most active voices, with 3 videos across 3 sources.
Apr 2026 • 2 videos
High activity month for Pest. Laravel Daily among the most active voices, with 2 videos across 1 sources.
Jul 2026 • 1 videos
Steady coverage of Pest. Laravel Daily contributed to 1 videos from 1 sources.
- 20 hours ago
- Apr 20, 2026
- Apr 9, 2026
- Mar 20, 2026
- Mar 19, 2026
The False Security of Automated Coverage Many developers now rely on Claude Opus or similar AI agents to draft both application logic and the accompanying tests. On the surface, the results look impressive. You run `php artisan test` and see hundreds of passing assertions. It feels like a win. However, blind trust in these generated suites is a dangerous bottleneck. AI models often default to the "happy path"—the scenarios where everything works as intended—while completely ignoring the messy edge cases that break production systems. The Missing Edge Case: A Laravel Example In a recent project using Filament, I encountered a bug that the AI-generated tests failed to catch. The system allowed accountants to delete their services. The AI wrote a test confirming that an expert can delete a service, which passed. What it didn't test was the consequence of deleting the *last* service. ```php // The problematic view logic the AI generated @foreach($services as $service) <x-booking-button :service="$service" /> @endforeach ``` Because the AI didn't account for an empty state, the public booking page displayed a confusing, empty interface when zero services remained. The AI verified the deletion worked but failed to verify the system's integrity after the deletion. This is a classic example of why generic instructions like "generate automated tests" are insufficient. Refining the Verification Prompt To fix this, you must move beyond generic commands. Your `claude.md` or system prompts need specific guardrails. Don't just ask for tests; demand validation of boundaries, empty states, and unauthorized access. Instead of "Generate tests for this feature," try a more structured approach: ```markdown Testing Requirements - Verify behavior when collections are empty. - Test boundary conditions for numerical inputs. - Ensure flash messages or UI warnings appear for destructive actions. - Confirm unauthorized users are redirected with 403/404 errors. ``` Syntax and Tooling Notes When working in Laravel, use Pest or PHPUnit to enforce these specific scenarios. The key syntax pattern to look for in AI-generated code is the `foreach` loop without an `@forelse` fallback or a count check. If your AI agent doesn't include an `assertViewHas` check for empty states, your verification process is incomplete. Manual testing remains a necessity, but a more rigorous prompting strategy significantly narrows the gap between AI-generated code and production-ready software.
Mar 14, 2026Overview: 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, 2025