bhavin-gajjar/laravel-coder-lora-train huggingface dataset:
[Laravel 13] Explain redis: Clusters

If your application is utilizing a cluster of Redis servers, you should define these clusters within a clusters key of your Redis configuration. This configuration key does not exist by default so you will need to create it within your application's config/database.php configuration file:

By default, Laravel will use native Redis clustering since the options.cluster configuration value is set to redis. Redis clustering is a great default option, as it gracefully handles failover.

Laravel also supports client-side sharding when using Predis. However, client-side sharding does not handle failover; therefore, it is primarily suited for transient cached data that is available from another primary data store.

If you would like to use client-side sharding instead of native Redis clustering, you may remove the options.cluster configuration value within your application's config/database.php configuration file:

<a name="predis"></a>
[Laravel 13] Explain redis: Predis

If you would like your application to interact with Redis via the Predis package, you should ensure the REDIS_CLIENT environment variable's value is predis:

In addition to the default configuration options, Predis supports additional connection parameters that may be defined for each of your Redis servers. To utilize these additional configuration options, add them to your Redis server configuration in your application's config/database.php configuration file:

<a name="phpredis"></a>
[Laravel 13] Explain releases: Versioning Scheme

Laravel and its other first-party packages follow Semantic Versioning. Major framework releases are released every year (~Q1), while minor and patch releases may be released as often as every week. Minor and patch releases should **never** contain breaking changes.

When referencing the Laravel framework or its components from your application or package, you should always use a version constraint such as ^13.0, since major releases of Laravel do include breaking changes. However, we strive to always ensure you may update to a new major release in one day or less.

<a name="named-arguments"></a>
[Laravel 13] Explain releases: Support Policy

For all Laravel releases, bug fixes are provided for 18 months and security fixes are provided for 2 years. For all additional libraries, only the latest major release receives bug fixes. In addition, please review the database versions supported by Laravel.

<div class="overflow-auto">

| Version | PHP (*)   | Release             | Bug Fixes Until     | Security Fixes Until |
| ------- |-----------| ------------------- | ------------------- | -------------------- |
| 10      | 8.1 - 8.3 | February 14th, 2023 | August 6th, 2024    | February 4th, 2025   |
| 11      | 8.2 - 8.4 | March 12th, 2024    | September 3rd, 2025 | March 12th, 2026     |
| 12      | 8.2 - 8.5 | February 24th, 2025 | August 13th, 2026   | February 24th, 2027  |
| 13      | 8.3 - 8.5 | March 17th, 2026    | Q3 2027             | March 17th, 2028     |

</div>

<div class="version-colors">
    <div class="end-of-life">
        <div class="color-box"></div>
        <div>End of life</div>
    </div>
    <div class="security-fixes">
        <div class="color-box"></div>
        <div>Security fixes only</div>
    </div>
</div>

(*) Supported PHP versions

<a name="laravel-13"></a>
[Laravel 13] Explain releases: Minimal Breaking Changes

Much of our focus during this release cycle has been minimizing breaking changes. Instead, we have dedicated ourselves to shipping continuous quality-of-life improvements throughout the year that do not break existing applications.

Therefore, the Laravel 13 release is a relatively minor upgrade in terms of effort, while still delivering substantial new capabilities. In light of this, most Laravel applications may upgrade to Laravel 13 without changing much application code.

<a name="php-8"></a>
[Laravel 13] Explain requests: HTTP Requests

- Introduction
- Interacting With The Request
    - Accessing the Request
    - Request Path, Host, and Method
    - Request Headers
    - Request IP Address
    - Content Negotiation
    - PSR-7 Requests
- Input
    - Retrieving Input
    - Input Presence
    - Merging Additional Input
    - Old Input
    - Cookies
    - Input Trimming and Normalization
- Files
    - Retrieving Uploaded Files
    - Storing Uploaded Files
- Configuring Trusted Proxies
- Configuring Trusted Hosts

<a name="introduction"></a>
[Laravel 13] Explain requests: Accessing the Request

