bhavin-gajjar/laravel-coder-lora-train huggingface dataset:
[Laravel 12] Explain testing: Introduction

Laravel is built with testing in mind. In fact, support for testing with Pest and PHPUnit is included out of the box and a phpunit.xml file is already set up for your application. The framework also ships with convenient helper methods that allow you to expressively test your applications.

By default, your application's tests directory contains two directories: Feature and Unit. Unit tests are tests that focus on a very small, isolated portion of your code. In fact, most unit tests probably focus on a single method. Tests within your "Unit" test directory do not boot your Laravel application and therefore are unable to access your application's database or other framework services.

Feature tests may test a larger portion of your code, including how several objects interact with each other or even a full HTTP request to a JSON endpoint. **Generally, most of your tests should be feature tests. These types of tests provide the most confidence that your system as a whole is functioning as intended.**

An ExampleTest.php file is provided in both the Feature and Unit test directories. After installing a new Laravel application, execute the vendor/bin/pest, vendor/bin/phpunit, or php artisan test commands to run your tests.

<a name="environment"></a>
[Laravel 12] Explain testing: Environment

When running tests, Laravel will automatically set the configuration environment to testing because of the environment variables defined in the phpunit.xml file. Laravel also automatically configures the session and cache to the array driver so that no session or cache data will be persisted while testing.

You are free to define other testing environment configuration values as necessary. The testing environment variables may be configured in your application's phpunit.xml file, but make sure to clear your configuration cache using the config:clear Artisan command before running your tests!

<a name="the-env-testing-environment-file"></a>
[Laravel 12] Explain testing: Creating Tests

To create a new test case, use the make:test Artisan command. By default, tests will be placed in the tests/Feature directory:

If you would like to create a test within the tests/Unit directory, you may use the --unit option when executing the make:test command:

> [!NOTE]
> Test stubs may be customized using stub publishing.

Once the test has been generated, you may define test as you normally would using Pest or PHPUnit. To run your tests, execute the vendor/bin/pest, vendor/bin/phpunit, or php artisan test command from your terminal:

> [!WARNING]
> If you define your own setUp / tearDown methods within a test class, be sure to call the respective parent::setUp() / parent::tearDown() methods on the parent class. Typically, you should invoke parent::setUp() at the start of your own setUp method, and parent::tearDown() at the end of your tearDown method.

<a name="running-tests"></a>
[Laravel 12] Explain upgrade: Low Impact Changes

<div class="content-list" markdown="1">

- Carbon 3
- Concurrency Result Index Mapping
- Container Class Dependency Resolution
- Image Validation Now Excludes SVGs
- Local Filesystem Disk Default Root Path
- Multi-Schema Database Inspecting
- Nested Array Request Merging

</div>

<a name="upgrade-12.0"></a>
[Laravel 12] Explain urls: Generating URLs

The url helper may be used to generate arbitrary URLs for your application. The generated URL will automatically use the scheme (HTTP or HTTPS) and host from the current request being handled by the application:

To generate a URL with query string parameters, you may use the query method:

Providing query string parameters that already exist in the path will overwrite their existing value:

Arrays of values may also be passed as query parameters. These values will be properly keyed and encoded in the generated URL:

<a name="accessing-the-current-url"></a>
[Laravel 12] Explain urls: Accessing the Previous URL

Sometimes it is helpful to know the previous URL that the user is visiting from. You can access the previous URL via the url helper's previous and previousPath methods:

Or, via the session, you may access the previous URL as a fluent URI instance:

It is also possible to retrieve the route name for the previously visited URL via the session:

<a name="urls-for-named-routes"></a>
[Laravel 12] Explain valet: Laravel Valet

- Introduction
- Installation
    - Upgrading Valet
- Serving Sites
    - The "Park" Command
    - The "Link" Command
    - Securing Sites With TLS
    - Serving a Default Site
    - Per-Site PHP Versions
- Sharing Sites
    - Sharing Sites on Your Local Network
- Site Specific Environment Variables
- Proxying Services
- Custom Valet Drivers
    - Local Drivers
- Other Valet Commands
- Valet Directories and Files
    - Disk Access

<a name="introduction"></a>
[Laravel 12] Explain valet: Introduction

