PHP code example of alex-kalanis / kw_mime

1. Go to this page and download the library: Download alex-kalanis/kw_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/ */

    

alex-kalanis / kw_mime example snippets


// Somewhere in DI
return function ($params): \kalanis\kw_mime\Interfaces\IMime {
    return (new \kalanis\kw_mime\Check\Factory())->getLibrary($params);
}

// In code
class MimeExample
{
    public function __construct(
        // ...
        protected readonly \kalanis\kw_mime\Interfaces\IMime $mime,
        // ...
    ) {
    }

    public function which(string $file): string
    {
        $path = (new \kalanis\kw_paths\ArrayPath())->setString($file);
        return $this->mime->getMime($path->getArray());
    }
}