VOOZH about

URL: https://deepwiki.com/hypervel/testbench/5.2-file-synchronization-with-testbench-sync

⇱ File Synchronization with testbench-sync | hypervel/testbench | DeepWiki


Loading...
Last indexed: 7 February 2026 (93289f)
Menu

File Synchronization

The file synchronization system copies the workbench application template from the vendor package directory to the local project workspace. This process is executed by the testbench-sync CLI script and establishes a complete application structure for testing package development.

For runtime environment initialization details, see page 2.3. For workbench application structure details, see page 5.

Overview

The testbench-sync script is a PHP executable located at bin/testbench-sync1-40 that performs one-time file synchronization from vendor/hypervel/testbench/workbench/ to a local workbench directory (default: testbench/). The script uses Hypervel\Filesystem\Filesystem for file operations and Hypervel\Support\Collection for batch file processing.

Sources: bin/testbench-sync1-40

Synchronized Components

The synchronization operation copies the following directory structures and files:

Source PathTarget PathContent TypePurpose
vendor/hypervel/testbench/testbench.yamltestbench.yamlYAML configurationMain testbench configuration file
vendor/hypervel/testbench/workbench/app/{workbench}/app/PHP classesService providers, controllers, models, commands
vendor/hypervel/testbench/workbench/config/{workbench}/config/PHP configuration filesApplication, database, session, auth configs
vendor/hypervel/testbench/workbench/database/{workbench}/database/Migration and factory filesDatabase schema and test data generators
vendor/hypervel/testbench/workbench/lang/{workbench}/lang/Translation filesLocalization strings
vendor/hypervel/testbench/workbench/routes/{workbench}/routes/Route definition filesWeb, API, and console route registrations
vendor/hypervel/testbench/workbench/resources/{workbench}/resources/View templatesBlade templates and static resources

Sources: bin/testbench-sync9-37 testbench.yaml1-20

Synchronization Execution Flow

The following diagram shows the execution flow of the testbench-sync script with actual code entities:


Sources: bin/testbench-sync1-40

Collection-Based File Processing

The synchronization uses Hypervel\Support\Collection pipeline operations to process file batches. This diagram illustrates the collection transformation flow:


Sources: bin/testbench-sync15-37

Path Resolution Mechanism

The script uses Hypervel\Support\Str helper methods for path manipulation and transformation:


Sources: bin/testbench-sync20-22 bin/testbench-sync34-36

Implementation Details

Core Dependencies

The script requires the following Hypervel framework components:

ClassMethods UsedPurpose
Hypervel\Filesystem\Filesystemcopy(), allFiles(), ensureDirectoryExists()File and directory operations
Hypervel\Support\Collectionmake(), flatten(), filter(), each()Collection pipeline for batch file processing
Hypervel\Support\Strafter(), before()String path manipulation

Sources: bin/testbench-sync8 bin/testbench-sync15-25 bin/testbench-sync20-35

Two-Phase Synchronization

The synchronization executes in two sequential phases using identical collection pipeline patterns:

Phase 1: Application Code (Lines 15-23)

Processes all PHP classes and application-level code from workbench/app/:

Collection::make([...$files->allFiles("{$workingPath}/vendor/hypervel/testbench/workbench/app/")])
 ->flatten()
 ->filter(static fn ($file) => is_file($file))
 ->each(static function ($file) use ($files, $workingPath, $workbenchPath) {
 // Path resolution and copy operation
 });

Sources: bin/testbench-sync15-23

Phase 2: Configuration and Resources (Lines 25-37)

Processes multiple directory trees in a single collection pipeline:

Collection::make([
 ...$files->allFiles("{$workingPath}/vendor/hypervel/testbench/workbench/config/"),
 ...$files->allFiles("{$workingPath}/vendor/hypervel/testbench/workbench/database/"),
 ...$files->allFiles("{$workingPath}/vendor/hypervel/testbench/workbench/lang/"),
 ...$files->allFiles("{$workingPath}/vendor/hypervel/testbench/workbench/routes/"),
 ...$files->allFiles("{$workingPath}/vendor/hypervel/testbench/workbench/resources/"),
])

Sources: bin/testbench-sync25-37

testbench.yaml Synchronization

The script first copies testbench.yaml to the working directory root before processing workbench directories:


This configuration file defines provider registration, environment variables, workbench discovery settings, and purge rules for the test environment.

Sources: bin/testbench-sync9 testbench.yaml1-20

Usage Patterns

Basic Synchronization

The most common usage pattern involves running the synchronization script without arguments, which creates a testbench directory in the current working directory:


Custom Directory Name

Developers can specify an alternative directory name by providing it as the first argument bin/testbench-sync11:


Integration with Composer

The synchronization process is typically integrated into composer workflows, allowing developers to automate the setup process during package development and testing phases.

Sources: bin/testbench-sync11-39