The Hoa\Mime library.

Overview

Hoa


Build status Code coverage Packagist License

Hoa is a modular, extensible and structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\Mime

Help on IRC Help on Gitter Documentation Board

This library allows to manipulate a MIME types database and get some related informations about streams.

Learn more.

Installation

With Composer, to include this library into your dependencies, you need to require hoa/mime:

$ composer require hoa/mime '~3.0'

For more installation procedures, please read the Source page.

Testing

Before running the test suites, the development dependencies must be installed:

$ composer install

Then, to run all the test suites:

$ vendor/bin/hoa test:run

For more information, please read the contributor guide.

Quick usage

As a quick overview, we will see how to get general and stream-related informations.

General informations

All we need is static methods Hoa\Mime\Mime::getExtensionsFromMime to get extensions from a type and Hoa\Mime\Mime::getMimeFromExtension to get type from an extension:

print_r(Hoa\Mime\Mime::getExtensionsFromMime('text/html'));

/**
 * Will output:
 *     Array
 *     (
 *         [0] => html
 *         [1] => htm
 *     )
 */

var_dump(Hoa\Mime\Mime::getMimeFromExtension('webm'));

/**
 * Will output:
 *     string(10) "video/webm"
 */

By default, Hoa\Mime\Mime uses the hoa://Library/Mime/Mime.types file as database. We can change this behavior by calling the Hoa\Mime\Mime::compute before any computations:

Hoa\Mime\Mime::compute('/etc/mime.types');

Stream-related informations

By instanciating the Hoa\Mime\Mime class with a stream, we are able to get some informations about the stream, such as its extension, others extensions, type, etc. Thus:

$type = new Hoa\Mime\Mime(new Hoa\File\Read('index.html'));

var_dump(
    $type->getExtension(),
    $type->getOtherExtensions(),
    $type->getMime(),
    $type->isExperimental()
);

/**
 * Will output:
 *     string(4) "html"
 *     array(1) {
 *       [0]=>
 *       string(3) "htm"
 *     }
 *     string(9) "text/html"
 *     bool(false)
 */

Documentation

The hack book of Hoa\Mime contains detailed information about how to use this library and how it works.

To generate the documentation locally, execute the following commands:

$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open

More documentation can be found on the project's website: hoa-project.net.

Getting help

There are mainly two ways to get help:

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know.

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE for details.

Related projects

The following projects are using this library:

  • E-Conf, E-Conf is a Conference Management System,
  • sabre/katana, A contact, calendar, task list and file server.
Comments
  • Support for Microsoft Office Open XML MIME types

    Support for Microsoft Office Open XML MIME types

    opened by limenet 15
  • updated Mime.types with new MIME types

    updated Mime.types with new MIME types

    As per issue #15 I hope I didn't mess up anything, since there are a lot of changes I can't go through them one-by-one but after a few checks it looks fine.

    enhancement 
    opened by limenet 6
  • Composer install does not work

    Composer install does not work

    Hi, I tried to install the Mime library in one or our project today be it seems some dependencies are missing.

    I tried with ^3.16.01, ~3.16 or ~3.0 and end with the following resolution errors.

    Problem 1
        - hoa/mime 3.16.01.11 requires hoa/zformat ~0.0 -> no matching package found.
        - hoa/mime 3.16.01.14 requires hoa/stream ~1.0 -> satisfiable by hoa/stream[1.16.01.14].
        - hoa/mime 3.16.01.15 requires hoa/stream ~1.0 -> satisfiable by hoa/stream[1.16.01.14].
        - Conclusion: don't install hoa/stream 1.16.01.14
        - Installation request for hoa/mime ^3.16.01 -> satisfiable by hoa/mime[3.16.01.11, 3.16.01.14, 3.16.01.15]
    

    Thanks

    question difficulty: medium 
    opened by bgaillard 3
  • Support uppercase file extensions

    Support uppercase file extensions

    Sometimes files have uppercase file extensions like image.JPG, which would cause a MimeIsNotFound exception to be thrown upon instantiation of Mime. This proposed fix simply converts the extension to lowercase in Mime::getMimeFromExtension().

    enhancement 
    opened by bgetsug 2
  • Upgrade to GitHub-native Dependabot

    Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.

    dependencies 
    opened by dependabot-preview[bot] 2
