1. Go to this page and download the library: Download fei/filer-common 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/ */
fei / filer-common example snippets
use Fei\Service\Filer\Validator\FileValidator;
use Fei\Service\Filer\Entity\File;
$fileValidator = new FileValidator();
$file = new File();
//validate returns true if your File instance is valid, or false in the other case
$isFileValid = $fileValidator->validate($file);
//getErrors() allows you to get an array of errors if there are some, or an empty array in the other case
$errors = $fileValidator->getErrors();
use Fei\Service\Filer\Validator\FileValidator;
use Fei\Service\Filer\Entity\File;
$fileValidator = new FileValidator();
$file = new File();
$file->setUuid('uuid');
$file->setRevision(1);
$fileValidator->validateUuid($file->getUuid());
$fileValidator->validateRevision($file->getRevision());
// will return an empty array : all of our definitions are correct
$errors = $fileValidator->getErrors();
echo empty($errors); // true
// contentType can not be empty, let's try to set it as an empty string
$file->setContentType('');
$fileValidator->validateContentType($file->getContentType());
// this time you'll get a non-empty array
$errors = $fileValidator->getErrors();
echo empty($errors); // false
print_r($errors);
/**
* print_r will return:
*
* Array
* (
* ['contentType'] => Array
* (
* 'Content-Type cannot be empty'
* )
* )
**/
use Fei\Service\Filer\Validator\ContextValidator;
use Fei\Service\Filer\Entity\File;
use Fei\Service\Filer\Entity\Context;
$contextValidator = new ContextValidator();
$file = new File();
$context = new Context([
'key' => 'my_key',
'value' => 'my_value',
'file' => $file
]);
//validate returns true if your Context instance is valid, or false in the other case
$isContextValid = $contextValidator->validate($context);
//getErrors() allows you to get an array of errors if there are some, or an empty array in the other case
$errors = $contextValidator->getErrors();
use Fei\Service\Filer\Validator\ContextValidator;
use Fei\Service\Filer\Entity\Context;
$contextValidator = new ContextValidator();
$context = new Context();
$context->setKey('key');
$context->setValue('value');
$contextValidator->validateKey($context->getKey());
$contextValidator->validateValue($context->getValue());
// will return an empty array : all of our definitions are correct
$errors = $contextValidator->getErrors();
echo empty($errors); // true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.