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

- Introduction
    - Passport or Sanctum?
- Installation
    - Deploying Passport
    - Upgrading Passport
- Configuration
    - Token Lifetimes
    - Overriding Default Models
    - Overriding Routes
- Authorization Code Grant
    - Managing Clients
    - Requesting Tokens
    - Managing Tokens
    - Refreshing Tokens
    - Revoking Tokens
    - Purging Tokens
- Authorization Code Grant With PKCE
    - Creating the Client
    - Requesting Tokens
- Device Authorization Grant
    - Creating a Device Code Grant Client
    - Requesting Tokens
- Password Grant
    - Creating a Password Grant Client
    - Requesting Tokens
    - Requesting All Scopes
    - Customizing the User Provider
    - Customizing the Username Field
    - Customizing the Password Validation
- Implicit Grant
- Client Credentials Grant
- Personal Access Tokens
    - Creating a Personal Access Client
    - Customizing the User Provider
    - Managing Personal Access Tokens
- Protecting Routes
    - Via Middleware
    - Passing the Access Token
- Token Scopes
    - Defining Scopes
    - Default Scope
    - Assigning Scopes to Tokens
    - Checking Scopes
- SPA Authentication
- Events
- Testing

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

Laravel Passport provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Andy Millington and Simon Hamp.

> [!NOTE]
> This documentation assumes you are already familiar with OAuth2. If you do not know anything about OAuth2, consider familiarizing yourself with the general terminology and features of OAuth2 before continuing.

<a name="passport-or-sanctum"></a>
[Laravel 12] Explain passport: Passport or Sanctum?

Before getting started, you may wish to determine if your application would be better served by Laravel Passport or Laravel Sanctum. If your application absolutely needs to support OAuth2, then you should use Laravel Passport.

However, if you are attempting to authenticate a single-page application, mobile application, or issue API tokens, you should use Laravel Sanctum. Laravel Sanctum does not support OAuth2; however, it provides a much simpler API authentication development experience.

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

You may install Laravel Passport via the install:api Artisan command:

This command will publish and run the database migrations necessary for creating the tables your application needs to store OAuth2 clients and access tokens. The command will also create the encryption keys required to generate secure access tokens.

After running the install:api command, add the Laravel\Passport\HasApiTokens trait and Laravel\Passport\Contracts\OAuthenticatable interface to your App\Models\User model. This trait will provide a few helper methods to your model which allow you to inspect the authenticated user's token and scopes:

Finally, in your application's config/auth.php configuration file, you should define an api authentication guard and set the driver option to passport. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests:

<a name="deploying-passport"></a>
[Laravel 12] Explain passport: Deploying Passport

When deploying Passport to your application's servers for the first time, you will likely need to run the passport:keys command. This command generates the encryption keys Passport needs in order to generate access tokens. The generated keys are not typically kept in source control:

If necessary, you may define the path where Passport's keys should be loaded from. You may use the Passport::loadKeysFrom method to accomplish this. Typically, this method should be called from the boot method of your application's App\Providers\AppServiceProvider class:

<a name="loading-keys-from-the-environment"></a>
[Laravel 12] Explain passwords: Introduction

Most web applications provide a way for users to reset their forgotten passwords. Rather than forcing you to re-implement this by hand for every application you create, Laravel provides convenient services for sending password reset links and secure resetting passwords.

> [!NOTE]
> Want to get started fast? Install a Laravel application starter kit in a fresh Laravel application. Laravel's starter kits will take care of scaffolding your entire authentication system, including resetting forgotten passwords.

<a name="configuration"></a>
[Laravel 12] Explain passwords: Configuration

Your application's password reset configuration file is stored at config/auth.php. Be sure to review the options available to you in this file. By default, Laravel is configured to use the database password reset driver.

The password reset driver configuration option defines where password reset data will be stored. Laravel includes two drivers:

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

- database - password reset data is stored in a relational database.
- cache - password reset data is stored in one of your cache-based stores.

</div>

<a name="driver-prerequisites"></a>
[Laravel 12] Explain passwords: Cache

There is also a cache driver available for handling password resets, which does not require a dedicated database table. Entries are keyed by the user's email address, so ensure you are not using email addresses as a cache key elsewhere in your application:

To prevent a call to artisan cache:clear from flushing your password reset data, you can optionally specify a separate cache store with the store configuration key. The value should correspond to a store configured in your config/cache.php configuration value.

<a name="model-preparation"></a>
[Laravel 12] Explain pennant: Laravel Pennant

- Introduction
- Installation
- Configuration
- Defining Features
    - Class Based Features
- Checking Features
    - Conditional Execution
    - The HasFeatures Trait
    - Blade Directive
    - Middleware
    - Intercepting Feature Checks
    - In-Memory Cache