> [!NOTE]
> Looking for an even easier way to develop Laravel applications on macOS or Windows? Check out Laravel Herd. Herd includes everything you need to get started with Laravel development, including Valet, PHP, and Composer.

Laravel Valet is a development environment for macOS minimalists. Laravel Valet configures your Mac to always run Nginx in the background when your machine starts. Then, using DnsMasq, Valet proxies all requests on the *.test domain to point to sites installed on your local machine.

In other words, Valet is a blazing fast Laravel development environment that uses roughly 7 MB of RAM. Valet isn't a complete replacement for Sail or Homestead, but provides a great alternative if you want flexible basics, prefer extreme speed, or are working on a machine with a limited amount of RAM.

Out of the box, Valet support includes, but is not limited to:

<style>
    #valet-support > ul {
        column-count: 3; -moz-column-count: 3; -webkit-column-count: 3;
        line-height: 1.9;
    }
</style>

<div id="valet-support" markdown="1">

- Laravel
- Bedrock
- CakePHP 3
- ConcreteCMS
- Contao
- Craft
- Drupal
- ExpressionEngine
- Jigsaw
- Joomla
- Katana
- Kirby
- Magento
- OctoberCMS
- Sculpin
- Slim
- Statamic
- Static HTML
- Symfony
- WordPress
- Zend

</div>

However, you may extend Valet with your own custom drivers.

<a name="installation"></a>
[Laravel 12] Explain valet: Installation

> [!WARNING]
> Valet requires macOS and Homebrew. Before installation, you should make sure that no other programs such as Apache or Nginx are binding to your local machine's port 80.

To get started, you first need to ensure that Homebrew is up to date using the update command:

Next, you should use Homebrew to install PHP:

After installing PHP, you are ready to install the Composer package manager. In addition, you should make sure the $HOME/.composer/vendor/bin directory is in your system's "PATH". After Composer has been installed, you may install Laravel Valet as a global Composer package:

Finally, you may execute Valet's install command. This will configure and install Valet and DnsMasq. In addition, the daemons Valet depends on will be configured to launch when your system starts:

Once Valet is installed, try pinging any *.test domain on your terminal using a command such as ping foobar.test. If Valet is installed correctly you should see this domain responding on 127.0.0.1.

Valet will automatically start its required services each time your machine boots.

<a name="php-versions"></a>
[Laravel 12] Explain valet: PHP Versions

> [!NOTE]
> Instead of modifying your global PHP version, you can instruct Valet to use per-site PHP versions via the isolate command.

Valet allows you to switch PHP versions using the valet use php@version command. Valet will install the specified PHP version via Homebrew if it is not already installed:

You may also create a .valetrc file in the root of your project. The .valetrc file should contain the PHP version the site should use:

Once this file has been created, you may simply execute the valet use command and the command will determine the site's preferred PHP version by reading the file.

> [!WARNING]
> Valet only serves one PHP version at a time, even if you have multiple PHP versions installed.

<a name="database"></a>
[Laravel 12] Explain validation: Validation

- Introduction
- Validation Quickstart
    - Defining the Routes
    - Creating the Controller
    - Writing the Validation Logic
    - Displaying the Validation Errors
    - Repopulating Forms
    - A Note on Optional Fields
    - Validation Error Response Format
- Form Request Validation
    - Creating Form Requests
    - Authorizing Form Requests
    - Customizing the Error Messages
    - Preparing Input for Validation
- Manually Creating Validators
    - Automatic Redirection
    - Named Error Bags
    - Customizing the Error Messages
    - Performing Additional Validation
- Working With Validated Input
- Working With Error Messages
    - Specifying Custom Messages in Language Files
    - Specifying Attributes in Language Files
    - Specifying Values in Language Files
- Available Validation Rules
- Conditionally Adding Rules
- Validating Arrays
    - Validating Nested Array Input
    - Error Message Indexes and Positions
- Validating Files
- Validating Passwords
- Custom Validation Rules
    - Using Rule Objects
    - Using Closures
    - Implicit Rules

<a name="introduction"></a>
[Laravel 12] Explain validation: Introduction

Laravel provides several different approaches to validate your application's incoming data. It is most common to use the validate method available on all incoming HTTP requests. However, we will discuss other approaches to validation as well.