Releases(3.17.01.10)
  • 3.17.01.10(Jan 10, 2017)

    • Quality: Happy new year! (Alexis von Glasow, 2017-01-09T21:38:16+01:00)
    • Test: Add the Decorrelated interface. (Ivan Enderlin, 2016-10-25T07:55:40+02:00)
    • Documentation: New README.md file. (Ivan Enderlin, 2016-10-18T15:30:44+02:00)
    • Documentation: Update support properties. (Ivan Enderlin, 2016-10-11T17:04:06+02:00)
    Source code(tar.gz)
    Source code(zip)
  • 3.16.01.15(Jan 14, 2016)

  • 3.16.01.14(Jan 14, 2016)

  • 3.16.01.11(Jan 11, 2016)

    • Quality: Drop PHP5.4. (Ivan Enderlin, 2016-01-11T09:15:26+01:00)
    • Quality: Run devtools:cs. (Ivan Enderlin, 2016-01-09T09:05:27+01:00)
    • Core: Remove Hoa\Core. (Ivan Enderlin, 2016-01-09T08:20:11+01:00)
    • Parameters: Use Hoa\Zformat. (Ivan Enderlin, 2016-01-08T17:13:20+01:00)
    • Consistency: Use Hoa\Consistency. (Ivan Enderlin, 2015-12-08T11:23:05+01:00)
    • Exception: Use Hoa\Exception. (Ivan Enderlin, 2015-11-20T12:57:07+01:00)
    Source code(tar.gz)
    Source code(zip)
  • 2.15.10.29(Oct 29, 2015)

    • Test: Specify file type with hoa://Test/Vfs. (Ivan Enderlin, 2015-10-29T22:26:00+01:00)
    • Add a .gitignore file. (Stéphane HULARD, 2015-08-03T11:39:40+02:00)
    Source code(tar.gz)
    Source code(zip)
  • 2.15.07.28(Jul 28, 2015)

  • 2.15.05.29(May 29, 2015)

  • 2.15.02.24(Feb 24, 2015)

    • Add the CHANGELOG.md file. (Ivan Enderlin, 2015-02-24T09:26:54+01:00)
    • Update links in the documentation. (Ivan Enderlin, 2015-01-23T19:26:04+01:00)
    • Update Mime.types with new MIME types (Linus Metzler, 2015-01-19T11:38:14+01:00)
    • Happy new year! (Ivan Enderlin, 2015-01-05T14:42:39+01:00)
    Source code(tar.gz)
    Source code(zip)
  • 2.14.12.10(Feb 24, 2015)

  • 2.14.11.26(Feb 24, 2015)

    • Require hoa/test. (Alexis von Glasow, 2014-11-25T13:58:13+01:00)
    • Add text/vcard (RFC6350) (Ivan Enderlin, 2014-11-19T14:35:16+01:00)
    • Add application/davmount+xml (RFC4709). (Ivan Enderlin, 2014-11-19T14:27:17+01:00)
    • Add xCard. (Ivan Enderlin, 2014-11-12T13:47:04+01:00)
    • Add xCal. (Ivan Enderlin, 2014-11-12T13:46:41+01:00)
    Source code(tar.gz)
    Source code(zip)
  • 2.14.11.09(Feb 24, 2015)

  • 2.14.09.23(Feb 24, 2015)

  • 2.14.09.22(Feb 24, 2015)

    • Add tests for the documentation. (Ivan Enderlin, 2014-09-22T10:28:08+02:00)
    • Use short-array syntax. (Ivan Enderlin, 2014-09-17T18:54:29+02:00)
    • Remove from/import. (Ivan Enderlin, 2014-09-17T18:50:49+02:00)
    Source code(tar.gz)
    Source code(zip)
  • 2.14.09.17(Feb 24, 2015)

Owner
Hoa
Hoa is a modular, extensible and structured set of PHP libraries.
Hoa
A PHP library to deal with all those media services around, parsing their URLs and displaying their audios/videos.

MediaEmbed A utility library that generates HTML embed tags for audio or video located on a given URL. It also parses and validates given media URLs.