To obtain an instance of the current HTTP request via dependency injection, you should type-hint the Illuminate\Http\Request class on your route closure or controller method. The incoming request instance will automatically be injected by the Laravel service container:

As mentioned, you may also type-hint the Illuminate\Http\Request class on a route closure. The service container will automatically inject the incoming request into the closure when it is executed:

<a name="dependency-injection-route-parameters"></a>
[Laravel 13] Explain responses: HTTP Responses

- Creating Responses
    - Attaching Headers to Responses
    - Attaching Cookies to Responses
    - Cookies and Encryption
- Redirects
    - Redirecting to Named Routes
    - Redirecting to Controller Actions
    - Redirecting to External Domains
    - Redirecting With Flashed Session Data
- Other Response Types
    - View Responses
    - JSON Responses
    - File Downloads
    - File Responses
- Streamed Responses
    - Consuming Streamed Responses
    - Streamed JSON Responses
    - Event Streams (SSE)
    - Streamed Downloads
- Response Macros

<a name="creating-responses"></a>
[Laravel 13] Explain responses: Strings and Arrays

All routes and controllers should return a response to be sent back to the user's browser. Laravel provides several different ways to return responses. The most basic response is returning a string from a route or controller. The framework will automatically convert the string into a full HTTP response:

In addition to returning strings from your routes and controllers, you may also return arrays. The framework will automatically convert the array into a JSON response:

> [!NOTE]
> Did you know you can also return Eloquent collections from your routes or controllers? They will automatically be converted to JSON. Give it a shot!

<a name="response-objects"></a>
[Laravel 13] Explain responses: Response Objects

Typically, you won't just be returning simple strings or arrays from your route actions. Instead, you will be returning full Illuminate\Http\Response instances or views.

Returning a full Response instance allows you to customize the response's HTTP status code and headers. A Response instance inherits from the Symfony\Component\HttpFoundation\Response class, which provides a variety of methods for building HTTP responses:

<a name="eloquent-models-and-collections"></a>
[Laravel 13] Explain responses: Attaching Headers to Responses

Keep in mind that most response methods are chainable, allowing for the fluent construction of response instances. For example, you may use the header method to add a series of headers to the response before sending it back to the user:

Or, you may use the withHeaders method to specify an array of headers to be added to the response:

You can remove specific headers from an outgoing response using the withoutHeader method:

<a name="cache-control-middleware"></a>
[Laravel 13] Explain responses: Cache Control Middleware

Laravel includes a cache.headers middleware, which may be used to quickly set the Cache-Control header for a group of routes. Directives should be provided using the "snake case" equivalent of the corresponding cache-control directive and should be separated by a semicolon. If etag is specified in the list of directives, an MD5 hash of the response content will automatically be set as the ETag identifier:

<a name="attaching-cookies-to-responses"></a>
[Laravel 13] Explain reverb: Laravel Reverb

- Introduction
- Installation
- Configuration
    - Application Credentials
    - Allowed Origins
    - Additional Applications
    - SSL
- Running the Server
    - Debugging
    - Restarting
- Monitoring
- Running Reverb in Production
    - Open Files
    - Event Loop
    - Web Server
    - Ports
    - Process Management
    - Scaling
- Events

<a name="introduction"></a>
[Laravel 13] Explain routing: Routing

- Basic Routing
    - The Default Route Files
    - Redirect Routes
    - View Routes
    - Listing Your Routes
    - Routing Customization
- Route Parameters
    - Required Parameters
    - Optional Parameters
    - Regular Expression Constraints
- Named Routes
- Route Groups
    - Middleware
    - Controllers
    - Subdomain Routing
    - Route Prefixes
    - Route Name Prefixes
- Route Model Binding
    - Implicit Binding
    - Implicit Enum Binding
    - Explicit Binding
- Fallback Routes
- Rate Limiting
    - Defining Rate Limiters
    - Attaching Rate Limiters to Routes
- Form Method Spoofing
- Accessing the Current Route
- Cross-Origin Resource Sharing (CORS)
- Route Caching

<a name="basic-routing"></a>
[Laravel 13] Explain routing: The Default Route Files

