PHP code example of alembic / mime

1. Go to this page and download the library: Download alembic/mime library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alembic / mime example snippets


use Alembic\Mime\Mime;

use Alembic\Mime\Mime;

Mime::lookup('/path/to/file.txt');         # => 'text/plain'
Mime::lookup('file.txt');                  # => 'text/plain'
Mime::lookup('.TXT');                      # => 'text/plain'
Mime::lookup('htm');                       # => 'text/html'
Mime::lookup('unknown');                   # => 'application/octet-stream'
Mime::lookup('unknown', null);             # => null
# Instance mode:
(new Mime)->lookup('folder/file');         # => 'application/octet-stream'

Mime::extension('text/html');                 # => 'html'
Mime::extension('application/octet-stream');  # => 'bin'

Mime::define([
    'text/x-some-format'      => ['x-sf', 'x-sft', 'x-sfml'],
    'application/x-my-type'   => ['x-mt', 'x-mtt'],
    'application/x-my-format' => 'x-mf', # string allowed for unique ext
    # etc ...
]);

Mime::lookup('x-sft');  # => 'text/x-some-format'

Mime::extension('text/x-some-format');  # => 'x-sf'

Mime::load('./my_project.types');