Styling console applications based on Symfony, Laravel, CakePHP, and other PHP Frameworks!

Methods

Media Files

Method Description
upload Upload media file.
fetch Fetch file or files collection.
move Move file.
copy Copy file.
delete Delete file.
has Check whether a file exists.
getFileLocation Get file location.

Methods Details

upload

Upload media file.

/**
 * Upload media file
 *
 * @param array  $file   Raw file data (multipart/form-data).
 * @param string $folder The folder you're targetting.
 *
 * @access public
 */
public function upload(array $file, string $folder)

Examples

flextype('media')
  ->files()
  ->upload($_FILES['file'], '/entries/movies/sg-1/season-5/episode-21/');
fetch

Fetch file or files collection.

/**
 * Fetch.
 *
 * @param string $id    The path to file.
 * @param array  $options Options array.
 *
 * @access public
 */
public function fetch(string $id, array $options = []): Arrays
Fetch single file

Examples

// Fetch single image
$cover = flextype('media')
                 ->files()
                 ->fetch('entries/movies/sg-1/season-5/episode-21/cover.jpg');

// Now you may get each image field from image meta data.
echo $cover['title'];
echo $cover['description'];
echo $cover['uploaded_on'];
echo $cover['filename'];
echo $cover['basename'];
echo $cover['extension'];
echo $cover['dirname'];
echo $cover['url'];
echo $cover['full_url'];

// Fetch single image and send $options
$cover = flextype('media')
                  ->files()
                  ->fetch('entries/movies/sg-1/season-5/episode-21/cover.jpg', $options);

$options is an array of valid values for filter() and find() helpers.

Fetch files collection

Examples

// Fetch images collection
$images = flextype('media')
                     ->files()
                     ->fetch('entries/movies/sg-1/season-5/episode-21');

// Fetch images collection and send $options
$cover = flextype('media')
                  ->files()
                  ->fetch('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                                ['collection' => true, ...$options]);

$options is an array of valid values for filter and find helpers.

move

Move file.

/**
 * Move file
 *
 * @param string $id     Unique identifier of the file.
 * @param string $newID New Unique identifier of the file.
 *
 * @return bool True on success, false on failure.
 *
 * @access public
 */
public function move(string $id, string $newID): bool

Examples

flextype('media')
  ->files()
  ->move('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                          'entries/movies/sg-1/season-5/episode-21/cover-image.jpg');
copy

Copy file.

/**
 * Copy file
 *
 * @param string $id     Unique identifier of the file.
 * @param string $newID New Unique identifier of the file.
 *
 * @return bool True on success, false on failure.
 *
 * @access public
 */
public function copy(string $id, string $newID): bool

Examples

flextype('media')
            ->files()
            ->copy('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                          'entries/movies/sg-1/season-5/episode-22/cover.jpg');
delete

Delete file.

/**
 * Delete file
 *
 * @param string $id Unique identifier of the file.
 *
 * @return bool True on success, false on failure.
 *
 * @access public
 */
public function delete(string $id): bool

Examples

flextype('media')
            ->files()
            ->delete('entries/movies/sg-1/season-5/episode-21/cover-image.jpg');
has

Check whether a file exists.

/**
 * Check whether a file exists.
 *
 * @param string $id Unique identifier of the file.
 *
 * @return bool True on success, false on failure.
 *
 * @access public
 */
public function has(string $id): bool

Examples

if (flextype('media')
            ->files()
            ->has('entries/movies/sg-1/season-5/episode-21/cover-image.jpg')) {
    // do something...
}
getFileLocation

Get file location.

/**
 * Get file location
 *
 * @param string $id Unique identifier of the file.
 *
 * @return string entry file location
 *
 * @access public
 */
public function getFileLocation(string $id): string

Examples

flextype('media')
            ->files()
            ->getFileLocation('entries/movies/sg-1/season-5/episode-21/cover-image.jpg');

Media Files Meta

Method Description
update Update file meta information.
add Add file meta information.
delete Delete file meta information.
getFileMetaLocation() Get file meta location.

Methods Details

update

Update file meta information.

Examples

flextype('media')
            ->files()
            ->meta()
            ->update('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                     'title',
                     'Episode 21');
add

Add file meta information.

Examples

flextype('media')
            ->files()
            ->meta()
            ->add('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                     'tags',
                     'sg1');
delete

Delete file meta information.

Examples

flextype('media')
            ->files()
            ->meta()
            ->delete('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                     'tags');

getFileMetaLocation()

Get file meta location.

Examples

flextype('media')
            ->files()
            ->meta()
            ->getFileMetaLocation('entries/movies/sg-1/season-5/episode-21/cover.jpg');

Media Folders

Method Description
fetch Fetch folder or folders collection.
move Create folder.
move Move folder.
delete Delete folder.
getDirLocation Get folder location.

Methods Details

fetch

Fetch folder or folders collection.

Fetch single folder.

Examples

// Fetch single folder
$folder = flextype('media')
                ->folders()
                ->fetch('entries/movies/sg-1/season-5/episode-21');

echo $folder['path'];
echo $folder['full_path'];
echo $folder['url'];
echo $folder['full_url'];
Fetch folders collection.

Examples

// Fetch folders collection
$folders = flextype('media')
                ->folders()
                ->fetch('entries/movies/sg-1/season-5', ['collection' => true]);
create

Create folder.

Examples

flextype('media')
            ->folders()
            ->create('entries/movies/sg-1/season-5/episode-22');
move

Move folder.

Examples

flextype('media')
            ->folders()
            ->move('entries/movies/sg-1/season-5/episode-22',
                            'entries/movies/sg-1/season-5/episode-23');
delete

Delete folder.

Examples

flextype('media')
            ->folders()
            ->delete('entries/movies/sg-1/season-5/episode-23');
getDirLocation

Get folder location.

Examples

flextype('media')
            ->folders()
            ->getDirLocation('entries/movies/sg-1/season-5/episode-23');

Media Folders Meta

Method Description
getDirMetaLocation Get files directory meta location.

Methods Details

getDirMetaLocation

Get files directory meta location.

Examples

flextype('media')
            ->folders()
            ->meta()
            ->getDirMetaLocation('entries/movies/sg-1/season-5/episode-23');