All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by Laravel using the configuration specified in your application's bootstrap/app.php file. The routes/web.php file defines routes that are for your web interface. These routes are assigned the web middleware group, which provides features like session state and CSRF protection.

For most applications, you will begin by defining routes in your routes/web.php file. The routes defined in routes/web.php may be accessed by entering the defined route's URL in your browser. For example, you may access the following route by navigating to http://example.com/user in your browser:

<a name="api-routes"></a>
[Laravel 13] Explain routing: API Routes

If your application will also offer a stateless API, you may enable API routing using the install:api Artisan command:

The install:api command installs Laravel Sanctum, which provides a robust, yet simple API token authentication guard which can be used to authenticate third-party API consumers, SPAs, or mobile applications. In addition, the install:api command creates the routes/api.php file:

Of course, you are free to omit the auth:sanctum middleware on routes that should be publicly accessible.

The routes in routes/api.php are stateless and are assigned to the api middleware group. Additionally, the /api URI prefix is automatically applied to these routes, so you do not need to manually apply it to every route in the file. You may change the prefix by modifying your application's bootstrap/app.php file:

<a name="available-router-methods"></a>
[Laravel 13] Explain routing: Available Router Methods

The router allows you to register routes that respond to any HTTP verb:

Sometimes you may need to register a route that responds to multiple HTTP verbs. You may do so using the match method. Or, you may even register a route that responds to all HTTP verbs using the any method:

> [!NOTE]
> When defining multiple routes that share the same URI, routes using the get, post, put, patch, delete, and options methods should be defined before routes using the any, match, and redirect methods. This ensures the incoming request is matched with the correct route.

<a name="dependency-injection"></a>
[Laravel 13] Explain sail: Laravel Sail

- Introduction
- Installation and Setup
    - Rebuilding Sail Images
    - Configuring A Shell Alias
- Starting and Stopping Sail
- Executing Commands
    - Executing PHP Commands
    - Executing Composer Commands
    - Executing Artisan Commands
    - Executing Node / NPM Commands
- Interacting With Databases
    - MySQL
    - MongoDB
    - Redis
    - Valkey
    - Meilisearch
    - Typesense
- File Storage
- Running Tests
    - Laravel Dusk
- Previewing Emails
- Container CLI
- PHP Versions
    - Additional PHP Extensions
- Node Versions
- Sharing Your Site
- Debugging With Xdebug
  - Xdebug CLI Usage
  - Xdebug Browser Usage
- Customization

<a name="introduction"></a>
[Laravel 13] Explain sail: Introduction

Laravel Sail is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience.

At its heart, Sail is the compose.yaml file and the sail script that is stored at the root of your project. The sail script provides a CLI with convenient methods for interacting with the Docker containers defined by the compose.yaml file.

Laravel Sail is supported on macOS, Linux, and Windows (via WSL2).

<a name="installation"></a>
[Laravel 13] Explain sail: Installation and Setup

You may install Sail using the Composer package manager:

After Sail has been installed, you may run the sail:install Artisan command. This command will publish Sail's compose.yaml file to the root of your application and modify your .env file with the required environment variables in order to connect to the Docker services:

Finally, you may start Sail. To continue learning how to use Sail, please continue reading the remainder of this documentation:

> [!WARNING]
> If you are using Docker Desktop for Linux, you should use the default Docker context by executing the following command: docker context use default. In addition, if you encounter file permission errors within containers, you may need to set the SUPERVISOR_PHP_USER environment variable to root.

<a name="adding-additional-services"></a>
[Laravel 13] Explain sanctum: Laravel Sanctum

- Introduction
    - How it Works
- Installation
- Configuration
    - Overriding Default Models
- API Token Authentication
    - Issuing API Tokens
    - Token Abilities
    - Protecting Routes
    - Revoking Tokens
    - Token Expiration
- SPA Authentication
    - Configuration
    - Authenticating
    - Protecting Routes
    - Authorizing Private Broadcast Channels
- Mobile Application Authentication
    - Issuing API Tokens
    - Protecting Routes
    - Revoking Tokens
- Testing

