Download the PHP package softcreatr/php-mime-detector without Composer

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

PHP Mime Detector

Detecting the real type of (binary) files doesn't have to be hard. Checking a file's extension is not reliable and can cause serious security issues.

This package helps you to determine the correct type of files, by reading it byte for byte (up to 4096) and check for magic numbers.

However, this package isn't a replacement for any security software. It just aims to produce less false positives, than a simple extension check would produce.

A list of supported file types can be found on this Wiki page.

Why a separate class?

You may wonder why we don't just rely on extensions like Fileinfo? First off all, a short background story:

We are building extensions and applications for an Open Source PHP Framework, thus we are creating web software for the masses. Many of our customers and/or users of our free products are on shared hosting without any possibility to install or manage installed PHP extensions. So our goal is to develop solutions with as few dependencies as necessary, but with as much functionality as possible.

While developing a solution, that allows people to convert HEIF/HEIC files to a more "standardized" format (using our own, external API), we had troubles detecting these files, because especially this format isn't known by most Webservers, yet. While checking the file extension isn't reliable, we had to find a reusable solution that works for most of our clients. So we started to build a magic number based check for these files. That was the birth of our Mime Detector.

Why are the unit tests so poorly written?

Short answer: I have just little experience in unit testing. This project was a good training and even if the unit tests could be better: I am proud of my progress :)

Demo

A demo (based on dev-master) can be found at WhatTheFile.info.

Requirements

If you are looking for a solution that works on older PHP versions (5.3.2+), head over to the oldphp branch.

Installation

Require this package using Composer, in the root directory of your project:

Usage

Here is an example on how this package makes it very easy to determine the mime type (and it's corresponding file extension) of a given file:

Or short:

Testing

Testing utilizes PHPUnit (what else?) by running this command:

However, you may check out a bunch of test files for a full test. Test files are no longer included in the composer package nor the Git repository itself, so you have to perform a checkout of this repository and install it's submodules:

When done, perform a composer install and run PHPUnit as described above.

ToDo

Contributing

Please see CONTRIBUTING for details.

When adding new detections, please make sure to provide at least one sample file.

License

ISC

Free Software, Hell Yeah!


All versions of php-mime-detector with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 softcreatr/php-mime-detector contains the following files

Loading the files please wait ....