Laravel includes a wide variety of convenient validation rules that you may apply to data, even providing the ability to validate if values are unique in a given database table. We'll cover each of these validation rules in detail so that you are familiar with all of Laravel's validation features.

<a name="validation-quickstart"></a>
[Laravel 12] Explain verification: Introduction

Many web applications require users to verify their email addresses before using the application. Rather than forcing you to re-implement this feature by hand for each application you create, Laravel provides convenient built-in services for sending and verifying email verification requests.

> [!NOTE]
> Want to get started fast? Install one of the Laravel application starter kits in a fresh Laravel application. The starter kits will take care of scaffolding your entire authentication system, including email verification support.

<a name="model-preparation"></a>
[Laravel 12] Explain verification: Model Preparation

Before getting started, verify that your App\Models\User model implements the Illuminate\Contracts\Auth\MustVerifyEmail contract:

Once this interface has been added to your model, newly registered users will automatically be sent an email containing an email verification link. This happens seamlessly because Laravel automatically registers the Illuminate\Auth\Listeners\SendEmailVerificationNotification listener for the Illuminate\Auth\Events\Registered event.

If you are manually implementing registration within your application instead of using a starter kit, you should ensure that you are dispatching the Illuminate\Auth\Events\Registered event after a user's registration is successful:

<a name="database-preparation"></a>
[Laravel 12] Explain verification: Routing

To properly implement email verification, three routes will need to be defined. First, a route will be needed to display a notice to the user that they should click the email verification link in the verification email that Laravel sent them after registration.

Second, a route will be needed to handle requests generated when the user clicks the email verification link in the email.

Third, a route will be needed to resend a verification link if the user accidentally loses the first verification link.

<a name="the-email-verification-notice"></a>
[Laravel 12] Explain views: Views

- Introduction
    - Writing Views in React / Svelte / Vue
- Creating and Rendering Views
    - Nested View Directories
    - Creating the First Available View
    - Determining if a View Exists
- Passing Data to Views
    - Sharing Data With All Views
- View Composers
    - View Creators
- Optimizing Views

<a name="introduction"></a>
[Laravel 12] Explain views: Introduction

Of course, it's not practical to return entire HTML documents strings directly from your routes and controllers. Thankfully, views provide a convenient way to place all of our HTML in separate files.

Views separate your controller / application logic from your presentation logic and are stored in the resources/views directory. When using Laravel, view templates are usually written using the Blade templating language. A simple view might look something like this:

Since this view is stored at resources/views/greeting.blade.php, we may return it using the global view helper like so:

> [!NOTE]
> Looking for more information on how to write Blade templates? Check out the full Blade documentation to get started.

<a name="writing-views-in-react-svelte-or-vue"></a>
[Laravel 12] Explain views: Writing Views in React / Svelte / Vue

Instead of writing their frontend templates in PHP via Blade, many developers have begun to prefer to write their templates using React, Svelte, or Vue. Laravel makes this painless thanks to Inertia, a library that makes it a cinch to tie your React / Svelte / Vue frontend to your Laravel backend without the typical complexities of building an SPA.

Our React, Svelte, and Vue application starter kits give you a great starting point for your next Laravel application powered by Inertia.

<a name="creating-and-rendering-views"></a>
[Laravel 12] Explain views: Creating and Rendering Views

You may create a view by placing a file with the .blade.php extension in your application's resources/views directory or by using the make:view Artisan command:

The .blade.php extension informs the framework that the file contains a Blade template. Blade templates contain HTML as well as Blade directives that allow you to easily echo values, create "if" statements, iterate over data, and more.

Once you have created a view, you may return it from one of your application's routes or controllers using the global view helper:

Views may also be returned using the View facade:

As you can see, the first argument passed to the view helper corresponds to the name of the view file in the resources/views directory. The second argument is an array of data that should be made available to the view. In this case, we are passing the name variable, which is displayed in the view using Blade syntax.

<a name="nested-view-directories"></a>
[Laravel 12] Explain views: Nested View Directories

Views may also be nested within subdirectories of the resources/views directory. "Dot" notation may be used to reference nested views. For example, if your view is stored at resources/views/admin/profile.blade.php, you may return it from one of your application's routes / controllers like so:

> [!WARNING]
> View directory names should not contain the . character.

