### Start Development Server Source: https://laravel.com/docs/13.x/installation Install frontend dependencies and launch the local development environment. ```shell cd example-app npm install && npm run build composer run dev ``` -------------------------------- ### Initialize Project Dependencies and Server Source: https://laravel.com/docs/13.x/starter-kits Navigate to the project directory, install frontend dependencies, build assets, and start the development server. ```shell cd my-app npm install && npm run build composer run dev ``` -------------------------------- ### Install Dusk and ChromeDriver Source: https://laravel.com/docs/13.x/dusk After installing the Dusk package, execute the dusk:install Artisan command to create the tests/Browser directory, an example Dusk test, and install the Chrome Driver binary. ```shell php artisan dusk:install ``` -------------------------------- ### Install PHP, Composer, and Laravel Installer Source: https://laravel.com/docs/13.x/installation Automated installation scripts for local development environments. ```shell /bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.5)" ``` ```shell # Run as administrator... Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.5')) ``` ```shell /bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.5)" ``` -------------------------------- ### Define an Asynchronous Process Route Source: https://laravel.com/docs/13.x/processes Example route demonstrating an asynchronous process interaction using the start method. ```php use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Route; Route::get('/import', function () { $process = Process::start('bash import.sh'); while ($process->running()) { Log::info($process->latestOutput()); Log::info($process->latestErrorOutput()); } return 'Done'; }); ``` -------------------------------- ### Install and Setup Laravel Pulse Source: https://laravel.com/docs/13.x/pulse Commands to install the Pulse package via Composer, publish necessary configuration and migration files, and execute database migrations. ```shell composer require laravel/pulse php artisan vendor:publish --provider="Laravel\Pulse\PulseServiceProvider" php artisan migrate ``` -------------------------------- ### Install Laravel Installer via Composer Source: https://laravel.com/docs/13.x/installation Alternative installation method if PHP and Composer are already present. ```shell composer global require laravel/installer ``` -------------------------------- ### Create Setup Intent for Subscriptions Source: https://laravel.com/docs/13.x/billing Pass a new setup intent to the view to prepare for secure payment collection. ```php return view('subscribe', [ 'intent' => $user->createSetupIntent() ]); ``` -------------------------------- ### Install Precognition React Helpers Source: https://laravel.com/docs/13.x/precognition Install the necessary frontend package via NPM. ```shell npm install laravel-precognition-react ``` -------------------------------- ### Setup RoadRunner via Laravel Sail Source: https://laravel.com/docs/13.x/octane Instructions for installing RoadRunner dependencies, retrieving the binary, and configuring the docker-compose service to use Octane. ```shell ./vendor/bin/sail up ./vendor/bin/sail composer require laravel/octane spiral/roadrunner-cli spiral/roadrunner-http ./vendor/bin/sail shell ./vendor/bin/rr get-binary ``` ```yaml services: laravel.test: environment: SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=roadrunner --host=0.0.0.0 --rpc-port=6001 --port='${APP_PORT:-80}'" ``` ```shell chmod +x ./rr ./vendor/bin/sail build --no-cache ``` -------------------------------- ### Install and initialize per-project Homestead Source: https://laravel.com/docs/13.x/homestead Commands to install Homestead as a project dependency and generate the necessary configuration files. ```shell composer require laravel/homestead --dev ``` ```shell # macOS / Linux... php vendor/bin/homestead make # Windows... vendor\\bin\\homestead make ``` -------------------------------- ### Travis CI Configuration for Dusk Tests Source: https://laravel.com/docs/13.x/dusk This YAML configuration for .travis.yml sets up PHP, installs dependencies, and prepares the environment for running Dusk tests. It includes steps to launch Chrome in headless mode and start the PHP development server. ```yaml language: php php: - 8.2 addons: chrome: stable install: - cp .env.testing .env - travis_retry composer install --no-interaction --prefer-dist - php artisan key:generate - php artisan dusk:chrome-driver before_script: - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & - php artisan serve --no-reload & script: - php artisan dusk ``` -------------------------------- ### Install Typesense PHP SDK Source: https://laravel.com/docs/13.x/scout Install the Typesense PHP SDK via Composer to begin integration. ```shell composer require typesense/typesense-php ``` -------------------------------- ### Install Postmark Driver Source: https://laravel.com/docs/13.x/mail Install the required Symfony Postmark and HTTP client packages. ```shell composer require symfony/postmark-mailer symfony/http-client ``` -------------------------------- ### Setup PHP Code Blocks Source: https://laravel.com/docs/13.x/envoy Use the @setup directive to execute arbitrary PHP code before tasks run. ```php @setup $now = new DateTime; @endsetup ``` -------------------------------- ### Install Supervisor on Ubuntu Source: https://laravel.com/docs/13.x/queues Use this command to install the Supervisor process monitor on an Ubuntu system. ```shell sudo apt-get install supervisor ``` -------------------------------- ### GitHub Actions Workflow for Dusk Tests Source: https://laravel.com/docs/13.x/dusk This GitHub Actions workflow defines a CI job to run Dusk tests. It checks out code, prepares the environment, sets up a MySQL database, installs dependencies, upgrades the Chrome driver, and starts the necessary servers before running the Dusk tests. ```yaml name: CI on: [push] jobs: dusk-php: runs-on: ubuntu-latest env: APP_URL: "http://127.0.0.1:8000" DB_USERNAME: root DB_PASSWORD: root MAIL_MAILER: log steps: - uses: actions/checkout@v5 - name: Prepare The Environment run: cp .env.example .env - name: Create Database run: | sudo systemctl start mysql mysql --user="root" --password="root" -e "CREATE DATABASE \ `my-database` character set UTF8mb4 collate utf8mb4_bin;" - name: Install Composer Dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Generate Application Key run: php artisan key:generate - name: Upgrade Chrome Driver run: php artisan dusk:chrome-driver --detect - name: Start Chrome Driver run: ./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 & - name: Run Laravel Server run: php artisan serve --no-reload & - name: Run Dusk Tests run: php artisan dusk - name: Upload Screenshots if: failure() uses: actions/upload-artifact@v4 with: name: screenshots path: tests/Browser/screenshots - name: Upload Console Logs if: failure() uses: actions/upload-artifact@v4 with: name: console path: tests/Browser/console ``` -------------------------------- ### Install frontend dependencies Source: https://laravel.com/docs/13.x/vite Install the application's frontend dependencies defined in package.json using NPM. ```shell npm install ``` -------------------------------- ### Install Broadcasting with Pusher Source: https://laravel.com/docs/13.x/broadcasting Enables broadcasting, prompts for Pusher credentials, and installs necessary SDKs. ```shell php artisan install:broadcasting --pusher ``` -------------------------------- ### Install Ably PHP SDK Source: https://laravel.com/docs/13.x/broadcasting Install the Ably PHP SDK using Composer for manual integration. ```shell composer require ably/ably-php ``` -------------------------------- ### Install Broadcasting with Ably Support Source: https://laravel.com/docs/13.x/broadcasting Use the Artisan command to install broadcasting with Ably support, which prompts for credentials and updates .env. ```shell php artisan install:broadcasting --ably ``` -------------------------------- ### start Source: https://laravel.com/docs/13.x/strings Adds a single instance of the given value to a string if it does not already start with that value. ```APIDOC ## start ### Description The `start` method adds a single instance of the given value to a string if it does not already start with that value. ### Usage ```php use Illuminate\Support\Str; $adjusted = Str::of('this/string')->start('/'); ``` ``` -------------------------------- ### Install Pusher PHP SDK Source: https://laravel.com/docs/13.x/broadcasting Install the Pusher Channels PHP SDK using Composer. ```shell composer require pusher/pusher-php-server ``` -------------------------------- ### Install Fortify Passkeys JavaScript Client Source: https://laravel.com/docs/13.x/fortify Install the official `@laravel/passkeys` npm package to handle WebAuthn ceremonies in your frontend. ```shell npm install @laravel/passkeys ``` -------------------------------- ### Install Meilisearch PHP SDK Source: https://laravel.com/docs/13.x/scout Install the Meilisearch PHP SDK and the required HTTP factory via Composer. ```shell composer require meilisearch/meilisearch-php http-interop/http-factory-guzzle ``` -------------------------------- ### Install Laravel AI SDK Source: https://laravel.com/docs/13.x/ai-sdk Install the package via Composer and publish the necessary configuration and migration files. ```shell composer require laravel/ai ``` ```shell php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider" ``` ```shell php artisan migrate ``` -------------------------------- ### Run Laravel Boost Installer Source: https://laravel.com/docs/13.x/ai Execute the interactive installer to configure IDE and AI agent integrations. ```shell php artisan boost:install ``` -------------------------------- ### Install Laravel Boost Source: https://laravel.com/docs/13.x/boost Use Composer to add the package to your project and run the installation command to generate configuration files. ```shell composer require laravel/boost --dev ``` ```shell php artisan boost:install ``` -------------------------------- ### Install spatie/fork Package Source: https://laravel.com/docs/13.x/concurrency Install the spatie/fork package to use the 'fork' driver for improved concurrency performance. This driver is only available in PHP's CLI context. ```shell composer require spatie/fork ``` -------------------------------- ### Install Swoole and Open Swoole Extensions Source: https://laravel.com/docs/13.x/octane Commands to install the required PHP extensions for Swoole and Open Swoole via PECL. ```shell pecl install swoole ``` ```shell pecl install openswoole ``` -------------------------------- ### Install SRI Plugin Source: https://laravel.com/docs/13.x/vite Install the vite-plugin-manifest-sri package to enable Subresource Integrity hashes. ```shell npm install --save-dev vite-plugin-manifest-sri ``` -------------------------------- ### Install and configure React for Vite Source: https://laravel.com/docs/13.x/vite Install the React plugin and include the required Blade directives in your templates. ```shell npm install --save-dev @vitejs/plugin-react ``` ```js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [ laravel(['resources/js/app.jsx']), react(), ], }); ``` ```blade @viteReactRefresh @vite('resources/js/app.jsx') ``` -------------------------------- ### Install Broadcasting with Reverb Source: https://laravel.com/docs/13.x/broadcasting Enables broadcasting and installs Reverb's required packages and environment variables. ```shell php artisan install:broadcasting --reverb ``` -------------------------------- ### Initialize Laravel with AI Agent Source: https://laravel.com/docs/13.x/installation Use this prompt with AI coding agents to fetch official installation guidance. ```text I'm building a new Laravel application. Fetch and follow the instructions from https://laravel.com/for/agents. Treat the returned Markdown as the source of truth for how to install and set up Laravel in this session. ``` -------------------------------- ### Start Inertia SSR server Source: https://laravel.com/docs/13.x/vite Use the Artisan command to start the SSR server when using Inertia. ```shell php artisan inertia:start-ssr ``` -------------------------------- ### Create application with community starter kit Source: https://laravel.com/docs/13.x/starter-kits Use the --using flag with the Laravel installer to specify a community-maintained starter kit from Packagist. ```shell laravel new my-app --using=example/starter-kit ``` -------------------------------- ### Get All Defined Scopes Source: https://laravel.com/docs/13.x/passport Use the `scopes` method to retrieve an array of all defined scopes as `Laravel\Passport\Scope` instances. No setup is required. ```php Passport::scopes(); ``` -------------------------------- ### Start development server with SSR Source: https://laravel.com/docs/13.x/starter-kits Use this command to start the Laravel development server and Inertia SSR server for local testing. ```shell composer dev:ssr ``` -------------------------------- ### Complete Subscription After Redirect Source: https://laravel.com/docs/13.x/billing Retrieve the setup intent from the query string and create a new subscription using the payment method. ```php use Illuminate\Http\Request; Route::get('/subscription/complete', function (Request $request) { $setupIntent = $request->user()->findSetupIntent( $request->setup_intent ); $paymentMethod = $setupIntent->payment_method; $request->user() ->newSubscription('default', 'price_xxx') ->create($paymentMethod); return redirect('/dashboard'); })->name('subscription.complete'); ``` -------------------------------- ### Install Resend PHP SDK Source: https://laravel.com/docs/13.x/mail Install the required dependency for the Resend mail driver via Composer. ```shell composer require resend/resend-php ``` -------------------------------- ### Install and configure Vue for Vite Source: https://laravel.com/docs/13.x/vite Install the required Vue plugin and configure it in vite.config.js with necessary asset URL transformations. ```shell npm install --save-dev @vitejs/plugin-vue ``` ```js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import vue from '@vitejs/plugin-vue'; export default defineConfig({ plugins: [ laravel(['resources/js/app.js']), vue({ template: { transformAssetUrls: { // The Vue plugin will re-write asset URLs, when referenced // in Single File Components, to point to the Laravel web // server. Setting this to `null` allows the Laravel plugin // to instead re-write asset URLs to point to the Vite // server instead. base: null, // The Vue plugin will parse absolute URLs and treat them // as absolute paths to files on disk. Setting this to // `false` will leave absolute URLs un-touched so they can // reference assets in the public directory as expected. includeAbsolute: false, }, }, }), ], }); ``` -------------------------------- ### Get All Defined Scope IDs Source: https://laravel.com/docs/13.x/passport Use the `scopeIds` method to retrieve an array of all defined scope IDs or names. No setup is required. ```php use Laravel\Passport\Passport; Passport::scopeIds(); ``` -------------------------------- ### Suggest with Configuration Source: https://laravel.com/docs/13.x/prompts Includes optional placeholder, default value, and informational hint. ```php $name = suggest( label: 'What is your name?', options: ['Taylor', 'Dayle'], placeholder: 'E.g. Taylor', default: $user?->name, hint: 'This will be displayed on your profile.' ); ``` -------------------------------- ### Install Algolia PHP SDK Source: https://laravel.com/docs/13.x/scout Install the required Algolia PHP SDK via Composer before configuring credentials in config/scout.php. ```shell composer require algolia/algoliasearch-client-php ``` -------------------------------- ### Configure Laravel Echo with Vue Source: https://laravel.com/docs/13.x/broadcasting Configure Laravel Echo for a Vue application using the '@laravel/echo-vue' package. This example demonstrates the configuration setup. ```Vue import { configureEcho } from "@laravel/echo-vue"; configureEcho({ broadcaster: "reverb", // key: import.meta.env.VITE_REVERB_APP_KEY, // wsHost: import.meta.env.VITE_REVERB_HOST, // wsPort: import.meta.env.VITE_REVERB_PORT, // wssPort: import.meta.env.VITE_REVERB_PORT, // forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https', // enabledTransports: ['ws', 'wss'], }); ``` -------------------------------- ### Enter Tinker Environment Source: https://laravel.com/docs/13.x/artisan Starts the interactive Tinker REPL session. ```shell php artisan tinker ``` -------------------------------- ### Install Laravel Passport Source: https://laravel.com/docs/13.x/passport Run this Artisan command to install Passport, which publishes migrations and creates necessary encryption keys. ```shell php artisan install:api --passport ``` -------------------------------- ### Retrieve Attributes by Key Prefix Source: https://laravel.com/docs/13.x/blade Get all attributes whose keys start with a given string. Useful for filtering attributes like 'wire:model'. ```blade {{ $attributes->whereStartsWith('wire:model') }} ``` -------------------------------- ### Vue Directory Structure Source: https://laravel.com/docs/13.x/starter-kits Overview of the resources/js directory structure for Vue starter kits. ```text resources/js/ ├── components/ # Reusable Vue components ├── composables/ # Vue composables / hooks ├── layouts/ # Application layouts ├── lib/ # Utility functions and configuration ├── pages/ # Page components └── types/ # TypeScript definitions ``` -------------------------------- ### Get Items Per Page - Laravel Paginator Source: https://laravel.com/docs/13.x/pagination Returns the configured number of items that are displayed on each page. This value is typically set during the pagination setup. ```php $paginator->perPage() ``` -------------------------------- ### Install AWS SDK for DynamoDB Source: https://laravel.com/docs/13.x/cache Command to install the required AWS SDK package for the DynamoDB cache driver. ```shell composer require aws/aws-sdk-php ``` -------------------------------- ### Resource Response with Links and Meta Source: https://laravel.com/docs/13.x/eloquent-resources Example JSON output demonstrating how custom links and meta information are added to a resource object. ```json { "data": { "id": "1", "type": "posts", "attributes": { "title": "Hello World" }, "links": { "self": "https://example.com/api/posts/1" }, "meta": { "readable_created_at": "2 hours ago" } } } ``` -------------------------------- ### Event Discovery Listener Example Source: https://laravel.com/docs/13.x/events Laravel automatically registers listeners by scanning for methods starting with 'handle' or '__invoke' in listener classes. The event type is determined by the method's type-hinted parameter. ```php use App\Events\PodcastProcessed; class SendPodcastNotification { /** * Handle the event. */ public function handle(PodcastProcessed $event): void { // ... } } ``` -------------------------------- ### Build and start SSR server Source: https://laravel.com/docs/13.x/vite Commands to compile the assets and initiate the SSR server. ```shell npm run build node bootstrap/ssr/ssr.js ``` -------------------------------- ### Get Model Broadcast Channel Name Source: https://laravel.com/docs/13.x/broadcasting This method returns the conventional channel name string for a given Eloquent model instance. For example, an `App\Models\User` with ID `1` would result in `App.Models.User.1`. ```php $user->broadcastChannel(); ``` -------------------------------- ### Prepend Attribute Values in Blade Component Source: https://laravel.com/docs/13.x/blade Use the `prepends` method to ensure an attribute value always starts with a specific string, followed by any injected values. This example prepends to a `data-controller` attribute. ```blade
merge(['data-controller' => $attributes->prepends('profile-controller')]) }}> {{ $slot }}
``` -------------------------------- ### Livewire Directory Structure Source: https://laravel.com/docs/13.x/starter-kits Overview of the resources/views directory structure for Livewire starter kits. ```text resources/views ├── components # Reusable components ├── flux # Customized Flux components ├── layouts # Application layouts ├── pages # Livewire pages ├── partials # Reusable Blade partials ├── dashboard.blade.php # Authenticated user dashboard └── welcome.blade.php # Guest user welcome page ``` -------------------------------- ### Install Broadcasting Source: https://laravel.com/docs/13.x/broadcasting Enables broadcasting and prompts for the desired service. Creates configuration and channel files. ```shell php artisan install:broadcasting ``` -------------------------------- ### Install Laravel Fortify Source: https://laravel.com/docs/13.x/fortify Use Composer to install the Fortify package. This is the first step to integrating Fortify into your Laravel application. ```shell composer require laravel/fortify ``` -------------------------------- ### Create and Use a Browser Instance (Pest) Source: https://laravel.com/docs/13.x/dusk Use the `browse` method to create a browser instance for testing. This is useful for navigating, filling forms, and asserting page states. ```php use(DatabaseMigrations::class); test('basic example', function () { $user = User::factory()->create([ 'email' => 'taylor@laravel.com', ]); $this->browse(function (Browser $browser) use ($user) { $browser->visit('/login') ->type('email', $user->email) ->type('password', 'password') ->press('Login') ->assertPathIs('/home'); }); }); ``` -------------------------------- ### Use Middleware Alias in Route Definition Source: https://laravel.com/docs/13.x/middleware Applies a previously defined middleware alias to a specific route. This allows for cleaner route definitions by using the short alias instead of the full middleware class name. The example shows applying the 'subscribed' alias to a GET route. ```php Route::get('/profile', function () { // ... })->middleware('subscribed'); ``` -------------------------------- ### Start Tailing Logs with Pail Source: https://laravel.com/docs/13.x/logging Basic command to start tailing logs in real-time using Laravel Pail. Press Ctrl+C to stop. ```shell php artisan pail ``` -------------------------------- ### Inbound-Only Cast Implementation (PHP) Source: https://laravel.com/docs/13.x/eloquent-mutators An example of an inbound-only cast class implementing the `CastsInboundAttributes` interface. This class defines a `set` method to prepare attribute values for storage, optionally using a specified hashing algorithm. It does not define a `get` method, meaning it won't modify retrieved values. ```php $attributes */ public function set( Model $model, string $key, mixed $value, array $attributes, ): string { return is_null($this->algorithm) ? bcrypt($value) : hash($this->algorithm, $value); } } ``` -------------------------------- ### Create URI Instances Source: https://laravel.com/docs/13.x/helpers Demonstrates various ways to create Uri instances, including from strings, named routes, controller actions, and the current request. ```php use App\Http\Controllers\UserController; use App\Http\Controllers\InvokableController; use Illuminate\Support\Uri; // Generate a URI instance from the given string... $uri = Uri::of('https://example.com/path'); // Generate URI instances to paths, named routes, or controller actions... $uri = Uri::to('/dashboard'); $uri = Uri::route('users.show', ['user' => 1]); $uri = Uri::signedRoute('users.show', ['user' => 1]); $uri = Uri::temporarySignedRoute('user.index', now()->plus(minutes: 5)); $uri = Uri::action([UserController::class, 'index']); $uri = Uri::action(InvokableController::class); // Generate a URI instance from the current request URL... $uri = $request->uri(); ``` -------------------------------- ### Publish Fortify Resources Source: https://laravel.com/docs/13.x/fortify After installation, use the Artisan command to publish Fortify's actions, service provider, configuration, and migrations. This sets up the necessary files for Fortify to function. ```shell php artisan fortify:install ``` -------------------------------- ### Install Laravel Sanctum Source: https://laravel.com/docs/13.x/sanctum Install Sanctum using the `install:api` Artisan command. This command publishes Sanctum's migration files and configuration. ```shell php artisan install:api ``` -------------------------------- ### Install Reverb Manually Source: https://laravel.com/docs/13.x/broadcasting Installs the Reverb Composer package. ```shell composer require laravel/reverb ``` -------------------------------- ### Create a new Laravel application on Windows Source: https://laravel.com/docs/13.x/installation Initialize a new Laravel project via PowerShell within the default Herd parked directory. ```shell cd ~\Herd laravel new my-app cd my-app herd open ``` -------------------------------- ### Manage ChromeDriver Installation Source: https://laravel.com/docs/13.x/dusk Use the dusk:chrome-driver command to manage ChromeDriver installations. You can install the latest version, a specific version, or versions for all supported operating systems. ```shell php artisan dusk:chrome-driver # Install a given version of ChromeDriver for your OS... php artisan dusk:chrome-driver 86 # Install a given version of ChromeDriver for all supported OSs... php artisan dusk:chrome-driver --all ``` -------------------------------- ### Install Tinker Source: https://laravel.com/docs/13.x/artisan Installs the Laravel Tinker package via Composer. ```shell composer require laravel/tinker ``` -------------------------------- ### Upgrade Valet Installation Source: https://laravel.com/docs/13.x/valet Updates the Valet installation to the latest version. After upgrading, it's recommended to run the install command to apply any necessary configuration changes. ```shell composer global require laravel/valet valet install ``` -------------------------------- ### Run Vite development and build commands Source: https://laravel.com/docs/13.x/vite Use these commands to start the local development server or bundle assets for production deployment. ```shell # Run the Vite development server... npm run dev # Build and version the assets for production... npm run build ``` -------------------------------- ### GET Request with Query Parameters Source: https://laravel.com/docs/13.x/http-client Append query parameters to a GET request by passing an array of key/value pairs as the second argument to the `get` method. Alternatively, use the `withQueryParameters` method. ```php $response = Http::get('http://example.com/users', [ 'name' => 'Taylor', 'page' => 1, ]); ``` ```php Http::retry(3, 100)->withQueryParameters([ 'name' => 'Taylor', 'page' => 1, ])->get('http://example.com/users'); ``` -------------------------------- ### Install Laravel Boost Source: https://laravel.com/docs/13.x/ai Install the package as a development dependency in your Laravel project. ```shell composer require laravel/boost --dev ``` -------------------------------- ### Create and Use a Browser Instance (PHPUnit) Source: https://laravel.com/docs/13.x/dusk This example demonstrates creating a browser instance within a PHPUnit test case for interacting with the application during tests. ```php create([ 'email' => 'taylor@laravel.com', ]); $this->browse(function (Browser $browser) use ($user) { $browser->visit('/login') ->type('email', $user->email) ->type('password', 'password') ->press('Login') ->assertPathIs('/home'); }); } } ``` -------------------------------- ### Replace at start Source: https://laravel.com/docs/13.x/strings Replaces the first occurrence of a value only if it appears at the start of the string. ```php use Illuminate\Support\Str; $replaced = Str::replaceStart('Hello', 'Laravel', 'Hello World'); // Laravel World $replaced = Str::replaceStart('World', 'Laravel', 'Hello World'); // Hello World ``` -------------------------------- ### Make a Basic GET Request Source: https://laravel.com/docs/13.x/http-client Use the `get` method on the `Http` facade to make a simple GET request to a specified URL. The response object provides methods to inspect the response details. ```php use Illuminate\Support\Facades\Http; $response = Http::get('http://example.com'); ``` -------------------------------- ### Create a personal access client Source: https://laravel.com/docs/13.x/passport Execute this command to enable the issuance of personal access tokens within your application. ```shell php artisan passport:client --personal ``` -------------------------------- ### Install Mailgun Driver Source: https://laravel.com/docs/13.x/mail Install the necessary Symfony Mailgun and HTTP client packages. ```shell composer require symfony/mailgun-mailer symfony/http-client ``` -------------------------------- ### Install Precognition Alpine Helpers Source: https://laravel.com/docs/13.x/precognition Install the necessary NPM package for Alpine integration. ```shell npm install laravel-precognition-alpine ``` -------------------------------- ### Reset Valet Installation Source: https://laravel.com/docs/13.x/valet Resets the Valet installation to resolve issues. This involves reinstalling Valet globally and then running the install command. A 'hard reset' option is available for more severe problems. ```shell composer global require laravel/valet valet install ``` ```shell valet uninstall --force valet install ``` -------------------------------- ### Install Svelte Vite Plugin Source: https://laravel.com/docs/13.x/vite Install the required Svelte plugin for Vite via npm. ```shell npm install --save-dev @sveltejs/vite-plugin-svelte ``` -------------------------------- ### Apply audio instructions Source: https://laravel.com/docs/13.x/ai-sdk Provide dynamic instructions to influence the tone or style of the generated audio. ```php $audio = Audio::of('I love coding with Laravel.') ->female() ->instructions('Said like a pirate') ->generate(); ``` -------------------------------- ### Install Additional Symfony Transports Source: https://laravel.com/docs/13.x/mail Use Composer to install the required Symfony mailer packages. ```shell composer require symfony/brevo-mailer symfony/http-client ``` -------------------------------- ### Initiate Passkey Registration and Verification with JavaScript Source: https://laravel.com/docs/13.x/fortify Use the imported `Passkeys` class to initiate passkey registration and verification from your frontend JavaScript. ```javascript import { Passkeys } from "@laravel/passkeys"; await Passkeys.register({ name: "MacBook Pro" }); await Passkeys.verify(); ``` -------------------------------- ### Install Cloudflare Driver Source: https://laravel.com/docs/13.x/mail Install the required Symfony HTTP client dependency via Composer. ```shell composer require symfony/http-client ``` -------------------------------- ### Run Database Migrations Source: https://laravel.com/docs/13.x/installation Execute the migration command to create database tables after switching to a non-SQLite driver. ```shell php artisan migrate ``` -------------------------------- ### Execute closure when string starts with substring Source: https://laravel.com/docs/13.x/strings Invokes the closure if the string starts with the specified substring. ```php use Illuminate\Support\Str; use Illuminate\Support\Stringable; $string = Str::of('disney world')->whenStartsWith('disney', function (Stringable $string) { return $string->title(); }); // 'Disney World' ``` -------------------------------- ### Execute closure when string does not start with substring Source: https://laravel.com/docs/13.x/strings Invokes the closure if the string does not start with the specified substring. ```php use Illuminate\Support\Str; use Illuminate\Support\Stringable; $string = Str::of('disney world')->whenDoesntStartWith('sea', function (Stringable $string) { return $string->title(); }); // 'Disney World' ``` -------------------------------- ### Start the Vite development server Source: https://laravel.com/docs/13.x/vite Run the development server for both Laravel and Vite. ```shell composer run dev ``` -------------------------------- ### Start string with value Source: https://laravel.com/docs/13.x/strings Adds a single instance of a value to the start of a string if it is not already present. ```php use Illuminate\Support\Str; $adjusted = Str::start('this/string', '/'); // /this/string $adjusted = Str::start('/this/string', '/'); // /this/string ``` -------------------------------- ### Str::start() Source: https://laravel.com/docs/13.x/strings Adds a single instance of the given value to a string if it does not already start with that value. ```APIDOC ## Str::start() ### Description The `Str::start` method adds a single instance of the given value to a string if it does not already start with that value. ### Signature `Str::start(string $value, string $prefix)` ``` -------------------------------- ### Install Laravel Valet Source: https://laravel.com/docs/13.x/valet Installs Laravel Valet globally using Composer after ensuring Homebrew and PHP are up-to-date. The 'valet install' command configures Nginx, DnsMasq, and system startup services. ```shell brew update brew install php composer global require laravel/valet valet install ``` -------------------------------- ### Install Dompdf Library Source: https://laravel.com/docs/13.x/billing Install the required Dompdf library via Composer before generating invoice PDFs. ```shell composer require dompdf/dompdf ``` -------------------------------- ### Create Subscription After Generic Trial Source: https://laravel.com/docs/13.x/billing Initialize a standard subscription for a user who was previously on a generic trial. ```php $user = User::find(1); $user->newSubscription('default', 'price_monthly')->create($paymentMethod); ``` -------------------------------- ### Configure Storage Cache Driver Source: https://laravel.com/docs/13.x/cache Example configuration for using a filesystem disk as a cache store. ```php 'storage' => [ 'driver' => 'storage', 'disk' => env('CACHE_STORAGE_DISK'), 'path' => env('CACHE_STORAGE_PATH', 'framework/cache/data'), ], ``` -------------------------------- ### Define Project Structure Source: https://laravel.com/docs/13.x/vite Example directory structure for asset management. ```text public/ taylor.png resources/ js/ Pages/ Welcome.vue images/ abigail.png ``` -------------------------------- ### Basic Task Implementation Source: https://laravel.com/docs/13.x/prompts Displays a labeled task with a spinner while executing a callback. ```php use function Laravel espons ask; task( label: 'Installing dependencies', callback: function ($logger) { // Long-running process... } ); ``` -------------------------------- ### View Command Help Source: https://laravel.com/docs/13.x/artisan Displays the help screen for a specific command, showing arguments and options. ```shell php artisan help migrate ``` -------------------------------- ### Install Laravel Sail via Composer Source: https://laravel.com/docs/13.x/sail Install the Sail package as a development dependency in your Laravel project. ```shell composer require laravel/sail --dev ``` -------------------------------- ### Select Prompt with Default and Hint Source: https://laravel.com/docs/13.x/prompts Sets a default selection and provides an informational hint to the user. ```php $role = select( label: 'What role should the user have?', options: ['Member', 'Contributor', 'Owner'], default: 'Owner', hint: 'The role may be changed at any time.' ); ``` -------------------------------- ### Update Laravel Installer via Composer Source: https://laravel.com/docs/13.x/upgrade Command to update the global Laravel installer CLI tool. ```shell composer global update laravel/installer ``` -------------------------------- ### Install Predis via Composer Source: https://laravel.com/docs/13.x/redis Use this command to install the Predis package if the PhpRedis extension is not available. ```shell composer require predis/predis ``` -------------------------------- ### Registering command directories Source: https://laravel.com/docs/13.x/artisan Use the withCommands method in bootstrap/app.php to scan additional directories for Artisan commands. ```php ->withCommands([ __DIR__.'/../app/Domain/Orders/Commands', ]) ``` -------------------------------- ### Install Laravel MongoDB Package Source: https://laravel.com/docs/13.x/mongodb Use Composer to install the official MongoDB integration package for Laravel. ```shell composer require mongodb/laravel-mongodb ``` -------------------------------- ### Select Prompt with Static Info Source: https://laravel.com/docs/13.x/prompts Displays a static informational string alongside the options. ```php $role = select( label: 'What role should the user have?', options: ['Member', 'Contributor', 'Owner'], info: 'The role may be changed at any time.' ); ``` -------------------------------- ### Dispatching Jobs to Queues Source: https://laravel.com/docs/13.x/queues Demonstrates how to dispatch a job to the default queue or a specific named queue. ```php use App\/Jobs\/ProcessPodcast; \/\/ This job is sent to the default connection's default queue... ProcessPodcast::dispatch(); \/\/ This job is sent to the default connection's "emails" queue... ProcessPodcast::dispatch()->onQueue('emails'); ``` -------------------------------- ### Create a Process Pipeline with Array of Commands Source: https://laravel.com/docs/13.x/processes A simpler way to create a process pipeline by passing an array of command strings directly to the `pipe` method. ```php $result = Process::pipe([ 'cat example.txt', 'grep -i "laravel", ]); ``` -------------------------------- ### Basic Suggest Usage Source: https://laravel.com/docs/13.x/prompts Provides auto-completion for a list of static options. ```php use function Laravel\Prompts\suggest; $name = suggest('What is your name?', ['Taylor', 'Dayle']); ``` -------------------------------- ### Install fontaine dependency Source: https://laravel.com/docs/13.x/vite Install the fontaine package as a development dependency to enable metric-adjusted fallback font generation. ```shell npm install --save-dev fontaine ``` -------------------------------- ### Install ext-uv for Enhanced Event Loop Source: https://laravel.com/docs/13.x/reverb This command installs the `ext-uv` PHP extension, which provides an alternative event loop for ReactPHP. This is recommended for handling more than 1,000 concurrent connections, as the default `stream_select` loop has limitations. ```shell pecl install uv ``` -------------------------------- ### Create Subscription with Upfront Trial Days Source: https://laravel.com/docs/13.x/billing Use the trialDays method to specify the number of trial days when creating a subscription with a payment method. ```php use Illuminate\Http\Request; Route::post('/user/subscribe', function (Request $request) { $request->user()->newSubscription('default', 'price_monthly') ->trialDays(10) ->create($request->paymentMethodId); // ... }); ``` -------------------------------- ### Install MongoDB PHP Extension Source: https://laravel.com/docs/13.x/mongodb Use PECL to install the required MongoDB PHP extension if not already present. ```shell pecl install mongodb ``` -------------------------------- ### Handle Real-time Process Output Source: https://laravel.com/docs/13.x/processes Gather output in real-time by passing a closure to the start method. ```php $process = Process::start('bash import.sh', function (string $type, string $output) { echo $output; }); $result = $process->wait(); ```