PHP code example of sateler / yii2-document
1. Go to this page and download the library: Download sateler/yii2-document 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/ */
sateler / yii2-document example snippets
return [
'controllerMap' => [
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationNamespaces' => [
'sateler\document\migrations',
],
],
],
];
return [
'controllerMap' => [
'documents' => [
'class' => 'sateler\document\controllers\DocumentController',
]
],
];
'documentManager' => [
'class' => \sateler\document\DocumentManager::class,
// Define default filesystem, of none given sql storage is used
'defaultFilesystemId' => 'awsS3',
'filesystems' => [
// A flysystem filesystem config
'awsS3' => [
'class' => AwsS3Filesystem::class,
'bucket' => 'bucket-name',
'region' => 'us-east-1',
'prefix' => 'path',
'key' => 'key',
'secret' => 'secret',
],
],
],
$doc = new Document();
$doc->name = 'filename';
$doc->mime_type = 'mime/type';
$doc->contents = file_get_contents('/path/to/file');
$doc->save();
$doc = Document::findOne($id)
$res = Yii::$app->response;
$res->format = Response::FORMAT_RAW;
$res->setDownloadHeaders($doc->name, $doc->mime_type, true);
$res->data = $doc->contents;
$res->send();