<a name="introduction"></a>
[Laravel 13] Explain sanctum: API Tokens

First, Sanctum is a simple package you may use to issue API tokens to your users without the complication of OAuth. This feature is inspired by GitHub and other applications which issue "personal access tokens". For example, imagine the "account settings" of your application has a screen where a user may generate an API token for their account. You may use Sanctum to generate and manage those tokens. These tokens typically have a very long expiration time (years), but may be manually revoked by the user anytime.

Laravel Sanctum offers this feature by storing user API tokens in a single database table and authenticating incoming HTTP requests via the Authorization header which should contain a valid API token.

<a name="how-it-works-spa-authentication"></a>
[Laravel 13] Explain sanctum: SPA Authentication

Second, Sanctum exists to offer a simple way to authenticate single page applications (SPAs) that need to communicate with a Laravel powered API. These SPAs might exist in the same repository as your Laravel application or might be an entirely separate repository, such as an SPA created using Next.js or Nuxt.

For this feature, Sanctum does not use tokens of any kind. Instead, Sanctum uses Laravel's built-in cookie based session authentication services. Typically, Sanctum utilizes Laravel's web authentication guard to accomplish this. This provides the benefits of CSRF protection, session authentication, as well as protects against leakage of the authentication credentials via XSS.

Sanctum will only attempt to authenticate using cookies when the incoming request originates from your own SPA frontend. When Sanctum examines an incoming HTTP request, it will first check for an authentication cookie and, if none is present, Sanctum will then examine the Authorization header for a valid API token.

> [!NOTE]
> It is perfectly fine to use Sanctum only for API token authentication or only for SPA authentication. Just because you use Sanctum does not mean you are required to use both features it offers.

<a name="installation"></a>
[Laravel 13] Explain scheduling: Task Scheduling

- Introduction
- Defining Schedules
    - Scheduling Artisan Commands
    - Scheduling Queued Jobs
    - Scheduling Shell Commands
    - Schedule Frequency Options
    - Timezones
    - Preventing Task Overlaps
    - Running Tasks on One Server
    - Background Tasks
    - Maintenance Mode
    - Pausing Scheduled Tasks
    - Schedule Groups
- Running the Scheduler
    - Sub-Minute Scheduled Tasks
    - Running the Scheduler Locally
- Task Output
- Task Hooks
- Events

<a name="introduction"></a>
[Laravel 13] Explain scheduling: Introduction

In the past, you may have written a cron configuration entry for each task you needed to schedule on your server. However, this can quickly become a pain because your task schedule is no longer in source control and you must SSH into your server to view your existing cron entries or add additional entries.

Laravel's command scheduler offers a fresh approach to managing scheduled tasks on your server. The scheduler allows you to fluently and expressively define your command schedule within your Laravel application itself. When using the scheduler, only a single cron entry is needed on your server. Your task schedule is typically defined in your application's routes/console.php file.

<a name="defining-schedules"></a>
[Laravel 13] Explain scheduling: Defining Schedules

You may define all of your scheduled tasks in your application's routes/console.php file. To get started, let's take a look at an example. In this example, we will schedule a closure to be called every day at midnight. Within the closure we will execute a database query to clear a table:

In addition to scheduling using closures, you may also schedule invokable objects. Invokable objects are simple PHP classes that contain an __invoke method:

If you prefer to reserve your routes/console.php file for command definitions only, you may use the withSchedule method in your application's bootstrap/app.php file to define your scheduled tasks. This method accepts a closure that receives an instance of the scheduler:

If you would like to view an overview of your scheduled tasks and the next time they are scheduled to run, you may use the schedule:list Artisan command:

<a name="scheduling-artisan-commands"></a>
[Laravel 13] Explain scheduling: Scheduling Artisan Commands

In addition to scheduling closures, you may also schedule Artisan commands and system commands. For example, you may use the command method to schedule an Artisan command using either the command's name or class.

When scheduling Artisan commands using the command's class name, you may pass an array of additional command-line arguments that should be provided to the command when it is invoked:

