### 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