PHP code example of deskhq / laravel-worktree

1. Go to this page and download the library: Download deskhq/laravel-worktree library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

deskhq / laravel-worktree example snippets


'env' => [
    'APP_PORT'             => '{{port.app}}',
    'VITE_PORT'            => '{{port.vite}}',
    'FORWARD_DB_PORT'      => '{{port.db}}',
    'FORWARD_REDIS_PORT'   => '{{port.redis}}',
    'COMPOSE_PROJECT_NAME' => '{{project}}',
    'APP_URL'              => 'http://localhost:{{port.app}}',

    'REVERB_PORT' => 8080,          // container-internal, deliberately not offset

    'COMPOSE_PROFILES' => '',       // and the services this worktree never starts
    'MAIL_MAILER'      => 'log',
    'SCOUT_DRIVER'     => 'collection',
    'MEILISEARCH_HOST' => '',
],

'compose' => [
    'keep_services'  => ['pgsql', 'redis'],
    'port_overrides' => ['reverb' => ['{{port.reverb}}:8080']],
],

interface Runtime
{
    public function boot(Identity $worktree, string $environmentFile, ?string $halted = null, ?string $remedy = null): void;
    public function stop(string $project, ?string $directory = null): bool;
    public function teardown(string $project, ?string $directory = null): TeardownResult;
    public function allocatesPorts(): bool;
    public function shell(): Shell;
}

'steps' => [
    ['label' => 'Installing PHP dependencies',
     'sail'  => 'composer install',
     'sentinel' => '.worktree-installed'],

    ['label' => 'Generating the application key',
     'sail'  => 'artisan key:generate --force',
     'when'  => 'env_empty:APP_KEY'],

    ['label' => 'Installing node modules',
     'host'  => 'npm ci',
     'when'  => 'missing:node_modules'],
],

['sail' => 'artisan migrate:fresh --seed --force', 'sentinel' => '.worktree-seeded'],
['sail' => 'artisan migrate --force', 'when' => 'exists:.worktree-seeded'],

['host' => 'bin/worktree-playwright {{path}}',
 'allow_failure' => true,
 'degrade' => 'Playwright is not fully installed; tests/Browser will not run here'],

'base_branch' => env('WORKTREE_BASE', 'develop'),
bash
php artisan vendor:publish --tag="worktree-config"
bash
php artisan vendor:publish --tag="worktree-stubs"
chmod +x bin/worktree-playwright
bash
worktree path 441 || echo "not created yet"