Download the PHP package fostam/file without Composer

On this page you can find all versions of the php package fostam/file. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package file

fostam/file

File is a simple convenience wrapper for PHP functions like fopen(), fgets(). It offers object oriented usage of file functions, and handles errors with exceptions instead of return results and PHP warnings/errors.

Install

The easiest way to install File is by using composer:

Usage

Example: print the contents of a file, line by line

Example: write into a file

Example: resumt reading a file from a known position

Errors

All errors are caught and passed on by throwing an Exception. All thrown Exceptions derive from the Fostam\File\Exception\FileException class.

Reference

Methods

Method Return value Description Equivalent
__construct(string $filename, string $mode) void Constructor -
open() void Open the file fopen()
close(bool $silent = false) void Close the file fclose()
setPos(int $pos) void Set the file pointer to position $pos fseek()
getPos() int Get the current file position ftell()
readLine(?int $maxBytes = null, int $pos = null) ?string Get the line (up to $maxBytes bytes) at the current position, or $pos fgets()
readBytes(int $length, int $pos = null) ?string Get $length bytes from the current position, or $pos fread()
write(string $data, int $maxBytes = null, int $pos = null) int Write (up to $maxBytes bytes from) $data to the current position, or $pos fputs()
truncate(int $size = 0) void Truncate the file to $size bytes ftruncate()
flush() void Write all data to disk fflush()
lockShared(bool $nonBlocking = false) void Lock the file in shared mode flock()
lockExclusive(bool $nonBlocking = false) void Lock the file in exclusive mode flock()
unlock(bool $nonBlocking = false) void Unlock the file flock()
stat() void Get file information fstat()
isAtEOF() bool Returns true if the file pointer is at the end of the file feof()
getFileHandle(): resource void Get the file handle (e.g. to be used with other file functions) fopen() (return value)

Open File Modes

See the fopen() documentation for a description of modes.

Constant Mode Description
MODE_READ r Read-only
MODE_READWRITE r+ Read/Write
MODE_WRITE_CREATE_OR_TRUNCATE w Write-only; create file, truncate if existing
MODE_READWRITE_CREATE_OR_TRUNCATE w+ Read/Write; create file, truncate if existing
MODE_WRITE_APPEND_CREATE a Write-only; append; create file if not existing
MODE_READWRITE_APPEND_CREATE a+ Read/Write; append; create file if not existing
MODE_WRITE_CREATE_NEW x Write-only; create file, fail if existing
MODE_READWRITE_CREATE_NEW x+ Read/Write; create file, fail if existing
MODE_WRITE_CREATE c Write-only; create file, don't truncate if existing
MODE_READWRITE_CREATE c+ Read/Write; create file, don't truncate if existing

Exceptions


All versions of file with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fostam/file contains the following files

Loading the files please wait ....