<a name="creating-the-first-available-view"></a>
[Laravel 12] Explain vite: Asset Bundling (Vite)

- Introduction
- Installation & Setup
  - Installing Node
  - Installing Vite and the Laravel Plugin
  - Configuring Vite
  - Loading Your Scripts and Styles
- Running Vite
- Working With JavaScript
  - Aliases
  - Vue
  - React
  - Svelte
  - Inertia
  - URL Processing
- Working With Stylesheets
- Working With Blade and Routes
  - Processing Static Assets With Vite
  - Refreshing on Save
  - Aliases
- Asset Prefetching
- Custom Base URLs
- Environment Variables
- Disabling Vite in Tests
- Server-Side Rendering (SSR)
- Script and Style Tag Attributes
  - Content Security Policy (CSP) Nonce
  - Subresource Integrity (SRI)
  - Arbitrary Attributes
- Advanced Customization
  - Dev Server Cross-Origin Resource Sharing (CORS)
  - Correcting Dev Server URLs

<a name="introduction"></a>
[Laravel 12] Explain vite: Introduction

Vite is a modern frontend build tool that provides an extremely fast development environment and bundles your code for production. When building applications with Laravel, you will typically use Vite to bundle your application's CSS and JavaScript files into production-ready assets.

Laravel integrates seamlessly with Vite by providing an official plugin and Blade directive to load your assets for development and production.

<a name="installation"></a>
[Laravel 12] Explain vite: Installing Node

You must ensure that Node.js (16+) and NPM are installed before running Vite and the Laravel plugin:

You can easily install the latest version of Node and NPM using simple graphical installers from the official Node website. Or, if you are using Laravel Sail, you may invoke Node and NPM through Sail:

<a name="installing-vite-and-laravel-plugin"></a>
[Laravel 13] Explain ai sdk: Laravel AI SDK

- Introduction
- Installation
    - Configuration
    - Custom Base URLs
    - Provider Support
- Agents
    - Prompting
    - Conversation Context
    - Structured Output
    - Attachments
    - Streaming
    - Broadcasting
    - Queueing
    - Tools
    - MCP Tools
    - Provider Tools
    - Sub-Agents
    - Middleware
    - Anonymous Agents
    - Agent Configuration
    - Provider Options
- Images
- Audio (TTS)
- Transcription (STT)
- Embeddings
    - Querying Embeddings
    - Caching Embeddings
- Reranking
- Files
- Vector Stores
    - Adding Files to Stores
- Failover
- Testing
    - Agents
    - Images
    - Audio
    - Transcriptions
    - Embeddings
    - Reranking
    - Files
    - Vector Stores
- Events

<a name="introduction"></a>
[Laravel 13] Explain ai sdk: Custom Base URLs

By default, the Laravel AI SDK connects directly to each provider's public API endpoint. However, you may need to route requests through a different endpoint - for example, when using a proxy service to centralize API key management, implement rate limiting, or route traffic through a corporate gateway.

You may configure custom base URLs by adding a url parameter to your provider configuration:

This is useful when routing requests through a proxy service (such as LiteLLM or Azure OpenAI Gateway) or using alternative endpoints.

Custom base URLs are supported for the following providers: OpenAI, Anthropic, Gemini, Groq, Cohere, DeepSeek, xAI, and OpenRouter.

<a name="provider-support"></a>
[Laravel 13] Explain ai sdk: Provider Support

The AI SDK supports a variety of providers across its features. The following table summarizes which providers are available for each feature:

<div class="overflow-auto">

| Feature | Providers |
|---|---|
| Text | OpenAI, Anthropic, Gemini, Azure, Bedrock, Groq, xAI, DeepSeek, Mistral, Ollama, OpenRouter |
| Images | OpenAI, Gemini, xAI, Azure, Bedrock, OpenRouter |
| TTS | OpenAI, ElevenLabs, Gemini |
| STT | OpenAI, ElevenLabs, Mistral, Gemini |
| Embeddings | OpenAI, Gemini, Azure, Bedrock, Cohere, Mistral, Jina, VoyageAI, Ollama, OpenRouter |
| Reranking | Cohere, Jina, VoyageAI |
| Files | OpenAI, Anthropic, Gemini |

</div>