- Scope
    - Specifying the Scope
    - Default Scope
    - Nullable Scope
    - Identifying Scope
    - Serializing Scope
- Rich Feature Values
- Retrieving Multiple Features
- Eager Loading
- Updating Values
    - Bulk Updates
    - Purging Features
- Testing
- Adding Custom Pennant Drivers
    - Implementing the Driver
    - Registering the Driver
    - Defining Features Externally
- Events

<a name="introduction"></a>
[Laravel 12] Explain pennant: Configuration

After publishing Pennant's assets, its configuration file will be located at config/pennant.php. This configuration file allows you to specify the default storage mechanism that will be used by Pennant to store resolved feature flag values.

Pennant includes support for storing resolved feature flag values in an in-memory array via the array driver. Or, Pennant can store resolved feature flag values persistently in a relational database via the database driver, which is the default storage mechanism used by Pennant.

<a name="defining-features"></a>
[Laravel 12] Explain pennant: Defining Features

To define a feature, you may use the define method offered by the Feature facade. You will need to provide a name for the feature, as well as a closure that will be invoked to resolve the feature's initial value.

Typically, features are defined in a service provider using the Feature facade. The closure will receive the "scope" for the feature check. Most commonly, the scope is the currently authenticated user. In this example, we will define a feature for incrementally rolling out a new API to our application's users:

As you can see, we have the following rules for our feature:

- All internal team members should be using the new API.
- Any high traffic customers should not be using the new API.
- Otherwise, the feature should be randomly assigned to users with a 1 in 100 chance of being active.

The first time the new-api feature is checked for a given user, the result of the closure will be stored by the storage driver. The next time the feature is checked against the same user, the value will be retrieved from storage and the closure will not be invoked.

For convenience, if a feature definition only returns a lottery, you may omit the closure completely:

    Feature::define('site-redesign', Lottery::odds(1, 1000));

<a name="class-based-features"></a>
[Laravel 12] Explain pint: Introduction

Laravel Pint is an opinionated PHP code style fixer for minimalists. Pint is built on top of PHP CS Fixer and makes it simple to ensure that your code style stays clean and consistent.

Pint is automatically installed with all new Laravel applications so you may start using it immediately. By default, Pint does not require any configuration and will fix code style issues in your code by following the opinionated coding style of Laravel.

<a name="installation"></a>
[Laravel 12] Explain pint: Running Pint

You can instruct Pint to fix code style issues by invoking the pint binary that is available in your project's vendor/bin directory:

If you would like Pint to run in parallel mode (experimental) for improved performance, you may use the --parallel option:

Parallel mode also allows you to specify the maximum number of processes to run via the --max-processes option. If this option is not provided, Pint will use every available core on your machine:

You may also run Pint on specific files or directories:

Pint will display a thorough list of all of the files that it updates. You can view even more detail about Pint's changes by providing the -v option when invoking Pint:

If you would like Pint to simply inspect your code for style errors without actually changing the files, you may use the --test option. Pint will return a non-zero exit code if any code style errors are found:

If you would like Pint to only modify the files that differ from the provided branch according to Git, you may use the --diff=[branch] option. This can be effectively used in your CI environment (like GitHub actions) to save time by only inspecting new or modified files:

If you would like Pint to only modify the files that have uncommitted changes according to Git, you may use the --dirty option:

If you would like Pint to fix any files with code style errors but also exit with a non-zero exit code if any errors were fixed, you may use the --repair option:

<a name="configuring-pint"></a>
[Laravel 12] Explain pint: Configuring Pint

As previously mentioned, Pint does not require any configuration. However, if you wish to customize the presets, rules, or inspected folders, you may do so by creating a pint.json file in your project's root directory:

In addition, if you wish to use a pint.json from a specific directory, you may provide the --config option when invoking Pint:

<a name="presets"></a>
[Laravel 12] Explain precognition: Introduction

Laravel Precognition allows you to anticipate the outcome of a future HTTP request. One of the primary use cases of Precognition is the ability to provide "live" validation for your frontend JavaScript application without having to duplicate your application's backend validation rules.

When Laravel receives a "precognitive request", it will execute all of the route's middleware and resolve the route's controller dependencies, including validating form requests - but it will not actually execute the route's controller method.

> [!NOTE]
> As of Inertia 2.3, Precognition support is built-in. Please consult the Inertia Forms documentation for more information. Earlier Inertia versions require Precognition 0.x.

<a name="live-validation"></a>
[Laravel 12] Explain precognition: Using Vue

Using Laravel Precognition, you can offer live validation experiences to your users without having to duplicate your validation rules in your frontend Vue application. To illustrate how it works, let's build a form for creating new users within our application.

