我有一个Dockerfile像这样的构建命令:
#install some base extensions
RUN apt-get install -y \
zlib1g-dev \
zip \
&& docker-php-ext-install zip
Run Code Online (Sandbox Code Playgroud)
我从构建输出中收到此警告:
警告:不推荐使用捆绑的libzip,将其删除.
configure:警告:某些功能(如加密和bzip2)不可用.
configure:警告:建议使用系统库和--with-libzip.
在没有这些警告的情况下安装zip扩展的正确方法是什么?
我的完整Dockerfile看起来像:
FROM php:7.2-apache
RUN apt-get clean
RUN apt-get update
#install some basic tools
RUN apt-get install -y \
git \
tree \
vim \
wget \
subversion
#install some base extensions
RUN apt-get install -y \
zlib1g-dev \
zip \
&& docker-php-ext-install zip
#setup composer
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/ …Run Code Online (Sandbox Code Playgroud) 尝试在 ubuntu 19.04 上安装 libzip4 以获取 mysql-workbench 依赖项
安装方法:
sudo apt install ./mysql-workbench-community_8.0.16-1ubuntu18.04_amd64.deb
错误信息:
mysql-workbench-community : Depends: libzip4 (>= 0.10) but it is not installable
apt安装列表:
sudo apt install libzip
libzip5 libzip-dev libzipios++0v5 libzipios++-dev libzipios++-doc libzip-ocaml libzip-ocaml-dev
尝试安装 php-zip 并希望它能安装 libzip4 但失败了!
如果有人能提供很棒的指导,我不确定还有其他方法可以解决这个问题!!
我在我的项目中使用libZip,我成功创建了 zip 文件输出,但我很难为 zip 文件设置密码。
我正在调用zip_set_default_password函数,并且得到了 OK 响应,但是当我尝试提取它时,它并没有要求输入密码。
代码示例:
int CompressWithPassword(const char * psFileContent, int iFileSize, const char * pcPassword)
{
zip_source *psZipSource = NULL;
zip_int64_t iIndex = 0;
int iError = EOK;
const char * pcZipOutputPath = "/home/user/Documents/myzip.zip";
// Open zip file.
m_psZip =
zip_open(pcZipOutputPath,
ZIP_CREATE /*Create the archive if it does not exist*/,
&iError);
// Zip opend ?
if(iError != ZIP_ER_OK)
{
Close();
return iError;
}
// Generate zip source content.
psZipSource =
zip_source_buffer(m_psZip, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 c++ 和 libzip 库解压缩可执行文件。从罗德里戈对类似问题的回答开始,我来到了这个示例代码:
#include <zip.h>
int main()
{
//Open the ZIP archive
int err = 0;
zip *z = zip_open("foo.zip", 0, &err);
//Search for the file of given name
const char *name = "file.txt";
struct zip_stat st;
zip_stat_init(&st);
zip_stat(z, name, 0, &st);
//Alloc memory for its uncompressed contents
char *contents = new char[st.size];
//Read the compressed file
zip_file *f = zip_fopen(z, "file.txt", 0);
zip_fread(f, contents, st.size);
zip_fclose(f);
//And close the archive
zip_close(z);
}
Run Code Online (Sandbox Code Playgroud)
据我了解,这段代码确实可以解压缩文件,但我不知道如何将该文件写入磁盘,就像使用 winzip 这样的工具提取 zip 文件一样。将解压缩的数据放在内存中对我没有帮助,但我一直无法弄清楚如何实际将文件保存到磁盘上。
我正在尝试使用 bzip2 扩展在 mac 上从源代码编译 php,但一直收到错误消息
检查默认路径中是否有 BZip2...未找到
我尝试过设置 LDFLAGS 和 CPPFLAGS 但这似乎不起作用。
dylib 位于/usr/local/opt/bzip2/lib中,头文件位于usr/local/opt/bzip2/include 中。
我正在开发一个使用libzip的项目.我在c ++ 14工作,我在libzip周围写了一个小包装,让我的生活更轻松.
我有一个std::ostream围绕自定义类继承的对象std::streambuf.此streambuf使用libzip函数写入存档中的文件.
一切都很好,直到我使用std::endl.当我这样做时,输出文件被我的所有文本阅读器读取为二进制文件(仅写入字符串).
我的文本阅读器检测到它的二进制文件,因为在我使用的地方std::endl有一个NUL字节,任何带有NUL字节的文件都被视为二进制文件.
所以我的问题是:这是正常的吗?我有办法使用std::endl吗?
我的代码(提取它可能不完全相同).
source.hpp
// my attributes
std::unique_ptr<zip_source_t, std::function<void(zip_source_t*)>> _source;
std::unique_ptr<std::ostream> _stream;
std::unique_ptr<_ZipBuffer> _buffer;
class _ZipBuffer : public std::streambuf {
private:
zip_source_t* _source;
std::streamsize xsputn(char const* s, std::streamsize n) override;
int overflow(int c) override;
public:
_ZipBuffer(zip_source_t* file);
};
Run Code Online (Sandbox Code Playgroud)
source.cpp
// create the streambuf and send it to the ostream
_buffer.reset(new _ZipBuffer(_source.get()));
_stream.reset(new std::ostream(_buffer.get()));
// the implementation of _ZipBuffer
Zip::Source::_ZipBuffer::_ZipBuffer(zip_source_t* source) {
_source = source;
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用libzip在内存中直接创建一个zip文件,而不是在磁盘上创建一个zip文件。目前,我的代码非常基本,因为我无法从zip_source_buffer创建必要的zip_t结构:
#include <stdio.h>
#include <string.h>
#include <zip.h>
int main(int argc, char *arrv[])
{
char buffer[65536] = {};
zip_error_t error;
zip_source_t *zs = zip_source_buffer_create(buffer, sizeof(buffer), 0, &error);
int err = zip_source_begin_write(zs);
printf("%p %d '%s'\n", zs, err, zip_error_strerror(&error));
zip_error_fini(&error);
zip_t * zip = zip_open_from_source(zs, ZIP_CREATE, &error);
printf("%p '%s'\n", zip, zip_error_strerror(&error));
zip_error_fini(&error);
}
Run Code Online (Sandbox Code Playgroud)
代码可以编译并运行,但是会引发错误:
$ ./ztest
0xdd50a0 0 'No error'
(nil) 'Not a zip archive'
Run Code Online (Sandbox Code Playgroud)
尚不清楚是否需要begin_write(),但它不会产生错误,没有它我也会得到相同的结果。
我想念什么?谢谢
我想在我的 docker 镜像上安装 php-zip(最终目标是使用 PhpWord 库)。我使用在 Debian 上运行的 php:7.4-fpm。
在我的 dockerfile 中,我使用以下命令:
RUN apt-get update docker-php-ext-install zip
Run Code Online (Sandbox Code Playgroud)
执行时,脚本崩溃,因为它找不到 /usr/src/php/ext/libzip。
所以我添加了一个很好的旧“apt-get install libzip”,但它找不到包。如果它尝试安装“libzip4”,同样的事情:
checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
No package 'libzip' found
No package 'libzip' found
No package 'libzip' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.
Alternatively, you may set …Run Code Online (Sandbox Code Playgroud) 由于兼容性问题,我使用的是相当旧的 libzip 版本(0.10.1-1.2)。
通常我们通过统计结果来检查文件类型(符号链接、目录、文件等)。类似地,在 libzip 上,我们使用 zip_stat,但其结构不包含文件系统 STAT 中的 ST_MOD 之类的内容。
struct zip_stat {
zip_uint64_t valid; /* which fields have valid values */
const char *name; /* name of the file */
zip_uint64_t index; /* index within archive */
zip_uint64_t size; /* size of file (uncompressed) */
zip_uint64_t comp_size; /* size of file (compressed) */
time_t mtime; /* modification time */
zip_uint32_t crc; /* crc of file data */
zip_uint16_t comp_method; /* compression method used */
zip_uint16_t encryption_method; /* encryption …Run Code Online (Sandbox Code Playgroud) 我想为 PHP 应用程序设置一个基于 docker 的开发环境。该环境应模仿生产服务器。
此应用程序想要导出一个 xlsx 文件并抛出 Fatal error: Class 'ZipArchive' not found in /var/www/html/lib/xlsxwriter.class.php on line 95
在我的 docker 容器中为 PHP 安装 zip 扩展的任何尝试都失败了
#chose the php version here
FROM php:5.4-apache
RUN docker-php-ext-install pdo pdo_mysql mysqli mysql zip
# /sf/ask/3493511591/
# this is for php 7
#RUN yes | pecl install xdebug \
# && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
# && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
# && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini …Run Code Online (Sandbox Code Playgroud)