VOOZH about

URL: https://deepwiki.com/hypervel/filesystem/5.2-configuration-reference

⇱ Configuration Reference | hypervel/filesystem | DeepWiki


Loading...
Menu

Configuration Reference

This page provides a comprehensive reference of all configuration options available in the Hypervel Filesystem package. Each driver type (local, S3, GCS, FTP, SFTP) has its own set of configuration parameters that control its behavior, credentials, and performance characteristics.

For information about creating custom drivers, see Creating Custom Drivers. For general installation and setup guidance, see Installation and Configuration.


Configuration File Structure

The filesystem configuration is stored in config/autoload/filesystems.php and consists of two main sections: a default disk identifier and a collection of disk configurations.


Sources: publish/filesystems.php1-88


Global Configuration Options

Default Disk

OptionTypeDefaultDescription
defaultstring'local'The name of the disk to use when no disk is explicitly specified via disk() method

The default disk is resolved using the FILESYSTEM_DISK environment variable.

Sources: publish/filesystems.php17


Common Disk Options

These options are available across all driver types, though some may have driver-specific behavior.

Core Options

OptionTypeDefaultDescription
driverstringrequiredThe driver type: 'local', 's3', 'gcs', 'ftp', 'sftp'
throwboolfalseWhether to throw exceptions on errors or return false
visibilitystringnullDefault visibility for files: 'public' or 'private'

Sources: publish/filesystems.php32-86


Local Driver Configuration

The local driver stores files on the server's filesystem using the League Flysystem local adapter.


Local Driver Options

OptionTypeDefaultDescription
rootstringrequiredAbsolute path to the root directory for file storage
urlstringnullBase URL for generating public URLs to files
visibilitystringnullDefault visibility: 'public' or 'private'
throwboolfalseWhether to throw exceptions on errors
serve_signed_urlsboolfalseWhether to serve files through signed URL verification (requires routing setup)
linksarray[]Array of symbolic links to create: ['public/storage' => 'storage/app/public']
lockintLOCK_EXFile lock constant for LockableFile operations
permissionsarraySee belowDirectory and file permission settings

Permissions Configuration

The permissions array controls Unix file permissions:


Example Configurations

Private Disk:


Public Disk with URLs:


Sources: publish/filesystems.php33-45 composer.json43


AWS S3 Driver Configuration

The s3 driver integrates with Amazon S3 and S3-compatible storage services using the AWS SDK for PHP.


S3 Driver Options

OptionTypeDefaultDescription
keystringrequiredAWS access key ID for authentication
secretstringrequiredAWS secret access key for authentication
regionstringrequiredAWS region code (e.g., 'us-east-1')
bucketstringrequiredS3 bucket name
urlstringnullCustom base URL for public file access
endpointstringnullCustom S3-compatible endpoint (for MinIO, DigitalOcean Spaces, etc.)
use_path_style_endpointboolfalseUse path-style endpoint format instead of virtual-hosted style
tokenstringnullAWS session token for temporary credentials
temporary_urlarray[]Options for temporary URL generation
throwboolfalseWhether to throw exceptions on errors
rootstring''Path prefix within the bucket
visibilitystringnullDefault visibility: 'public' or 'private'
optionsarray[]Additional S3Client configuration options
poolarraySee Pool ConfigurationConnection pooling settings

S3 Options Array

The options array is passed directly to the AWS S3Client constructor and can include:

OptionTypeDescription
versionstringS3 API version (default: 'latest')
signature_versionstringAWS signature version (e.g., 'v4')
use_dual_stack_endpointboolUse dual-stack endpoints for IPv4/IPv6
use_accelerate_endpointboolUse S3 Transfer Acceleration
retriesintNumber of retry attempts for failed requests
httparrayHTTP client configuration (timeout, proxy, etc.)

Temporary URL Configuration

The temporary_url array controls signed URL generation:


Example Configuration


Sources: publish/filesystems.php47-63 composer.json46


Google Cloud Storage Configuration