First, to enable Precognition for a route, the HandlePrecognitiveRequests middleware should be added to the route definition. You should also create a form request to house the route's validation rules:

Next, you should install the Laravel Precognition frontend helpers for Vue via NPM:

With the Laravel Precognition package installed, you can now create a form object using Precognition's useForm function, providing the HTTP method (post), the target URL (/users), and the initial form data.

Then, to enable live validation, invoke the form's validate method on each input's change event, providing the input's name:

Now, as the form is filled by the user, Precognition will provide live validation output powered by the validation rules in the route's form request. When the form's inputs are changed, a debounced "precognitive" validation request will be sent to your Laravel application. You may configure the debounce timeout by calling the form's setValidationTimeout function:

When a validation request is in-flight, the form's validating property will be true:

Any validation errors returned during a validation request or a form submission will automatically populate the form's errors object:

You can determine if the form has any errors using the form's hasErrors property:

You may also determine if an input has passed or failed validation by passing the input's name to the form's valid and invalid functions, respectively:

> [!WARNING]
> A form input will only appear as valid or invalid once it has changed and a validation response has been received.

If you are validating a subset of a form's inputs with Precognition, it can be useful to manually clear errors. You may use the form's forgetError function to
[Laravel 12] Explain precognition: Using React

Using Laravel Precognition, you can offer live validation experiences to your users without having to duplicate your validation rules in your frontend React application. To illustrate how it works, let's build a form for creating new users within our application.

First, to enable Precognition for a route, the HandlePrecognitiveRequests middleware should be added to the route definition. You should also create a form request to house the route's validation rules:

Next, you should install the Laravel Precognition frontend helpers for React via NPM:

With the Laravel Precognition package installed, you can now create a form object using Precognition's useForm function, providing the HTTP method (post), the target URL (/users), and the initial form data.

To enable live validation, you should listen to each input's change and blur event. In the change event handler, you should set the form's data with the setData function, passing the input's name and new value. Then, in the blur event handler invoke the form's validate method, providing the input's name:

Now, as the form is filled by the user, Precognition will provide live validation output powered by the validation rules in the route's form request. When the form's inputs are changed, a debounced "precognitive" validation request will be sent to your Laravel application. You may configure the debounce timeout by calling the form's setValidationTimeout function:

When a validation request is in-flight, the form's validating property will be true:

Any validation errors returned during a validation request or a form submission will automatically populate the form's errors object:

You can determine if the form has any errors using the form's hasErrors property:

You may also determine if an input has passed or failed validation by passing the input's name to the form's valid and invalid functions, respectively:

> [!WARNING]
> A form input will only appear as valid or invalid once it has changed and a validation res
[Laravel 12] Explain precognition: Using Alpine and Blade

Using Laravel Precognition, you can offer live validation experiences to your users without having to duplicate your validation rules in your frontend Alpine application. To illustrate how it works, let's build a form for creating new users within our application.

First, to enable Precognition for a route, the HandlePrecognitiveRequests middleware should be added to the route definition. You should also create a form request to house the route's validation rules:

Next, you should install the Laravel Precognition frontend helpers for Alpine via NPM:

Then, register the Precognition plugin with Alpine in your resources/js/app.js file:

With the Laravel Precognition package installed and registered, you can now create a form object using Precognition's $form "magic", providing the HTTP method (post), the target URL (/users), and the initial form data.

To enable live validation, you should bind the form's data to its relevant input and then listen to each input's change event. In the change event handler, you should invoke the form's validate method, providing the input's name:

Now, as the form is filled by the user, Precognition will provide live validation output powered by the validation rules in the route's form request. When the form's inputs are changed, a debounced "precognitive" validation request will be sent to your Laravel application. You may configure the debounce timeout by calling the form's setValidationTimeout function:

When a validation request is in-flight, the form's validating property will be true:

Any validation errors returned during a validation request or a form submission will automatically populate the form's errors object:

You can determine if the form has any errors using the form's hasErrors property:

You may also determine if an input has passed or failed validation by passing the input's name to the form's valid and invalid functions, respectively:

> [!WARNING]
> A form input will only appear as valid or invalid once it has chan
[Laravel 12] Explain processes: Processes

- Introduction
- Invoking Processes
    - Process Options
    - Process Output
    - Pipelines
- Asynchronous Processes
    - Process IDs and Signals
    - Asynchronous Process Output
    - Asynchronous Process Timeouts
- Concurrent Processes
    - Naming Pool Processes
    - Pool Process IDs and Signals
- Testing
    - Faking Processes
    - Faking Specific Processes
    - Faking Process Sequences
    - Faking Asynchronous Process Lifecycles
    - Available Assertions
    - Preventing Stray Processes

<a name="introduction"></a>
[Laravel 12] Explain processes: Invoking Processes

To invoke a process, you may use the run and start methods offered by the Process facade. The run method will invoke a process and wait for the process to finish executing, while the start method is used for asynchronous process execution. We'll examine both approaches within this documentation. First, let's examine how to invoke a basic, synchronous process and inspect its result:

Of course, the Illuminate\Contracts\Process\ProcessResult instance returned by the run method offers a variety of helpful methods that may be used to inspect the process result:

<a name="throwing-exceptions"></a>
[Laravel 12] Explain prompts: Prompts

- Introduction
- Installation
- Available Prompts
    - Text
    - Textarea
    - Number
    - Password
    - Confirm
    - Select
    - Multi-select
    - Suggest
    - Search
    - Multi-search
    - Pause
    - Autocomplete
- Transforming Input Before Validation
- Forms
- Informational Messages
- Tables
- Spin
- Progress Bar
- Task
- Stream
- Terminal Title
- Notifications
- Clearing the Terminal
- Terminal Considerations
- Unsupported Environments and Fallbacks
- Testing

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

Laravel Prompts is a PHP package for adding beautiful and user-friendly forms to your command-line applications, with browser-like features including placeholder text and validation.

<img src="https://laravel.com/img/docs/prompts-example.png">

Laravel Prompts is perfect for accepting user input in your Artisan console commands, but it may also be used in any command-line PHP project.

> [!NOTE]
> Laravel Prompts supports macOS, Linux, and Windows with WSL. For more information, please see our documentation on unsupported environments & fallbacks.

<a name="installation"></a>
[Laravel 12] Explain providers: Introduction

Service providers are the central place of all Laravel application bootstrapping. Your own application, as well as all of Laravel's core services, are bootstrapped via service providers.

But, what do we mean by "bootstrapped"? In general, we mean **registering** things, including registering service container bindings, event listeners, middleware, and even routes. Service providers are the central place to configure your application.

Laravel uses dozens of service providers internally to bootstrap its core services, such as the mailer, queue, cache, and others. Many of these providers are "deferred" providers, meaning they will not be loaded on every request, but only when the services they provide are actually needed.

All user-defined service providers are registered in the bootstrap/providers.php file. In the following documentation, you will learn how to write your own service providers and register them with your Laravel application.

> [!NOTE]
> If you would like to learn more about how Laravel handles requests and works internally, check out our documentation on the Laravel request lifecycle.

<a name="writing-service-providers"></a>
[Laravel 12] Explain providers: Writing Service Providers

All service providers extend the Illuminate\Support\ServiceProvider class. Most service providers contain a register and a boot method. Within the register method, you should **only bind things into the service container**. You should never attempt to register any event listeners, routes, or any other piece of functionality within the register method.

The Artisan CLI can generate a new provider via the make:provider command. Laravel will automatically register your new provider in your application's bootstrap/providers.php file:

<a name="the-register-method"></a>
[Laravel 12] Explain providers: The Register Method

As mentioned previously, within the register method, you should only bind things into the service container. You should never attempt to register any event listeners, routes, or any other piece of functionality within the register method. Otherwise, you may accidentally use a service that is provided by a service provider which has not loaded yet.

Let's take a look at a basic service provider. Within any of your service provider methods, you always have access to the $app property which provides access to the service container:

This service provider only defines a register method, and uses that method to define an implementation of App\Services\Riak\Connection in the service container. If you're not yet familiar with Laravel's service container, check out its documentation.

<a name="the-bindings-and-singletons-properties"></a>
[Laravel 12] Explain pulse: Laravel Pulse

- Introduction
- Installation
    - Configuration
- Dashboard
    - Authorization
    - Customization
    - Resolving Users
    - Cards
- Capturing Entries
    - Recorders
    - Filtering
- Performance
    - Using a Different Database
    - Redis Ingest
    - Sampling
    - Trimming
    - Handling Pulse Exceptions
- Custom Cards
    - Card Components
    - Styling
    - Data Capture and Aggregation

<a name="introduction"></a>
[Laravel 12] Explain pulse: Installation

> [!WARNING]
> Pulse's first-party storage implementation currently requires a MySQL, MariaDB, or PostgreSQL database. If you are using a different database engine, you will need a separate MySQL, MariaDB, or PostgreSQL database for your Pulse data.

You may install Pulse using the Composer package manager:

Next, you should publish the Pulse configuration and migration files using the vendor:publish Artisan command:

Finally, you should run the migrate command in order to create the tables needed to store Pulse's data:

Once Pulse's database migrations have been run, you may access the Pulse dashboard via the /pulse route.

> [!NOTE]
> If you do not want to store Pulse data in your application's primary database, you may specify a dedicated database connection.

<a name="configuration"></a>