Download the PHP package webfiori/file without Composer

On this page you can find all versions of the php package webfiori/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

WebFiori File

A comprehensive PHP library for file operations, providing an object-oriented abstraction layer for reading, writing, uploading, and serving files with advanced features like Base64 encoding/decoding, MIME type detection, and chunked file processing.

Table of Contents

Installation

Install via Composer:

Requirements

Supported PHP Versions

Build Status

Key Features

Quick Start

Core Classes

File

The main class for file operations, providing methods for reading, writing, and manipulating files.

FileUploader

Handles file uploads with validation, type checking, and error management.

UploadedFile

Extends File class to represent uploaded files with additional upload-specific properties.

MIME

Utility class for MIME type detection based on file extensions.

Usage Examples

Basic File Operations

Reading Files

Writing Files

File Information

File Upload

Basic Upload

Upload as File Objects

Upload Configuration

Base64 Encoding/Decoding

File Serving

Chunked Processing

MIME Type Detection

Working Example

The library includes a complete working example demonstrating file upload functionality with a modern web interface. The example consists of:

Running the Example

The example demonstrates:

For detailed setup instructions, see example/readme.md.

Testing

The library includes comprehensive test coverage using PHPUnit:

Test Coverage

The test suite covers:

The library includes comprehensive test coverage with extensive test cases.

UploadedFile Class

Constructor

Core Methods

Method Description Parameters Return Type
isUploaded() Check if file was uploaded successfully - bool
isReplace() Check if file replaced existing file - bool
getUploadError() Get upload error message - string
setIsUploaded($bool) Set upload status bool $bool void
setIsReplace($bool) Set replacement status bool $bool void
setUploadErr($err) Set upload error message string $err void

MIME Class

Static Methods

Method Description Parameters Return Type
getType($ext) Get MIME type by extension string $ext string

The MIME class contains a comprehensive mapping of file extensions to their corresponding MIME types.

Error Handling

The library uses the FileException class for error handling:

Common exceptions thrown:

Security Considerations

File Upload Security

Path Traversal Protection

The library automatically:

Best Practices

  1. Always validate file types before processing
  2. Store uploads outside the web root when possible
  3. Set appropriate file permissions (644 for files, 755 for directories)
  4. Implement file size limits via PHP configuration
  5. Scan uploaded files for malware when possible
  6. Use HTTPS for file upload forms

Performance Tips

Memory Management

Optimization Tips

  1. Use appropriate chunk sizes for large files (1MB recommended)
  2. Read only necessary byte ranges when possible
  3. Cache MIME type detection results for repeated operations
  4. Use streaming for file serving when available
  5. Implement proper error handling to avoid resource leaks

File Serving Optimization

Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository and create a feature branch
  2. Write tests for new functionality
  3. Follow PSR-12 coding standards
  4. Update documentation for new features
  5. Submit a pull request with clear description

Development Setup

Running Tests

License

This project is licensed under the MIT License - see the LICENSE file for details.


All versions of file with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
webfiori/jsonx Version 4.0.x
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 webfiori/file contains the following files

Loading the files please wait ....