bhavin-gajjar/laravel-coder-lora-train huggingface dataset:
[Laravel 13] 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 13] 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 13] 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 13] 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 13] Explain valet: Resetting Your Installation

If you are having trouble getting your Valet installation to run properly, executing the composer global require laravel/valet command followed by valet install will reset your installation and can solve a variety of problems. In rare cases, it may be necessary to "hard reset" Valet by executing valet uninstall --force followed by valet install.

<a name="upgrading-valet"></a>
[Laravel 13] 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 13] 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 13] Explain validation: Writing the Validation Logic

Now we are ready to fill in our store method with the logic to validate the new blog post. To do this, we will use the validate method provided by the Illuminate\Http\Request object. If the validation rules pass, your code will keep executing normally; however, if validation fails, an Illuminate\Validation\ValidationException exception will be thrown and the proper error response will automatically be sent back to the user.

If validation fails during a traditional HTTP request, a redirect response to the previous URL will be generated. If the incoming request is an XHR request, a JSON response containing the validation error messages will be returned.

To get a better understanding of the validate method, let's jump back into the store method:

As you can see, the validation rules are passed into the validate method. Don't worry - all available validation rules are documented. Again, if the validation fails, the proper response will automatically be generated. If the validation passes, our controller will continue executing normally.

In addition, you may use the validateWithBag method to validate a request and store any error messages within a named error bag:

<a name="stopping-on-first-validation-failure"></a>
[Laravel 13] 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 13] 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 13] 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 13] Explain verification: The Email Verification Notice

As mentioned previously, a route should be defined that will return a view instructing the user to click the email verification link that was emailed to them by Laravel after registration. This view will be displayed to users when they try to access other parts of the application without verifying their email address first. Remember, the link is automatically emailed to the user as long as your App\Models\User model implements the MustVerifyEmail interface:

The route that returns the email verification notice should be named verification.notice. It is important that the route is assigned this exact name since the verified middleware included with Laravel will automatically redirect to this route name if a user has not verified their email address.

> [!NOTE]
> When manually implementing email verification, you are required to define the contents of the verification notice view yourself. If you would like scaffolding that includes all necessary authentication and verification views, check out the Laravel application starter kits.

<a name="the-email-verification-handler"></a>
[Laravel 13] 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 13] 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 13] 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 13] 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 13] 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 13] 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 Fonts
  - Font Providers
  - Local Fonts
  - Font Options
- 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 13] 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 13] 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 vite: Configuring Vite

Vite is configured via a vite.config.js file in the root of your project. You are free to customize this file based on your needs, and you may also install any other plugins your application requires, such as @vitejs/plugin-react, @sveltejs/vite-plugin-svelte or @vitejs/plugin-vue.

The Laravel Vite plugin requires you to specify the entry points for your application. These may be JavaScript or CSS files, and include preprocessed languages such as TypeScript, JSX, TSX, and Sass.

If you are building an SPA, including applications built using Inertia, Vite works best without CSS entry points:

Instead, you should import your CSS via JavaScript. Typically, this would be done in your application's resources/js/app.js file:

The Laravel plugin also supports multiple entry points and advanced configuration options such as SSR entry points.

<a name="working-with-a-secure-development-server"></a>