作者 梁鹏山

服务器与git建立通信

正在显示 328 个修改的文件 包含 753 行增加2 行删除
  1 +<?php
  2 +
  3 +return [
  4 + 'Item_id' => '项目id',
  5 + 'Images' => '图片',
  6 + 'Details' => '详情',
  7 + 'Is_sift' => '是否为精选',
  8 + 'Is_sift 0' => '否',
  9 + 'Is_sift 1' => '是',
  10 + 'Createtime' => '创建时间',
  11 + 'Updatetime' => '更新时间',
  12 + 'Item.title' => '名称'
  13 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Item_id' => '项目id',
  5 + 'Images' => '图片',
  6 + 'Details' => '详情',
  7 + 'Is_sift' => '是否为精选',
  8 + 'Is_sift 0' => '否',
  9 + 'Is_sift 1' => '是',
  10 + 'Createtime' => '创建时间',
  11 + 'Updatetime' => '更新时间',
  12 + 'Item.title' => '名称'
  13 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Campus_id' => '校区id',
  5 + 'Ronda_id' => '场次id',
  6 + 'Item_id' => '项目id',
  7 + 'Createtime' => '创建时间',
  8 + 'Updatetime' => '更新时间'
  9 +];
  1 +<?php
  2 +
  3 +namespace app\admin\validate\item;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Details extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\api\controller;
  4 +
  5 +
  6 +use app\common\controller\Api;
  7 +
  8 +/**
  9 + * 定时任务
  10 + * @ApiWeigh (94)
  11 + */
  12 +class Crontab extends Api
  13 +{
  14 + protected $noNeedLogin = ['*'];
  15 + protected $noNeedRight = ['*'];
  16 +
  17 +
  18 + /**
  19 + * @ApiTitle (首页)
  20 + */
  21 + public function index(){
  22 + $res = db('study')->field('earn_score')->select();
  23 + function sort($res){
  24 + $len = count($res);
  25 + for ($i = 0; $i < $len - 1; $i++) {//循环比对的轮数
  26 + for ($j = 0; $j < $len - $i - 1; $j++) {//当前轮相邻元素循环对比
  27 + if ($res[$j] < $res[$j + 1]) {//如果前边的小于后边的
  28 + $tmp = $res[$j];//交换数据
  29 + $res[$j] = $res[$j + 1];
  30 + $res[$j + 1] = $tmp;
  31 + }
  32 + }
  33 + }
  34 + return $res;
  35 + }
  36 + $this->success('',sort($res));
  37 + }
  38 +}