Mark Sch. 165 Nov 10, 2022
This package used to upload files using laravel-media-library before saving model.

Laravel Media Uploader This package used to upload files using laravel-media-library before saving model. In this package all uploaded media will be p

Ahmed Fathy 312 Dec 12, 2022
Upload File Library For PHP ( Simple & Easy User )

Upload File Library For Backend/ServerSide PHP ( Simple & Easy For Use ), Support Multiple Upload

Lamhot Simamora 1 Oct 12, 2021
Gotipath Storage is a file storage library for PHP. It provides one interface to interact with FTP/SFTP.

Gotipath Storage is a file storage library for PHP. It provides one interface to interact with FTP/SFTP. When you use this package, you're protected from vendor lock-in, That mean you can connect to any FTP/SFTP storage. Also it's comes with base URL option to connect Gotipath CDN.

Gotipath 2 Nov 3, 2021
PHPProject is a library written in pure PHP that provides a set of classes to write to different project management file formats

PHPProject PHPProject is a library written in pure PHP that provides a set of classes to write to different project management file formats, i.e. Micr

PHPOffice 192 Dec 17, 2022
FileNamingResolver - A lightweight library which helps to resolve a file/directory naming of uploaded files using various naming strategies

FileNamingResolver - A lightweight library which helps to resolve a file/directory naming of uploaded files using various naming strategies

Victor Bocharsky 111 May 19, 2022
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

PEL: PHP Exif Library README file for PEL: PHP Exif Library. A library with support for reading and writing Exif headers in JPEG and TIFF images using

null 264 Dec 4, 2022
BeckhoffPLCSoapClient - SoapClient to communicate with BeckHoff PLC. Library made in PHP based on TcAdsWebService JavaScript Library.

BeckhoffPLCSoapClient - SoapClient to communicate with BeckHoff PLC. Library made in PHP based on TcAdsWebService JavaScript Library.

null 3 May 18, 2022
EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby

EmailReplyParser EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby.

William Durand 606 Dec 8, 2022
Library JGU is a website created for a university library system information. Made with PHP & TailwindCSS.

Library JGU Library JGU is a website created for a university library system information. Made with PHP & TailwindCSS. Key Features • How To Use • Rel

Azkazikna Ageung Laksana 23 Oct 7, 2022
This library extends the 'League OAuth2 Client' library to provide OpenID Connect Discovery support for supporting providers that expose a .well-known configuration endpoint.

OpenID Connect Discovery support for League - OAuth 2.0 Client This library extends the League OAuth2 Client library to provide OpenID Connect Discove

null 3 Jan 8, 2022
Laravel-Library-Management-system is nice to management library system...

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Eng Hasan Hajjar 2 Sep 30, 2022
Dobren Dragojević 6 Jun 11, 2023
Simple utility and class library for generating php classes from a wsdl file.

wsdl2phpgenerator Simple WSDL to PHP classes converter. Takes a WSDL file and outputs class files ready to use. Uses the MIT license. Announcement: We

null 802 Dec 10, 2022
A PHP library to support implementing representations for HATEOAS REST web services.

Hateoas A PHP library to support implementing representations for HATEOAS REST web services. Installation Working With Symfony Usage Introduction Conf

William Durand 998 Dec 5, 2022
This PHP library will help you to work with your Pinterest account without using any API account credentials.

Pinterest Bot for PHP A PHP library to help you work with your Pinterest account without API credentials. The Pinterest API is painful: receiving an a

Sergey Zhuk 414 Nov 21, 2022
A simple Monad library for PHP

MonadPHP This is a basic Monad library for PHP. Usage Values are "wrapped" in the monad via either the constructor: new MonadPHP\Identity($value) or t

Anthony Ferrara 283 Dec 29, 2022
A simple library to work with JSON Web Token and JSON Web Signature

JWT A simple library to work with JSON Web Token and JSON Web Signature based on the RFC 7519. Installation Package is available on Packagist, you can

Luís Cobucci 6.8k Jan 3, 2023
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Hybridauth 3.7.1 Hybridauth enables developers to easily build social applications and tools to engage websites visitors and customers on a social lev

hybridauth 3.3k Dec 23, 2022