The Laravel\Ai\Enums\Lab enum may be used to reference providers throughout your code instead of using plain strings:

<a name="agents"></a>
[Laravel 13] Explain ai: Introduction

Laravel is uniquely positioned to be the best framework for AI assisted and agentic development. The rise of AI coding agents like Claude Code, OpenCode, Cursor, and GitHub Copilot has transformed how developers write code. These tools can generate entire features, debug complex issues, and refactor code at unprecedented speed - but their effectiveness depends heavily on how well they understand your codebase.

<a name="why-laravel-for-ai-development"></a>
[Laravel 13] Explain ai: Why Laravel for AI Development?

Laravel's opinionated conventions and well-defined structure make it an ideal framework for AI assisted development. When you ask an AI agent to add a controller, it knows exactly where to place it. When you need a new migration, the naming conventions and file locations are predictable. This consistency eliminates the guesswork that often trips up AI tools in more flexible frameworks.

Beyond file organization, Laravel's expressive syntax and comprehensive documentation give AI agents the context they need to generate accurate, idiomatic code. Features like Eloquent relationships, form requests, and middleware follow patterns that agents can reliably understand and replicate. The result is AI-generated code that looks like it was written by a seasoned Laravel developer, not stitched together from generic PHP snippets.

<a name="laravel-boost"></a>
[Laravel 13] Explain ai: Laravel Boost

Laravel Boost bridges the gap between AI coding agents and your Laravel application. Boost is an MCP (Model Context Protocol) server equipped with over 15 specialized tools that provide AI agents with deep insight into your application's structure, database, routes, and more. When you install Boost, your AI agent transforms from a general-purpose code assistant into a Laravel expert that understands your specific application.

Boost provides three major capabilities: a suite of MCP tools for inspecting and interacting with your application, composable AI guidelines crafted specifically for the Laravel ecosystem, and a powerful documentation API containing over 17,000 pieces of Laravel-specific knowledge.

<a name="installation"></a>
[Laravel 13] Explain ai: Installation

Boost can be installed in Laravel 10, 11, 12, and 13 applications running PHP 8.1 or higher. To get started, install Boost as a development dependency:

Once installed, run the interactive installer:

The installer will auto-detect your IDE and AI agents, allowing you to select the integrations that make sense for your project. Boost will generate the necessary configuration files, such as .mcp.json for MCP-compatible editors and guideline files for AI context.

> [!NOTE]
> Generated configuration files like .mcp.json, CLAUDE.md, and boost.json can be safely added to your .gitignore if you prefer each developer to configure their own environment.

<a name="available-tools"></a>
[Laravel 13] Explain ai: Available Tools

Boost exposes a comprehensive set of tools to AI agents via the Model Context Protocol. These tools allow agents to deeply understand and interact with your Laravel application:

<div class="content-list" markdown="1">

- **Application Introspection** - Query your PHP and Laravel versions, list installed packages, and inspect your application's configuration and environment variables.
- **Database Tools** - Inspect your database schema, execute read-only queries, and understand your data structure without leaving the conversation.
- **Route Inspection** - List all registered routes with their middleware, controllers, and parameters.
- **Artisan Commands** - Discover available Artisan commands and their arguments, enabling agents to suggest and execute the right commands for your task.
- **Log Analysis** - Read and analyze your application's log files to help debug issues.
- **Browser Logs** - Access browser console logs and errors when developing with Laravel's frontend tools.
- **Tinker Integration** - Execute PHP code in the context of your application via Laravel Tinker, allowing agents to test hypotheses and verify behavior.
- **Documentation Search** - Search Laravel ecosystem documentation with results tailored to your installed package versions.

</div>

<a name="ai-guidelines"></a>
[Laravel 13] Explain artisan: Artisan Console

- Introduction
    - Tinker (REPL)
- Writing Commands
    - Generating Commands
    - Command Structure
    - Closure Commands
    - Isolatable Commands
- Defining Input Expectations
    - Arguments
    - Options
    - Input Arrays
    - Input Descriptions
    - Prompting for Missing Input
- Command I/O
    - Retrieving Input
    - Prompting for Input
    - Writing Output
- Registering Commands
- Programmatically Executing Commands
    - Calling Commands From Other Commands
- Signal Handling
- Stub Customization
- Events

<a name="introduction"></a>