### Creating and Configuring Serverless Postgres Database Source: https://context7.com/context7/cloud_laravel/llms.txt Guides through the process of setting up an autoscaling Serverless Postgres database with pgvector support. Includes example environment variables and basic Laravel database interaction. ```bash # Step 1: Navigate to environment canvas and click "Add database" # Step 2: Select "Create new cluster" and configure: # - Database Type: Laravel Serverless Postgres # - Cluster Name: production-postgres # - Compute Units: Min 0.25, Max 2 (autoscales based on load) # - Hibernation: Enable after 300 seconds of inactivity # - Region: must match your compute region # Automatically injected environment variables: DB_CONNECTION=pgsql DB_HOST=ep-frosty-shadow-a57j6ubb.us-east-2.pg.laravel.cloud DB_PORT=5432 DB_DATABASE=main DB_USERNAME=auto-generated DB_PASSWORD=auto-generated ``` ```php use IlluminateSupportFacadesDB; $users = DB::table('users')->get(); # Enable connection pooling for high-concurrency apps # Append "-pooler" to hostname segment DB_HOST=ep-frosty-shadow-a57j6ubb-pooler.us-east-2.pg.laravel.cloud ``` -------------------------------- ### Install and Use Bun in Laravel Cloud Source: https://cloud.laravel.com/docs/knowledge-base/using-yarn-bun-pnpm This snippet demonstrates how to install Bun globally and use it for dependency installation and building your project within Laravel Cloud. It replaces the default npm commands. ```bash npm install -g bun bun install bun run build ``` -------------------------------- ### Provisioning and Configuring Redis-Compatible KV Store Source: https://context7.com/context7/cloud_laravel/llms.txt Details the steps to create a Redis-compatible key-value store for caching and queues. Includes configuration examples for environment variables and Laravel's cache and queue drivers. ```bash # Step 1: Navigate to environment canvas and click "Add cache" # Step 2: Select "Create new cache" and configure: # - Cache Type: Laravel KV Store # - Name: production-cache # - Size: Standard 1GB (or Flex 100MB, 500MB, Standard 500MB, 2GB, 5GB, 10GB) # - Auto-upgrade: Enable (automatically scales when limits reached) # Automatically injected environment variables: CACHE_STORE=redis REDIS_HOST=usw1-refined-shark-12345.upstash.io REDIS_PASSWORD=auto-generated REDIS_PORT=6379 # Session and queue configuration (also uses Redis) SESSION_DRIVER=redis QUEUE_CONNECTION=redis ``` -------------------------------- ### Install Laravel Nightwatch Package Source: https://context7.com/context7/cloud_laravel/llms.txt Instructions to install the Laravel Nightwatch package using Composer. This package is required for advanced monitoring and exception tracking features provided by Nightwatch. ```bash # Step 1: Install Nightwatch package locally composer require laravel/nightwatch ``` -------------------------------- ### Install and Use Yarn in Laravel Cloud Source: https://cloud.laravel.com/docs/knowledge-base/using-yarn-bun-pnpm This snippet shows how to install Yarn globally and use it for dependency installation and building your project in Laravel Cloud, replacing the default npm commands. ```bash npm install -g yarn yarn install yarn run build ``` -------------------------------- ### Direct Redis Interaction in Laravel Source: https://context7.com/context7/cloud_laravel/llms.txt Provides examples of interacting directly with Redis from Laravel using the `Redis` facade, including setting key-value pairs, list operations, and publish/subscribe functionality. ```php use IlluminateSupportFacadesRedis; // Set key-value pairs Redis::set('api_counter', 0); Redis::incr('api_counter'); // Lists for real-time features Redis::lpush('notifications:user:' . $userId, json_encode($notification)); $notifications = Redis::lrange('notifications:user:' . $userId, 0, 9); // Pub/sub for real-time events Redis::publish('chat:room:' . $roomId, json_encode($message)); ``` -------------------------------- ### Dispatch Jobs with Laravel Queues Source: https://context7.com/context7/cloud_laravel/llms.txt Demonstrates how to dispatch jobs to Laravel's queue system. Includes examples for dispatching to the default queue, a specific queue, and scheduling jobs with a delay. Leverages the `dispatch` method on job classes. ```php use App\Jobs\SendEmailNotification; // Dispatch to default queue SendEmailNotification::dispatch($user, $message); // Dispatch to specific queue SendEmailNotification::dispatch($user, $message) ->onQueue('emails'); // Delayed dispatch SendEmailNotification::dispatch($user, $message) ->delay(now()->addMinutes(10)); ``` -------------------------------- ### Install and Use PNPM in Laravel Cloud Source: https://cloud.laravel.com/docs/knowledge-base/using-yarn-bun-pnpm This snippet illustrates how to install PNPM globally and use it for dependency installation and building your project within Laravel Cloud. It's a substitute for the default npm commands. ```bash npm install -g pnpm pnpm install pnpm run build ``` -------------------------------- ### Configure Laravel Octane with FrankenPHP Source: https://context7.com/context7/cloud_laravel/llms.txt Enables Laravel Octane runtime using FrankenPHP for improved performance. Requires composer package installation and a configuration file. Redeploy environment after enabling. ```bash # Toggle "Use Octane as runtime" # Requirements: composer require laravel/octane # config/octane.php must exist in your project # Redeploy environment after enabling ``` -------------------------------- ### Configure Object Storage Bucket (Laravel) Source: https://context7.com/context7/cloud_laravel/llms.txt Guides through setting up an object storage bucket for persistent file uploads within your Laravel environment. This involves creating a new bucket with a specified name on the platform. ```bash # Step 1: Navigate to environment canvas and click "Add object storage" # Step 2: Create new bucket: # - Bucket Name: production-assets ``` -------------------------------- ### Configure Private Composer Packages Source: https://cloud.laravel.com/docs/environments This snippet shows how to configure Composer to authenticate with private package repositories using HTTP basic authentication. It's crucial to add these configuration commands before running `composer install` to ensure private dependencies are fetched correctly. This setup is part of the build commands executed during deployment. ```shell composer config http-basic.composer.fluxui.dev your-username your-license-key composer install --no-dev ``` -------------------------------- ### Create and Deploy Laravel Application Source: https://context7.com/context7/cloud_laravel/llms.txt Steps to create a new Laravel application from a Git repository on Laravel Cloud. Includes configuration of build and deploy commands, and region selection. ```bash # Step 1: Connect your Git provider (GitHub, GitLab, or Bitbucket) # Navigate to Laravel Cloud dashboard and click "+ New application" # Step 2: Select your repository and configure # - Repository: your-org/your-laravel-app # - Application name: my-production-app # - Region: us-east-1 (or us-east-2, eu-central-1, eu-west-2, ap-southeast-1, ap-southeast-2) # Step 3: Configure build commands (default) composer install --no-dev npm ci npm run build # Step 4: Configure deploy commands (default) php artisan migrate --force # Step 5: Click "Create Application" # Your default environment will be created automatically ``` -------------------------------- ### Configuring Compute Scaling and Autoscaling Source: https://context7.com/context7/cloud_laravel/llms.txt Explains how to configure compute resources for a Laravel application, including selecting compute classes, sizes, and setting up autoscaling options (None, Custom, Unlimited). ```bash # Navigate to environment canvas and click on App compute cluster # Basic configuration: # - Compute Class: Flex or Pro # - Size: Flex 512MB, 1GB, 2GB / Pro 4GB, 8GB, 16GB, 32GB # - Autoscaling: None, Custom, or Unlimited # Example 1: Fixed single instance (no autoscaling) # Autoscaling: None ``` -------------------------------- ### Create and Attach MySQL Database to Laravel Environment Source: https://context7.com/context7/cloud_laravel/llms.txt Instructions for provisioning a managed MySQL database on Laravel Cloud and attaching it to an application environment. Includes configuration steps and automatically injected environment variables. ```bash # Step 1: Navigate to environment canvas and click "Add database" # Step 2: Select "Create new cluster" and configure: # - Database Type: Laravel MySQL # - Cluster Name: production-mysql # - Instance Size: Pro 2GB (or Flex 512MB, 1GB, 2GB) # - Storage: 20GB (5GB - 1,000GB available) # - Region: must match your compute region # Step 3: Create logical database within cluster # - Database Name: production_db # Automatically injected environment variables: DB_CONNECTION=mysql DB_HOST=cluster-abc123.us-east-1.mysql.laravel.cloud DB_PORT=3306 DB_DATABASE=production_db DB_USERNAME=auto-generated DB_PASSWORD=auto-generated ``` -------------------------------- ### Install Laravel Nightwatch Package using Composer Source: https://cloud.laravel.com/docs/knowledge-base/nightwatch-on-cloud Installs the Nightwatch package for Laravel using Composer. This command should be run locally before deploying to update your project's dependencies. ```bash composer require laravel/nightwatch ``` -------------------------------- ### Install Laravel Flysystem AWS S3 v3 Package Source: https://cloud.laravel.com/docs/resources/object-storage This command installs the necessary package for integrating AWS S3 compatible storage with Laravel applications. It ensures all dependencies are included for seamless operation with the Flysystem adapter. ```shell composer require league/flysystem-aws-s3-v3 "^3.0" --with-all-dependencies ``` -------------------------------- ### Connecting to MySQL Database from Local Machine Source: https://context7.com/context7/cloud_laravel/llms.txt Provides the command-line syntax for connecting to a remote MySQL database instance using the `mysql` client. This is typically used for direct database management or troubleshooting. ```bash mysql -h cluster-abc123.us-east-1.mysql.laravel.cloud \ -u username \ -p \ production_db ``` -------------------------------- ### Trigger Laravel Deployments with Hooks or GitHub Actions Source: https://context7.com/context7/cloud_laravel/llms.txt Methods for triggering deployments on Laravel Cloud, including automatic push-to-deploy, using deploy hooks via API, and integrating with GitHub Actions. ```bash # Option 1: Push to Deploy (enabled by default) git add . git commit -m "Add new feature" git push origin main # Deployment triggers automatically # Option 2: Deploy Hook via API # Navigate to Settings > Deployments and enable "Deploy hook" # Copy the provided webhook URL # Trigger deployment via curl curl -X POST "https://cloud.laravel.com/api/deploy/hooks/abc123xyz" # Deploy specific commit curl -X POST "https://cloud.laravel.com/api/deploy/hooks/abc123xyz?commit_hash=abc123def456" # Option 3: GitHub Actions Integration # .github/workflows/deploy.yml name: Deploy to Laravel Cloud on: push: branches: [ main ] jobs: deploy: runs-on: ubuntu-latest steps: - name: Deploy to Laravel Cloud run: | curl -X POST "${{ secrets.LARAVEL_CLOUD_DEPLOY_HOOK }}?commit_hash=${{ github.sha }}" # Add LARAVEL_CLOUD_DEPLOY_HOOK secret to GitHub repository # Secrets and variables → Actions → New repository secret ``` -------------------------------- ### Configure Laravel Environment Variables Source: https://context7.com/context7/cloud_laravel/llms.txt How to set up environment variables, including application settings, mail configuration, and third-party API keys. Also covers configuring PHP and Node.js versions. ```bash # Navigate to Environment > Settings > Environment Variables # Add custom environment variables APP_NAME="My Laravel App" APP_ENV=production APP_DEBUG=false APP_URL=https://my-app.laravel.cloud # Mail configuration MAIL_MAILER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=your-username MAIL_PASSWORD=your-password # Third-party API keys STRIPE_KEY=pk_live_xxxxx STRIPE_SECRET=sk_live_xxxxx # Note: Database, cache, and queue credentials are automatically injected # when you attach resources to your environment # Configure PHP version (Settings > General) # Available: PHP 8.2, 8.3, 8.4 # Configure Node version (Settings > General) # Available: Node 18, 20, 22 # Private Composer packages (add to build commands) composer config http-basic.composer.fluxui.dev your-username your-license-key composer install --no-dev # After adding/changing variables, redeploy the environment ``` -------------------------------- ### Laravel Cache Usage with Redis Source: https://context7.com/context7/cloud_laravel/llms.txt Shows practical examples of using Laravel's `Cache` facade with a Redis backend, including storing, retrieving, using the `remember` pattern, and implementing cache tags for invalidation. ```php use IlluminateSupportFacadesCache; // Store items in cache Cache::put('user.profile.' . $userId, $profile, now()->addHours(12)); // Retrieve from cache $profile = Cache::get('user.profile.' . $userId); // Remember pattern (retrieve or store) $stats = Cache::remember('daily-stats', 3600, function () { return DB::table('analytics')->where('date', today())->get(); }); // Cache tags for grouped invalidation Cache::tags(['users', 'profile'])->put('user.1', $user, 600); Cache::tags(['users'])->flush(); // Flush all user-related caches ```