This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".  
Status: 2025-02-15

Media\Type

Type Class

Following iana's Media Type List www.iana.org/assignments/media-types/media-types.xhtml

Emvicy provides single classes for each of the > 2000 Types. Each class comes with:

  • Media Type Description in its class name (e.g. Type_Application_json)
  • constant DESCRIPTION, containing the (string) Media Type Description
  • static method header(), which sends a header with Content-Type: DESCRIPTION

All classes are divided into the following types

  • application
  • audio
  • font
  • haptics
  • image
  • message
  • model
  • multipart
  • text
  • video

So in fact type application classes are named Type_Application_* (e.g. Type_Application_json),
while type image classes are named Type_Image_* (e.g. Type_Image_gif)


Example: \MVC\Media\Type_Application_json

<?php
/**
 * Type_Application_json.php
 * @package Emvicy
 * @copyright ueffing.net
 * @author Guido K.B.W. Üffing <emvicy@ueffing.net>
 * @license GNU GENERAL PUBLIC LICENSE Version 3. See application/doc/COPYING
 */

namespace MVC\Media;

use MVC\MVCTrait\TraitMediaType;

class Type_Application_json
{
    use TraitMediaType;

    /**
     * @reference [RFC8259]
     */
    const DESCRIPTION = 'application/json';
}

sends a header with Content-Type: (string) DESCRIPTION

\MVC\Media\Type_Application_json::header();

contains (string) application/json

$sMediaTypeDescription = \MVC\Media\Type_Application_json::DESCRIPTION; 

Media Type List

for a full List of iana Media Types see www.iana.org/assignments/media-types/media-types.xhtml