@@ -41,5 +41,5 @@ return array ( @@ -41,5 +41,5 @@ return array (
41 'category2' => 'Category2', 41 'category2' => 'Category2',
42 'custom' => 'Custom', 42 'custom' => 'Custom',
43 ), 43 ),
44 - 'privacy_policy' => '<p><img src="http://campus.cn/uploads/20230307/e7ab2a28f4cb819fd6536ce7381583a9.png"/></p><p>用户:在手机、平板电脑、电脑等注册成为平台(以下简称“平台”或“平台方”)的使用者,通过平台发布、查看、接收图文/音频/视频信息或其他文件,或与其他用户进行延时/实时交流的用户(以下简称“用户”)。</p>', 44 + 'privacy_policy' => '<p><img src="http://rramxwmk1.hb-bkt.clouddn.com/uploads/20230310/e7ab2a28f4cb819fd6536ce7381583a9.png"/></p><p>用户:在手机、平板电脑、电脑等注册成为平台(以下简称“平台”或“平台方”)的使用者,通过平台发布、查看、接收图文/音频/视频信息或其他文件,或与其他用户进行延时/实时交流的用户(以下简称“用户”)。</p>',
45 ); 45 );
  1 +<?php
  2 +
  3 +// +----------------------------------------------------------------------
  4 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  5 +// +----------------------------------------------------------------------
  6 +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  7 +// +----------------------------------------------------------------------
  8 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  9 +// +----------------------------------------------------------------------
  10 +// | Author: liu21st <liu21st@gmail.com>
  11 +// +----------------------------------------------------------------------
  12 +// [ 后台入口文件 ]
  13 +// 使用此文件可以达到隐藏admin模块的效果
  14 +// 为了你的安全,强烈不建议将此文件名修改成admin.php
  15 +// 定义应用目录
  16 +define('APP_PATH', __DIR__ . '/../application/');
  17 +
  18 +// 判断是否安装
  19 +if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) {
  20 + header("location:./install.php");
  21 + exit;
  22 +}
  23 +
  24 +// 加载框架引导文件
  25 +require __DIR__ . '/../thinkphp/base.php';
  26 +
  27 +// 绑定到admin模块
  28 +\think\Route::bind('admin');
  29 +
  30 +// 关闭路由
  31 +\think\App::route(false);
  32 +
  33 +// 设置根url
  34 +\think\Url::root('');
  35 +
  36 +// 执行应用
  37 +\think\App::run()->send();
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 // | Author: liu21st <liu21st@gmail.com> 9 // | Author: liu21st <liu21st@gmail.com>
10 // +---------------------------------------------------------------------- 10 // +----------------------------------------------------------------------
11 11
12 -define('THINK_VERSION', '5.0.24'); 12 +define('THINK_VERSION', '5.0.25');
13 define('THINK_START_TIME', microtime(true)); 13 define('THINK_START_TIME', microtime(true));
14 define('THINK_START_MEM', memory_get_usage()); 14 define('THINK_START_MEM', memory_get_usage());
15 define('EXT', '.php'); 15 define('EXT', '.php');
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<phive xmlns="https://phar.io/phive">
  3 + <phar name="phpdocumentor" version="^3.3.1" installed="3.3.1" location="./tools/phpdocumentor" copy="false"/>
  4 +</phive>
  1 +<?php
  2 +
  3 +declare(strict_types=1);
  4 +
  5 +/**
  6 + * PHP-CS-Fixer config for ZipStream-PHP
  7 + * @author Nicolas CARPi <nico-git@deltablot.email>
  8 + * @copyright 2022 Nicolas CARPi
  9 + * @see https://github.com/maennchen/ZipStream-PHP
  10 + * @license MIT
  11 + * @package maennchen/ZipStream-PHP
  12 + */
  13 +
  14 +use PhpCsFixer\Config;
  15 +use PhpCsFixer\Finder;
  16 +
  17 +$finder = Finder::create()
  18 + ->exclude('.github')
  19 + ->exclude('.phpdoc')
  20 + ->exclude('docs')
  21 + ->exclude('tools')
  22 + ->exclude('vendor')
  23 + ->in(__DIR__);
  24 +
  25 +$config = new Config();
  26 +return $config->setRules([
  27 + '@PER' => true,
  28 + '@PER:risky' => true,
  29 + '@PHP81Migration' => true,
  30 + '@PHPUnit84Migration:risky' => true,
  31 + 'array_syntax' => ['syntax' => 'short'],
  32 + 'class_attributes_separation' => true,
  33 + 'declare_strict_types' => true,
  34 + 'dir_constant' => true,
  35 + 'is_null' => true,
  36 + 'no_homoglyph_names' => true,
  37 + 'no_null_property_initialization' => true,
  38 + 'no_php4_constructor' => true,
  39 + 'no_unused_imports' => true,
  40 + 'no_useless_else' => true,
  41 + 'non_printable_character' => true,
  42 + 'ordered_imports' => true,
  43 + 'ordered_class_elements' => true,
  44 + 'php_unit_construct' => true,
  45 + 'pow_to_exponentiation' => true,
  46 + 'psr_autoloading' => true,
  47 + 'random_api_migration' => true,
  48 + 'return_assignment' => true,
  49 + 'self_accessor' => true,
  50 + 'semicolon_after_instruction' => true,
  51 + 'short_scalar_cast' => true,
  52 + 'simplified_null_return' => true,
  53 + 'single_blank_line_before_namespace' => true,
  54 + 'single_class_element_per_statement' => true,
  55 + 'single_line_comment_style' => true,
  56 + 'single_quote' => true,
  57 + 'space_after_semicolon' => true,
  58 + 'standardize_not_equals' => true,
  59 + 'strict_param' => true,
  60 + 'ternary_operator_spaces' => true,
  61 + 'trailing_comma_in_multiline' => true,
  62 + 'trim_array_spaces' => true,
  63 + 'unary_operator_spaces' => true,
  64 + 'global_namespace_import' => [
  65 + 'import_classes' => true,
  66 + 'import_functions' => true,
  67 + 'import_constants' => true,
  68 + ],
  69 + ])
  70 + ->setFinder($finder)
  71 + ->setRiskyAllowed(true);
  1 +{% extends 'layout.html.twig' %}
  2 +
  3 +{% set topMenu = {
  4 + "menu": [
  5 + { "name": "Guides", "url": "https://maennchen.dev/ZipStream-PHP/guide/index.html"},
  6 + { "name": "API", "url": "https://maennchen.dev/ZipStream-PHP/classes/ZipStream-ZipStream.html"},
  7 + { "name": "Issues", "url": "https://github.com/maennchen/ZipStream-PHP/issues"},
  8 + ],
  9 + "social": [
  10 + { "iconClass": "fab fa-github", "url": "https://github.com/maennchen/ZipStream-PHP"},
  11 + { "iconClass": "fas fa-envelope-open-text", "url": "https://github.com/maennchen/ZipStream-PHP/discussions"},
  12 + { "iconClass": "fas fa-money-bill", "url": "https://opencollective.com/zipstream"},
  13 + ]
  14 +}
  15 +%}
  1 +Adding Content-Length header
  2 +=============
  3 +
  4 +Adding a ``Content-Length`` header for ``ZipStream`` is not trivial since the
  5 +size is not known beforehand.
  6 +
  7 +The following workaround adds an approximated header:
  8 +
  9 +.. code-block:: php
  10 +
  11 + class Zip
  12 + {
  13 + /** @var string */
  14 + private $name;
  15 +
  16 + private $files = [];
  17 +
  18 + public function __construct($name)
  19 + {
  20 + $this->name = $name;
  21 + }
  22 +
  23 + public function addFile($name, $data)
  24 + {
  25 + $this->files[] = ['type' => 'addFile', 'name' => $name, 'data' => $data];
  26 + }
  27 +
  28 + public function addFileFromPath($name, $path)
  29 + {
  30 + $this->files[] = ['type' => 'addFileFromPath', 'name' => $name, 'path' => $path];
  31 + }
  32 +
  33 + public function getEstimate()
  34 + {
  35 + $estimate = 22;
  36 + foreach ($this->files as $file) {
  37 + $estimate += 76 + 2 * strlen($file['name']);
  38 + if ($file['type'] === 'addFile') {
  39 + $estimate += strlen($file['data']);
  40 + }
  41 + if ($file['type'] === 'addFileFromPath') {
  42 + $estimate += filesize($file['path']);
  43 + }
  44 + }
  45 + return $estimate;
  46 + }
  47 +
  48 + public function finish()
  49 + {
  50 + header('Content-Length: ' . $this->getEstimate());
  51 + $options = new \ZipStream\Option\Archive();
  52 + $options->setSendHttpHeaders(true);
  53 + $options->setEnableZip64(false);
  54 + $options->setDeflateLevel(-1);
  55 + $zip = new \ZipStream\ZipStream($this->name, $options);
  56 +
  57 + $fileOptions = new \ZipStream\Option\File();
  58 + $fileOptions->setMethod(\ZipStream\Option\Method::STORE());
  59 + foreach ($this->files as $file) {
  60 + if ($file['type'] === 'addFile') {
  61 + $zip->addFile($file['name'], $file['data'], $fileOptions);
  62 + }
  63 + if ($file['type'] === 'addFileFromPath') {
  64 + $zip->addFileFromPath($file['name'], $file['path'], $fileOptions);
  65 + }
  66 + }
  67 + $zip->finish();
  68 + exit;
  69 + }
  70 + }
  71 +
  72 +It only works with the following constraints:
  73 +
  74 +- All file content is known beforehand.
  75 +- Content Deflation is disabled
  76 +
  77 +Thanks to
  78 +`partiellkorrekt <https://github.com/maennchen/ZipStream-PHP/issues/89#issuecomment-1047949274>`_
  79 +for this workaround.
  1 +Usage with FlySystem
  2 +===============
  3 +
  4 +For saving or uploading the generated zip, you can use the
  5 +`Flysystem <https://flysystem.thephpleague.com>`_ package, and its many
  6 +adapters.
  7 +
  8 +For that you will need to provide another stream than the ``php://output``
  9 +default one, and pass it to Flysystem ``putStream`` method.
  10 +
  11 +.. code-block:: php
  12 +
  13 + // Open Stream only once for read and write since it's a memory stream and
  14 + // the content is lost when closing the stream / opening another one
  15 + $tempStream = fopen('php://memory', 'w+');
  16 +
  17 + // Init Options
  18 + $zipStreamOptions = new Archive();
  19 + $zipStreamOptions->setOutputStream($tempStream);
  20 +
  21 + // Create Zip Archive
  22 + $zipStream = new ZipStream('test.zip', $zipStreamOptions);
  23 + $zipStream->addFile('test.txt', 'text');
  24 + $zipStream->finish();
  25 +
  26 + // Store File (see Flysystem documentation, and all its framework integration)
  27 + $adapter = new Local(__DIR__.'/path/to/folder'); // Can be any adapter (AWS, Google, Ftp, etc.)
  28 + $filesystem = new Filesystem($adapter);
  29 +
  30 + $filesystem->putStream('test.zip', $tempStream)
  31 +
  32 + // Close Stream
  33 + fclose($tempStream);
  1 +Usage with nginx
  2 +=============
  3 +
  4 +If you are using nginx as a webserver, it will try to buffer the response.
  5 +So you'll want to disable this with a custom header:
  6 +
  7 +.. code-block:: php
  8 + header('X-Accel-Buffering: no');
  9 + # or with the Response class from Symfony
  10 + $response->headers->set('X-Accel-Buffering', 'no');
  11 +
  12 +Alternatively, you can tweak the
  13 +`fastcgi cache parameters <https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffers>`_
  14 +within nginx config.
  15 +
  16 +See `original issue <https://github.com/maennchen/ZipStream-PHP/issues/77>`_.
  1 +Available options
  2 +===============
  3 +
  4 +Here is the full list of options available to you. You can also have a look at
  5 +``src/Option/Archive.php`` file.
  6 +
  7 +First, an instance of ``ZipStream\Option\Archive`` needs to be created, and
  8 +after that you use setters methods to modify the values.
  9 +
  10 +.. code-block:: php
  11 + use ZipStream\ZipStream;
  12 + use ZipStream\Option\Archive as ArchiveOptions;
  13 +
  14 + require_once 'vendor/autoload.php';
  15 +
  16 + $opt = new ArchiveOptions();
  17 +
  18 + // Define output stream (argument is of type resource)
  19 + $opt->setOutputStream($fd);
  20 +
  21 + // Set the deflate level (default is 6; use -1 to disable it)
  22 + $opt->setDeflateLevel(6);
  23 +
  24 + // Add a comment to the zip file
  25 + $opt->setComment('This is a comment.');
  26 +
  27 + // Size, in bytes, of the largest file to try and load into memory (used by addFileFromPath()). Large files may also be compressed differently; see the 'largeFileMethod' option.
  28 + $opt->setLargeFileSize(30000000);
  29 +
  30 + // How to handle large files. Legal values are STORE (the default), or DEFLATE. Store sends the file raw and is significantly faster, while DEFLATE compresses the file and is much, much slower. Note that deflate must compress the file twice and is extremely slow.
  31 + $opt->setLargeFileMethod(ZipStream\Option\Method::STORE());
  32 + $opt->setLargeFileMethod(ZipStream\Option\Method::DEFLATE());
  33 +
  34 + // Send http headers (default is false)
  35 + $opt->setSendHttpHeaders(false);
  36 +
  37 + // HTTP Content-Disposition. Defaults to 'attachment', where FILENAME is the specified filename. Note that this does nothing if you are not sending HTTP headers.
  38 + $opt->setContentDisposition('attachment');
  39 +
  40 + // Set the content type (does nothing if you are not sending HTTP headers)
  41 + $opt->setContentType('application/x-zip');
  42 +
  43 + // Set the function called for setting headers. Default is the `header()` of PHP
  44 + $opt->setHttpHeaderCallback('header');
  45 +
  46 + // Enable streaming files with single read where general purpose bit 3 indicates local file header contain zero values in crc and size fields, these appear only after file contents in data descriptor block. Default is false. Set to true if your input stream is remote (used with addFileFromStream()).
  47 + $opt->setZeroHeader(false);
  48 +
  49 + // Enable reading file stat for determining file size. When a 32-bit system reads file size that is over 2 GB, invalid value appears in file size due to integer overflow. Should be disabled on 32-bit systems with method addFileFromPath if any file may exceed 2 GB. In this case file will be read in blocks and correct size will be determined from content. Default is true.
  50 + $opt->setStatFiles(true);
  51 +
  52 + // Enable zip64 extension, allowing very large archives (> 4Gb or file count > 64k)
  53 + // default is true
  54 + $opt->setEnableZip64(true);
  55 +
  56 + // Flush output buffer after every write
  57 + // default is false
  58 + $opt->setFlushOutput(true);
  59 +
  60 + // Now that everything is set you can pass the options to the ZipStream instance
  61 + $zip = new ZipStream('example.zip', $opt);
  1 +Usage with PSR 7 Streams
  2 +===============
  3 +
  4 +PSR-7 streams are `standardized streams <https://www.php-fig.org/psr/psr-7/>`_.
  5 +
  6 +ZipStream-PHP supports working with these streams with the function
  7 +``addFileFromPsr7Stream``.
  8 +
  9 +For all parameters of the function see the API documentation.
  10 +
  11 +Example
  12 +---------------
  13 +
  14 +.. code-block:: php
  15 +
  16 + $stream = $response->getBody();
  17 + // add a file named 'streamfile.txt' from the content of the stream
  18 + $zip->addFileFromPsr7Stream('streamfile.txt', $stream);
  1 +Stream Output
  2 +===============
  3 +
  4 +Stream to S3 Bucket
  5 +---------------
  6 +
  7 +.. code-block:: php
  8 + use Aws\S3\S3Client;
  9 + use Aws\Credentials\CredentialProvider;
  10 + use ZipStream\Option\Archive;
  11 + use ZipStream\ZipStream;
  12 +
  13 + $bucket = 'your bucket name';
  14 + $client = new S3Client([
  15 + 'region' => 'your region',
  16 + 'version' => 'latest',
  17 + 'bucketName' => $bucket,
  18 + 'credentials' => CredentialProvider::defaultProvider(),
  19 + ]);
  20 + $client->registerStreamWrapper();
  21 +
  22 + $zipFile = fopen("s3://$bucket/example.zip", 'w');
  23 +
  24 + $options = new Archive();
  25 + $options->setEnableZip64(false);
  26 + $options->setOutputStream($zipFile);
  27 +
  28 + $zip = new ZipStream(null, $options);
  29 + $zip->addFile('file1.txt', 'File1 data');
  30 + $zip->addFile('file2.txt', 'File2 data');
  31 + $zip->finish();
  32 +
  33 + fclose($zipFile);
  1 +Usage with Symfony
  2 +===============
  3 +
  4 +Overview for using ZipStream in Symfony
  5 +--------
  6 +
  7 +Using ZipStream in Symfony requires use of Symfony's ``StreamedResponse`` when
  8 +used in controller actions.
  9 +
  10 +Wrap your call to the relevant ``ZipStream`` stream method (i.e. ``addFile``,
  11 +``addFileFromPath``, ``addFileFromStream``) in Symfony's ``StreamedResponse``
  12 +function passing in any required arguments for your use case.
  13 +
  14 +Using Symfony's ``StreamedResponse`` will allow Symfony to stream output from
  15 +ZipStream correctly to users' browsers and avoid a corrupted final zip landing
  16 +on the users' end.
  17 +
  18 +Example for using ``ZipStream`` in a controller action to zip stream files
  19 +stored in an AWS S3 bucket by key:
  20 +
  21 +.. code-block:: php
  22 +
  23 + use Symfony\Component\HttpFoundation\StreamedResponse;
  24 + use Aws\S3\S3Client;
  25 + use ZipStream;
  26 +
  27 + //...
  28 +
  29 + /**
  30 + * @Route("/zipstream", name="zipstream")
  31 + */
  32 + public function zipStreamAction()
  33 + {
  34 + //sample test file on s3
  35 + $s3keys = array(
  36 + "ziptestfolder/file1.txt"
  37 + );
  38 +
  39 + $s3Client = $this->get('app.amazon.s3'); //s3client service
  40 + $s3Client->registerStreamWrapper(); //required
  41 +
  42 + //using StreamedResponse to wrap ZipStream functionality for files on AWS s3.
  43 + $response = new StreamedResponse(function() use($s3keys, $s3Client)
  44 + {
  45 + // Define suitable options for ZipStream Archive.
  46 + $options = new \ZipStream\Option\Archive();
  47 + $options->setContentType('application/octet-stream');
  48 + // this is needed to prevent issues with truncated zip files
  49 + $options->setZeroHeader(true);
  50 + $options->setComment('test zip file.');
  51 +
  52 + //initialise zipstream with output zip filename and options.
  53 + $zip = new ZipStream\ZipStream('test.zip', $options);
  54 +
  55 + //loop keys - useful for multiple files
  56 + foreach ($s3keys as $key) {
  57 + // Get the file name in S3 key so we can save it to the zip
  58 + //file using the same name.
  59 + $fileName = basename($key);
  60 +
  61 + //concatenate s3path.
  62 + $bucket = 'bucketname'; //replace with your bucket name or get from parameters file.
  63 + $s3path = "s3://" . $bucket . "/" . $key;
  64 +
  65 + //addFileFromStream
  66 + if ($streamRead = fopen($s3path, 'r')) {
  67 + $zip->addFileFromStream($fileName, $streamRead);
  68 + } else {
  69 + die('Could not open stream for reading');
  70 + }
  71 + }
  72 +
  73 + $zip->finish();
  74 +
  75 + });
  76 +
  77 + return $response;
  78 + }
  79 +
  80 +In the above example, files on AWS S3 are being streamed from S3 to the Symfon
  81 +application via ``fopen`` call when the s3Client has ``registerStreamWrapper``
  82 +applied. This stream is then passed to ``ZipStream`` via the
  83 +``addFileFromStream`` function, which ZipStream then streams as a zip to the
  84 +client browser via Symfony's ``StreamedResponse``. No Zip is created server
  85 +side, which makes this approach a more efficient solution for streaming zips to
  86 +the client browser especially for larger files.
  87 +
  88 +For the above use case you will need to have installed
  89 +`aws/aws-sdk-php-symfony <https://github.com/aws/aws-sdk-php-symfony>`_ to
  90 +support accessing S3 objects in your Symfony web application. This is not
  91 +required for locally stored files on you server you intend to stream via
  92 +``ZipStream``.
  93 +
  94 +See official Symfony documentation for details on
  95 +`Symfony's StreamedResponse <https://symfony.com/doc/current/components/http_foundation.html#streaming-a-response>`_
  96 +``Symfony\Component\HttpFoundation\StreamedResponse``.
  97 +
  98 +Note from `S3 documentation <https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-stream-wrapper.html>`_:
  99 +
  100 + Streams opened in "r" mode only allow data to be read from the stream, and
  101 + are not seekable by default. This is so that data can be downloaded from
  102 + Amazon S3 in a truly streaming manner, where previously read bytes do not
  103 + need to be buffered into memory. If you need a stream to be seekable, you
  104 + can pass seekable into the stream context options of a function.
  105 +
  106 +Make sure to configure your S3 context correctly!
  107 +
  108 +Uploading a file
  109 +--------
  110 +
  111 +You need to add correct permissions
  112 +(see `#120 <https://github.com/maennchen/ZipStream-PHP/issues/120>`_)
  113 +
  114 +**example code**
  115 +
  116 +
  117 +.. code-block:: php
  118 +
  119 + $path = "s3://{$adapter->getBucket()}/{$this->getArchivePath()}";
  120 +
  121 + // the important bit
  122 + $outputContext = stream_context_create([
  123 + 's3' => ['ACL' => 'public-read'],
  124 + ]);
  125 +
  126 + fopen($path, 'w', null, $outputContext);
  1 +Usage with Varnish
  2 +=============
  3 +
  4 +Serving a big zip with varnish in between can cause random stream close.
  5 +This can be solved by adding attached code to the vcl file.
  6 +
  7 +To avoid the problem, add the following to your varnish config file:
  8 +
  9 +.. code-block::
  10 + sub vcl_recv {
  11 + # Varnish can’t intercept the discussion anymore
  12 + # helps for streaming big zips
  13 + if (req.url ~ "\.(tar|gz|zip|7z|exe)$") {
  14 + return (pipe);
  15 + }
  16 + }
  17 + # Varnish can’t intercept the discussion anymore
  18 + # helps for streaming big zips
  19 + sub vcl_pipe {
  20 + set bereq.http.connection = "close";
  21 + return (pipe);
  22 + }
  1 +ZipStream PHP
  2 +=============
  3 +
  4 +A fast and simple streaming zip file downloader for PHP. Using this library will
  5 +save you from having to write the Zip to disk. You can directly send it to the
  6 +user, which is much faster. It can work with S3 buckets or any PSR7 Stream.
  7 +
  8 +.. toctree::
  9 +
  10 + index
  11 + Symfony
  12 + Options
  13 + StreamOutput
  14 + FlySystem
  15 + PSR7Streams
  16 + Nginx
  17 + Varnish
  18 + ContentLength
  19 +
  20 +Installation
  21 +---------------
  22 +
  23 +Simply add a dependency on ``maennchen/zipstream-php`` to your project's
  24 +``composer.json`` file if you use Composer to manage the dependencies of your
  25 +project. Use following command to add the package to your project's dependencies:
  26 +
  27 +.. code-block:: sh
  28 + composer require maennchen/zipstream-php
  29 +
  30 +Usage Intro
  31 +---------------
  32 +
  33 +Here's a simple example:
  34 +
  35 +.. code-block:: php
  36 +
  37 + // Autoload the dependencies
  38 + require 'vendor/autoload.php';
  39 +
  40 + // enable output of HTTP headers
  41 + $options = new ZipStream\Option\Archive();
  42 + $options->setSendHttpHeaders(true);
  43 +
  44 + // create a new zipstream object
  45 + $zip = new ZipStream\ZipStream('example.zip', $options);
  46 +
  47 + // create a file named 'hello.txt'
  48 + $zip->addFile('hello.txt', 'This is the contents of hello.txt');
  49 +
  50 + // add a file named 'some_image.jpg' from a local file 'path/to/image.jpg'
  51 + $zip->addFileFromPath('some_image.jpg', 'path/to/image.jpg');
  52 +
  53 + // add a file named 'goodbye.txt' from an open stream resource
  54 + $fp = tmpfile();
  55 + fwrite($fp, 'The quick brown fox jumped over the lazy dog.');
  56 + rewind($fp);
  57 + $zip->addFileFromStream('goodbye.txt', $fp);
  58 + fclose($fp);
  59 +
  60 + // finish the zip stream
  61 + $zip->finish();
  62 +
  63 +You can also add comments, modify file timestamps, and customize (or
  64 +disable) the HTTP headers. It is also possible to specify the storage method
  65 +when adding files, the current default storage method is ``DEFLATE``
  66 +i.e files are stored with Compression mode 0x08.
  67 +
  68 +Known Issues
  69 +---------------
  70 +
  71 +The native Mac OS archive extraction tool prior to macOS 10.15 might not open
  72 +archives in some conditions. A workaround is to disable the Zip64 feature with
  73 +the option ``enableZip64: false``. This limits the archive to 4 Gb and 64k files
  74 +but will allow users on macOS 10.14 and below to open them without issue.
  75 +See `#116 <https://github.com/maennchen/ZipStream-PHP/issues/146>`_.
  76 +
  77 +The linux ``unzip`` utility might not handle properly unicode characters.
  78 +It is recommended to extract with another tool like
  79 +`7-zip <https://www.7-zip.org/>`_.
  80 +See `#146 <https://github.com/maennchen/ZipStream-PHP/issues/146>`_.
  81 +
  82 +It is the responsability of the client code to make sure that files are not
  83 +saved with the same path, as it is not possible for the library to figure it out
  84 +while streaming a zip.
  85 +See `#154 <https://github.com/maennchen/ZipStream-PHP/issues/154>`_.
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<phpdocumentor
  3 + configVersion="3"
  4 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5 + xmlns="https://www.phpdoc.org"
  6 + xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/master/data/xsd/phpdoc.xsd"
  7 +>
  8 + <title>ZipStream-PHP</title>
  9 + <paths>
  10 + <output>docs</output>
  11 + </paths>
  12 + <version number="3.0.0">
  13 + <folder>latest</folder>
  14 + <api>
  15 + <source dsn=".">
  16 + <path>src</path>
  17 + </source>
  18 + <output>api</output>
  19 + <ignore hidden="true" symlinks="true">
  20 + <path>tests/**/*</path>
  21 + <path>vendor/**/*</path>
  22 + </ignore>
  23 + <extensions>
  24 + <extension>php</extension>
  25 + </extensions>
  26 + <visibility>public</visibility>
  27 + <default-package-name>ZipStream</default-package-name>
  28 + <include-source>true</include-source>
  29 + </api>
  30 + <guide>
  31 + <source dsn=".">
  32 + <path>guides</path>
  33 + </source>
  34 + <output>guide</output>
  35 + </guide>
  36 + </version>
  37 + <setting name="guides.enabled" value="true"/>
  38 + <template name="default" />
  39 +</phpdocumentor>
  1 +<?php
  2 +
  3 +if (\PHP_VERSION_ID < 80000 && !interface_exists('Stringable')) {
  4 + interface Stringable
  5 + {
  6 + /**
  7 + * @return string
  8 + */
  9 + public function __toString();
  10 + }
  11 +}