Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

File Laravel Package

amphp/file

Non-blocking file I/O for PHP 8.1+ in the AMPHP ecosystem. Read/write files or stream via async file handles while keeping apps responsive. Uses multi-process by default, with optional eio/uv/parallel drivers when available.

View on GitHub
Deep Wiki
Context7
v4.0.0-beta.1

Users of 3.x should be able to update to 4.x without code changes unless their application did one of the following:

  • Defined a custom File implementation
  • Initialized ParallelFilesystemDriver with a custom worker count.

Breaking Changes

This release adds a lock(), tryLock(), and unlock() to the File interface. These methods provide a non-blocking means of locking and unlocking a file.

  • File::lock(): Non-blocking method to obtain a shared or exclusive lock on the file. This method must only return once the lock has been obtained.
  • File::tryLock(): Makes a single non-blocking attempt to obtain a shared or exclusive lock on the file. Returns true if the lock was obtained, otherwise false.
  • File::unlock(): Unlocks the file if the lock is currently held.

In 3.x, the constructor of ParallelFilesystemDriver accepted an optional WorkerPool and a number of workers to use from that pool. In 4.x, instead the constructor now requires only an optional LimitedWorkerPool (a new pool is created if one is not provided). The number of workers used for opening files is determined by the value returned from LimitedWorkerPool::getWorkerLimit(). Use a DelegateWorkerPool if you wish to use an existing pool and limit the number of workers used from the pool to open files. In general, it is not necessary to customize the parallel filesystem driver.


Full Changelog: https://github.com/amphp/file/compare/v3.2.0...v4.0.0-beta.1

v3.2.0

What's Changed

  • The parallel driver no longer reuses the global worker pool if a specific instance is not provided to the constructor. Instead, a new worker pool is created.
  • The $workerLimit parameter to the constructor of ParallelFilesystemDriver is now deprecated. Pass an instance of LimitedWorkerPool instead.

Full Changelog: https://github.com/amphp/file/compare/v3.1.1...v3.2.0

v3.1.1

What's Changed

Full Changelog: https://github.com/amphp/file/compare/v3.1.0...v3.1.1

v3.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/amphp/file/compare/v3.0.2...v3.1.0

v3.0.2

