Разделы
Теги | RSS © 2008 – 2022
Контакты
email:
skype:
» » » Страница 8

brandonsavage/Upload - скрипт загрузки файлов с валидацией


Пример
setName($new_filename);

// Validate file upload
// MimeType List => http://www.iana.org/assignments/media-types/media-types.xhtml
$file->addValidations(array(
    // Ensure file is of type "image/png"
    new \Upload\Validation\Mimetype('image/png'),

    //You can also add multi mimetype validation
    //new \Upload\Validation\Mimetype(array('image/png', 'image/gif'))

    // Ensure file is no larger than 5M (use "B", "K", M", or "G")
    new \Upload\Validation\Size('5M')
));

// Access data about the file that has been uploaded
$data = array(
    'name'       => $file->getNameWithExtension(),
    'extension'  => $file->getExtension(),
    'mime'       => $file->getMimetype(),
    'size'       => $file->getSize(),
    'md5'        => $file->getMd5(),
    'dimensions' => $file->getDimensions()
);

// Try to upload file
try {
    // Success!
    $file->upload();
} catch (\Exception $e) {
    // Fail!
    $errors = $file->getErrors();
}

https://github.com/brandonsavage/Upload

sokil/php-mongo - php ODM для mongodb


Пример получения данных
requiredField; // defaultValue
$document->get('requiredField'); // defaultValue
$document->getRequiredField(); // defaultValue

$document->someField; // ['subDocumentField' => 'value']
$document->get('someField'); // ['subDocumentField' => 'value']
$document->getSomeField(); // ['subDocumentField' => 'value']
$document->get('someField.subDocumentField'); // 'value'

$document->get('some.unexisted.subDocumentField'); // null

https://github.com/sokil/php-mongo

MongoQB - php обертка для запросов в mongo


Подключение
$qb = \MongoQB\Builder(array(
    'dsn'   =>  'mongodb://user:[email protected]:27017/databaseName'
);
Вставка
$qb->insert('collectionName', [
    'name'  =>  'Alex',
    'age'   =>  22,
    'likes' =>  ['whisky', 'gin']
]);
Обновление
$qb
    ->where(['name' => 'Alex'])
    ->set([
        'country' => 'UK',
        'job' => 'Developer'
    ])
    ->push('likes', ['PHP', 'coffee'])
    ->update('collectionName');

https://github.com/alexbilbie/MongoQB

CalendR - php библиотека календаря


Пример создания календаря
getMonth(2012, 01);
?>


http://yohan.giarel.li/CalendR/

php-ssh - php api для работы с ssh


Пример
getAuthentication('optional_passphrase', 'optional_username');

echo $exec->run('ls -lah');

https://github.com/Herzult/php-ssh

image-with-text - php скрипт создания изображений с текстом разных шрифтов


Пример
align = 'left';
$text1->color = 'FFFFFF';
$text1->font = dirname(__FILE__) . '/Ubuntu-Medium.ttf';
$text1->lineHeight = 36;
$text1->size = 24;
$text1->startX = 40;
$text1->startY = 40;
$image->addText($text1);

// Add another styled text to image
$text2 = new \NMC\ImageWithText\Text('No, really, thanks!', 1, 30);
$text2->align = 'left';
$text2->color = '000000';
$text2->font = dirname(__FILE__) . '/Ubuntu-Medium.ttf';
$text2->lineHeight = 20;
$text2->size = 14;
$text2->startX = 40;
$text2->startY = 140;
$image->addText($text2);

// Render image
$image->render(dirname(__FILE__) . '/destination.jpg');

https://github.com/nmcteam/image-with-text
«
1...456789101112...217
»
Вверх