The gcs driver integrates with Google Cloud Storage using the Google Cloud SDK for PHP.


GCS Driver Options

OptionTypeDefaultDescription
key_file_pathstringnullPath to service account JSON key file
key_filearray[]Service account credentials as array (alternative to file)
project_idstringrequiredGoogle Cloud project ID
bucketstringrequiredGCS bucket name
path_prefixstring''Default path prefix within the bucket
storage_api_uristringnullCustom storage API URI for public URLs
api_endpointstringnullCustom API endpoint for StorageClient
visibilitystringnullDefault visibility: 'public' or 'private'
visibility_handlerstringnullFQCN of custom visibility handler
metadataarray[]Default metadata for all uploaded objects
stream_readsboolfalseEnable streaming reads for better memory efficiency
throwboolfalseWhether to throw exceptions on errors
poolarraySee Pool ConfigurationConnection pooling settings

Key File Authentication

Option 1: JSON File Path


Option 2: Inline Array


Visibility Handler

Set visibility_handler to enable uniform bucket-level access:


Metadata Configuration

Default metadata is applied to all uploaded objects:


Example Configuration


Sources: publish/filesystems.php65-85 composer.json47


FTP/SFTP Driver Configuration

FTP and SFTP drivers provide remote file access over traditional network protocols.


FTP Driver Options

OptionTypeDefaultDescription
hoststringrequiredFTP server hostname or IP address
portint21FTP server port
usernamestringrequiredFTP username
passwordstringrequiredFTP password
rootstring''Root directory on the FTP server
passivebooltrueUse passive mode for data transfers
sslboolfalseUse FTPS (FTP over SSL/TLS)
timeoutint30Connection timeout in seconds
visibilitystringnullDefault visibility (may not be supported by all servers)
throwboolfalseWhether to throw exceptions on errors

SFTP Driver Options

OptionTypeDefaultDescription
hoststringrequiredSFTP server hostname or IP address
portint22SFTP server port
usernamestringrequiredSFTP username
passwordstringnullSFTP password (if not using key authentication)
privateKeystringnullPath to private key file for authentication
passphrasestringnullPassphrase for encrypted private key
rootstring''Root directory on the SFTP server
timeoutint30Connection timeout in seconds
permissionsarraySee local driverDirectory and file permissions
visibilitystringnullDefault visibility
throwboolfalseWhether to throw exceptions on errors

Example FTP Configuration


Example SFTP Configuration


Sources: composer.json41 composer.json48-49


Pool Configuration

Connection pooling is available for S3 and GCS drivers to improve performance in high-concurrency Swoole/Hyperf environments. The pool is managed by the FilesystemPoolProxy class using the hypervel/object-pool library.


Pool Options

OptionTypeDefaultDescription
min_objectsint1Minimum number of connection objects to maintain in the pool
max_objectsint10Maximum number of connection objects allowed in the pool
wait_timeoutfloat3.0Maximum seconds to wait when borrowing an object if pool is exhausted
max_lifetimefloat60.0Maximum seconds an object can live before being destroyed and recreated

Pool Configuration Guidelines

Optimal Settings for Different Workloads:

Workload Typemin_objectsmax_objectswait_timeoutmax_lifetime
Low traffic153.060.0
Medium traffic2105.0120.0
High traffic52010.0300.0
Burst traffic2303.060.0

Configuration Considerations:

  • min_objects: Higher values provide better response times but consume more resources when idle
  • max_objects: Should be set based on expected concurrency and upstream service limits (S3/GCS rate limits)
  • wait_timeout: Balance between request timeout and resource availability
  • max_lifetime: Shorter values refresh connections more frequently but increase overhead

Example Pool Configuration

Conservative (default):


Aggressive (high throughput):


Sources: publish/filesystems.php57-62 publish/filesystems.php79-84 composer.json37


Advanced Configuration Options

Scoped Driver (Path Prefixing)

Wrap any driver with automatic path prefixing using the scoped driver:


All operations on this disk will be automatically prefixed with uploads/2024/.

Required: league/flysystem-path-prefixing package

Read-Only Driver

Make any disk read-only by wrapping it:


Write operations will throw UnableToWriteFile exceptions.

Required: league/flysystem-read-only package

Custom Driver Configuration

Custom drivers registered via FilesystemManager::extend() can accept arbitrary configuration:


The configuration array is passed to the custom creator callback.

Sources: composer.json44-45


Configuration Loading and Caching

The configuration is loaded by FilesystemManager through Hyperf's configuration system:


Configuration Access

The FilesystemManager accesses configuration through the ConfigInterface:

  • Disk configurations: filesystems.disks.{name}
  • Default disk: filesystems.default

Disk Instance Caching

Created disk instances are cached in FilesystemManager::$disks to avoid redundant initialization:


To purge a specific disk from cache:


Sources: publish/filesystems.php1-88


Environment Variable Reference

Common environment variables used in filesystem configuration:

Global

VariableDescriptionExample
FILESYSTEM_DISKDefault disk namelocal
APP_URLBase application URL (for local public URLs)https://example.com

AWS S3

VariableDescriptionExample
AWS_ACCESS_KEY_IDAWS access keyAKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEYAWS secret keywJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_DEFAULT_REGIONAWS regionus-east-1
AWS_BUCKETS3 bucket namemy-bucket
AWS_URLCustom public URLhttps://cdn.example.com
AWS_ENDPOINTCustom endpointhttps://nyc3.digitaloceanspaces.com
AWS_USE_PATH_STYLE_ENDPOINTPath-style endpointstrue or false

Google Cloud Storage

VariableDescriptionExample
GOOGLE_CLOUD_KEY_FILEService account key file path/path/to/key.json
GOOGLE_CLOUD_PROJECT_IDGCP project IDmy-project-123456
GOOGLE_CLOUD_STORAGE_BUCKETGCS bucket namemy-bucket
GOOGLE_CLOUD_STORAGE_PATH_PREFIXDefault path prefixuploads/
GOOGLE_CLOUD_STORAGE_API_URICustom storage API URIhttps://storage.example.com
GOOGLE_CLOUD_STORAGE_API_ENDPOINTCustom API endpointhttps://api.example.com

FTP/SFTP

VariableDescriptionExample
FTP_HOSTFTP server hostnameftp.example.com
FTP_PORTFTP server port21
FTP_USERNAMEFTP usernameuser@example.com
FTP_PASSWORDFTP passwordsecret
FTP_ROOTFTP root directory/public_html
SFTP_HOSTSFTP server hostnamesftp.example.com
SFTP_PORTSFTP server port22
SFTP_USERNAMESFTP usernamedeploy
SFTP_PASSWORDSFTP passwordsecret
SFTP_PRIVATE_KEYPrivate key file path/home/.ssh/id_rsa
SFTP_PASSPHRASEKey passphrasepassphrase
SFTP_ROOTSFTP root directory/var/www

Sources: publish/filesystems.php17 publish/filesystems.php42 publish/filesystems.php49-55 publish/filesystems.php67-73


Configuration Validation

The following table summarizes required vs optional configuration by driver:

OptionLocalS3GCSFTPSFTP
driver✓ Required✓ Required✓ Required✓ Required✓ Required
root✓ RequiredOptionalOptionalOptionalOptional
host✓ Required✓ Required
username✓ Required✓ Required
password✓ RequiredOptional*
key✓ Required
secret✓ Required
region✓ Required
bucket✓ Required✓ Required
project_id✓ Required
key_fileOptional*
privateKeyOptional*
poolOptionalOptional
urlOptionalOptionalOptional
throwOptionalOptionalOptionalOptionalOptional
visibilityOptionalOptionalOptionalOptionalOptional

* For SFTP, either password or privateKey is required. For GCS, either key_file_path or key_file array is required.

Sources: publish/filesystems.php32-86

Refresh this wiki

On this page