What's Changed

  • Fixed detecting if a file is writing from the file mode when r+ (or similar) is used as the mode. (#77)
  • Fixed assertion failing during shutdown destruction of ParallelFilesystemDriver. (#81)

Full Changelog: https://github.com/amphp/file/compare/v3.0.1...v3.0.2

v3.0.1

What's Changed

  • Fix touch() on non-existent files in ext-uv and ext-eio by @kelunik (#73)
  • Fix write() truncation with ext-uv and ext-eio by @danog in (#76)

Full Changelog: https://github.com/amphp/file/compare/v3.0.0...v3.0.1

v3.0.0

Stable release compatible with AMPHP v3 and fibers! 🎉

As with other libraries compatible with AMPHP v3, most cases of parameters or returns of Promise<ResolutionType> have been replaced with ResolutionType.

  • Renamed BlockingDriver to BlockingFilesystemDriver
  • Renamed EioDriver to EioFilesystemDriver
  • Renamed ParallelDriver to ParallelFilesystemDriver
  • Renamed StatusCachingDriver to StatusCachingFilesystemDriver
  • Renamed UvDriver to UvFilesystemDriver
  • Renamed Amp\File\Sync\AsyncFileMutex to Amp\File\FileMutex
  • Added ?Cancellation as first parameter of File::read()
  • Added File::isSeekable()
  • Removed File::SEEK_SET, File::SEEK_CUR, and File::SEEK_END
  • Added Amp\File\Whence for seeking instead
v3.0.0-beta.6
  • Fixed compatibility with v2.0 of amphp/byte-stream by updating File implementations to also implement Traversable.
v3.0.0-beta.5
  • Fixed PendingOperationError being thrown after several seek-then-write operations in UvFile and EioFile.
v3.0.0-beta.4
  • Added compatibility with Revolt v1.x
  • Fixed (removed) file truncation in append modes with ext-eio
  • Fixed tell behavior in blocking implementation for append modes
  • Fixed automatic closing of files with ext-uv
  • Fixed exception message in BlockingFilesystemDriver::write
v3.0.0-beta.3
v2.0.4
v3.0.0-beta.2
  • PHP 8.1 now required.
  • Update for Closable interface adding an onClose. All File objects now include an onClose method which can be used to attache a closure which will be invoked when the file is closed.
v3.0.0-beta.1
  • Support AMPHP v3 and fibers, removing the need for promises for return values
  • Changed File::write() return type from Promise<int> to void
  • Renamed Driver to FilesystemDriver
  • Renamed Amp\File\Sync\AsyncMutex to Amp\File\FileMutex
v2.0.3
  • Return written length in blocking and parallel drivers (https://github.com/amphp/file/pull/64) This makes BlockingFile and ParallelFile consistent with the other drivers and the documented return type. However, it's recommended to avoid relying on this return value, as these method will return void in the next major version.
v2.0.2
  • Fix compatibility with ext-eio (#61)
v2.0.1
  • Fixed deprecation warning on PHP 8.1
v2.0.0
  • Added AsyncFileMutex (#43)
  • Improved driver consistency and reduced its API (#38)
  • Added functions: isSymlink
  • Renamed functions:
    • open → openFile
    • stat → getStatus
    • lstat → getLinkStatus
    • size → getSize
    • isdir → isDirectory
    • isfile → isFile
    • mtime → getModificationTime
    • atime → getAccessTime
    • ctime → getCreationTime
    • symlink → createSymlink
    • link → createHardlink
    • readlink → resolveSymlink
    • rename → move
    • unlink → deleteFile
    • rmdir → deleteDirectory
    • scandir → listFiles
    • chmod → changePermissions
    • chown → changeOwner ($uid and $gid accept null instead of -1 to ignore now)
    • get → read
    • put → write
    • mkdir → createDirectory / createDirectoryRecursively

Huge thanks to @enumag for this release!

v1.0.2
  • Fixed compatibility with ext-uv@0.2.x (#46)
v1.0.1
  • Added support for ext-uv@0.3.0
  • Improved error messages when using the blocking driver or parallel driver
  • Fixed link() function, previously was creating a symlink instead of a hard link (#37)
  • Skipped usage of EIO_O_FSYNC if undefined (#42)
  • Fixed export-ignore files for composer installs
v1.0.0

This release is, in most cases, backward compatible with v0.3.x if this library was only used for async file access.

Uses of Amp\File\Handle should be replaced with Amp\File\File, as Amp\File\Handle will be removed in a future major release.

Please review the changes below to determine if further changes are needed for your code.

  • Handle has been deprecated in favor of File, which extends Handle for backward compatibility. Uses of Handle should be updated to File. Thus, the promise returned from Driver::open() should resolve with an instance of File.
  • BlockingHandle, EioHandle, ParallelHandle, and UvHandle have been renamed respectively to BlockingFile, EioFile, ParallelFile, and UvFile.
  • All classes, except FilesystemException, are now declared final.
  • Amp\File\driver() has been renamed to Amp\File\createDefaultDriver().
  • File adds a truncate() method to resize the file to a given length.
v0.3.5
  • Fixed an error calculating file length when writing to files with the UV extension if the file was opened in append mode.
v0.3.4

Accidental tag on master when v0.3.x branch should have been tagged. Ignore this release.

v0.3.3
  • Fixed stat result when using UvDriver (#29)
  • Fixed readlink implementation when using EioDriver or UvDriver (#30)
  • Fixed scandir when reading an empty directory when using UvDriver (#23)
  • Results returned from scandir are now alphabetically sorted when using EioDriver (now matches results from other drivers).
  • Added isSupported() method to EioDriver and UvDriver, returning a bool determining if the driver can be used.
v0.3.2

Updated to amphp/parallel v1.0.

v0.3.1
  • Fixed default permissions for mkdir(). These previously were 0644, which doesn't really make sense, because it doesn't allow listing. New default is 0777 like PHP's default, which will usually result in 0755 with the umask.
v0.3.0
  • All SAPIs (not only CLI) will use ParallelDriver if ext-eio and ext-uv are not installed.
  • Windows can now use ParallelDriver
  • The 'e' flag is automatically used when opening files (#20)
  • Added optional parameters $time and $atime to Amp\File\touch() and Driver::touch() (#22)This is only a breaking change if you implement the Driver interface yourself.
v0.2.4
  • Use BlockingDriver for SAPIs other than cli and phpdbg.
v0.2.3
  • Workers created by the amphp/parallel package will not use ParallelDriver to avoid launching another worker from within a worker. BlockingDriver is used if eio or uv is not available.
  • StatCache is now used in ParallelDriver in the same way as EioDriver and UvDriver.
v0.2.2
  • The ParallelHandle::seek() function now doesn't set the handle to busy, similarly to the other handle implementations.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport