Download the PHP package didslm/file-upload-wrapper without Composer

On this page you can find all versions of the php package didslm/file-upload-wrapper. 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-upload-wrapper

File Upload Wrapper

The File Upload Wrapper is a PHP library that simplifies file uploads by providing a set of easy-to-use classes that handle common validation and processing tasks. With this library, you can:

Getting Started

To use the library, follow these steps:

  1. Install the library using Composer:

  2. Import the classes you need:

  3. Use the upload() method to handle file uploads for your entity:

  4. The same exmaple you can do via Dependency Injection:

At the end of this document you can see how to configure in Laravel or Symfony.


Examples

Handling File Uploads for an Entity

The following code shows an example of how to use the library to handle file uploads for an entity:

In this example, the Product class has two properties image and profile that are decorated with the Image attribute.

Types

In the following example you will see a list of available Attribute types:

The Image attribute provides metadata to the library to process the files correctly during the upload.

The Document attribute provides metadata to the library to process the files correctly during the upload.

The Video attribute provides metadata to the library to process the files correctly during the upload.

The upload() method is then called on the Uploader class with the Product object and an array of validation rules as its parameters.

Handling Exceptions

The library provides a FileUploadException class that all exceptions thrown by the library extend. This means that you can catch all exceptions using FileUploadException in a try-catch block, as shown below:

Validation

The library provides several validation classes that you can use to validate uploaded files. These classes can be passed as parameters to the upload() method to specify the validation rules for the files being uploaded.

Type

The FileType class is used to check the file type. You can specify the types of files allowed by passing an array of file types to the constructor. For example:

Size

The FileSize class is used to validate the file size. You can specify the maximum file size allowed by passing the size in bytes to the constructor. Alternatively, you can use the Size class to specify the size in a more readable format. For example:

Dimension

The Dimension class is used to validate the dimensions of images. You can specify the maximum width and height of the image by passing them as parameters to the constructor. For example:

Targeted Validations

You can also target specific fields in your entity with a set of validations. To do this, you can use the FieldValidations class, which takes the request field name as it's first parameter and an array of validation rules as its second parameter. Here's an example:

In the example above, we are specifying a set of validation checks that apply to the profile field in the Product entity. These checks will only be applied to the profile image uploaded by the user.

Frameworks Implementation

The library is framework agnostic, which means that you can use it with any framework.

The following sections show how to configure the library in some of the most popular frameworks.

Symfony

In your Symfony app you can easily configure the library in your services.yaml file:

Laravel

In your Laravel app you can easily configure the library in your AppServiceProvider.php file:


Handling file uploads can be a complicated and error-prone task, but with this library, you can simplify the process and focus on building the features that matter. If you have any questions or feedback, feel free to reach out to the author on Twitter or LinkedIn.


All versions of file-upload-wrapper with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
psr/http-message Version ^1.0
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 didslm/file-upload-wrapper contains the following files

Loading the files please wait ....