<a name="scheduling-artisan-closure-commands"></a>
[Laravel 13] Explain scout: Laravel Scout

- Introduction
- Installation
    - Queueing
- Driver Prerequisites
- Configuration
    - Configuring Searchable Data
- Database / Collection Engines
    - Database Engine
    - Collection Engine
- Third-Party Engine Configuration
    - Configuring Model Indexes
    - Algolia
    - Meilisearch
    - Typesense
- Third-Party Engine Indexing
    - Batch Import
    - Adding Records
    - Updating Records
    - Removing Records
    - Pausing Indexing
    - Conditionally Searchable Model Instances
- Searching
    - Where Clauses
    - Pagination
    - Soft Deleting
    - Customizing Engine Searches
- Custom Engines

<a name="introduction"></a>
[Laravel 13] Explain scout: Introduction

Laravel Scout provides a simple, driver-based solution for adding full-text search to your Eloquent models. Using model observers, Scout will automatically keep your search indexes in sync with your Eloquent records.

Scout ships with a built-in database engine that uses MySQL / PostgreSQL full-text indexes and LIKE clauses to search your existing database — no external service required. For most applications, this is all you need. For an overview of all search options available in Laravel, consult the search documentation.

Scout also includes drivers for Algolia, Meilisearch, and Typesense when you need features like typo tolerance, faceted filtering, or geo-search at massive scale. A "collection" driver is also available for local development, and you are free to write custom engines as well.

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

First, install Scout via the Composer package manager:

After installing Scout, you should publish the Scout configuration file using the vendor:publish Artisan command. This command will publish the scout.php configuration file to your application's config directory:

Finally, add the Laravel\Scout\Searchable trait to the model you would like to make searchable. This trait will register a model observer that will automatically keep the model in sync with your search driver:

<a name="queueing"></a>
[Laravel 13] Explain scout: Queueing

When using an engine that is not the database or collection engine, you should strongly consider configuring a queue driver before using the library. Running a queue worker will allow Scout to queue all operations that sync your model information to your search indexes, providing much better response times for your application's web interface.

Once you have configured a queue driver, set the value of the queue option in your config/scout.php configuration file to true:

Even when the queue option is set to false, it's important to remember that some Scout drivers like Algolia and Meilisearch always index records asynchronously. In other words, even though the index operation has completed within your Laravel application, the search engine itself may not reflect the new and updated records immediately.

To specify the connection and queue that your Scout jobs utilize, you may define the queue configuration option as an array:

Of course, if you customize the connection and queue that Scout jobs utilize, you should run a queue worker to process jobs on that connection and queue:

<a name="unique-jobs"></a>
[Laravel 13] Explain scout: Unique Jobs

In write-heavy applications, you may wish to prevent Scout from queueing duplicate jobs for the same model records. You may opt into unique indexing jobs by registering the MakeSearchableUniquely and RemoveFromSearchUniquely job classes, typically within the boot method of a service provider:

These jobs use Laravel's unique job locks to avoid dispatching duplicate queued indexing operations for the same searchable model records while a matching job is already queued.

<a name="driver-prerequisites"></a>
[Laravel 13] Explain search: Search

- Introduction
    - Full-Text Search
    - Semantic / Vector Search
    - Reranking
    - Scout Search Engines
- Full-Text Search
    - Adding Full-Text Indexes
    - Running Full-Text Queries
- Semantic / Vector Search
    - Generating Embeddings
    - Storing and Indexing Vectors
    - Querying by Similarity
- Reranking Results
- Laravel Scout
    - Database Engine
    - Third-Party Engines
- Combining Techniques

<a name="introduction"></a>
[Laravel 13] Explain search: Introduction

Almost every application needs search. Whether your users are searching a knowledge base for relevant articles, exploring a product catalog, or asking natural-language questions against a corpus of documents, Laravel provides built-in tools to handle each of these scenarios — and you often don't need any external services to get there.

Most applications will find that the built-in database-powered options provided by Laravel are more than sufficient — external search services are only necessary when you need features like typo tolerance, faceted filtering, or geo-search at massive scale.

<a name="introduction-full-text-search"></a>