youwe/pimcore-excelculator

此软件包最新版本(0.1.5)没有可用的许可信息。

安装数: 2,422

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 11

分支: 1

开放问题: 0

类型:pimcore-plugin

0.1.5 2019-02-07 14:02 UTC

This package is auto-updated.

Last update: 2024-09-08 06:52:29 UTC


README

版本: Pimcore 4.x

注意:与 Pimcore 版本低于 4 的不兼容

开发者:Youwe (Roelf)

摘要

  • 是否一直想简单地使用 Excel 表格进行大量计算?
  • 是否需要一个后台服务确保 Excel 表格在需要时随时可用?

...那么这个扩展就是为你准备的!

描述

pimcore 部署扩展具有以下通用功能:

  • 只要服务正在运行,就会提供 Excel 计算结果

用法和示例

在 Pimcore 中启用插件!

运行服务/确保在服务器启动时其正在运行

php ./plugins/PimcoreExcelculator/cli/PimcoreExcelculatorServer.php

尝试测试以确保服务正常工作

php ./plugins/PimcoreExcelculator/cli/PimcoreExcelculatorServerTest.php

配置自己的 Excel 文件(和套接字绑定)以执行计算

cp ./plugins/PimcoreExcelculator/pimcore-excel-config.default.php ./website/var/config/pimcore-excel-config.php
vi ./website/var/config/pimcore-excel-config.php

无错误处理的示例代码

// simple example

$calcey = new \PimcoreExcelculator\PimcoreExcelculatorCalc('included-demo-file');
$calcey->set([
    'A3' => 420,
    'A4' => 246
]);

$results = $calcey->get(['A5']);

echo 'result: ' . var_export($results, true);

有错误处理的示例代码

// you want to catch possible errors, because this functionality
// depends on a service that should be running in the background,
// and there is always the possibility that the service is busy
// or has not been started, or has crashed

$calcey = new \PimcoreExcelculator\PimcoreExcelculatorCalc('included-demo-file');
$calcey->set([
    'A3' => 420,
    'A4' => 246
]);

try {
    $results = $calcey->get(['A5']);
}
catch (\Throwable $t) {
    if($t->getCode() == 888) {
        // could not connect to the service!
    } 
    else {
        // something else is wrong  ( check $t->getMessage() )
    }
}

echo 'result: ' . var_export($results, true);

有错误处理和单个文件中不同工作表的示例代码

$calcey = new \PimcoreExcelculator\PimcoreExcelculatorCalc('some-not-included-file');
$calcey->set([
    'sheetOne.A3' => 420,
    'sheetTwo.A4' => 246
]);

try {
    $results = $calcey->get(['sheetThree.A5', 'sheetFour.C6']);
}
catch (\Throwable $t) {
    if($t->getCode() == 888) {
        // could not connect to the service!
    } 
    else {
        // something else is wrong  ( check $t->getMessage() )
    }
}

echo 'result: ' . var_export($results, true);

部署到服务器

运行服务/确保在服务器启动时其正在运行

php ./plugins/PimcoreExcelculator/cli/PimcoreExcelculatorServer.php

您可以通过 cron 作业来做这件事,例如

*/1 * * * * flock -n /tmp/pimcore.excel.lockfile -c "/usr/bin/php /var/www/html/plugins/PimcoreExcelculator/cli/PimcoreExcelculatorServer.php"

故障排除

在导入定义之前,您可能需要设置正确的权限,以便此脚本能够写入定义文件。在本地开发的情况下,可以使用以下低安全解决方案

sudo chmod -R 777 .

确保您的本地 Apache 以 root 或您的用户身份运行,否则它可能无法连接到服务

在 macOS/OSX 上

in httpd.conf

User my-username
Group _www

or

User root
Group _www

安装

插件可以通过 composer 安装。将以下内容添加到您的 composer.json 中

composer require youwe/pimcore-excelculator

在 pimcore 的 extras->extensions 列表中激活/启用插件。

此外,将其添加到您的 .gitignore

/plugins/PimcoreExcelculator

插件开发

要创建新版本,请检出 master 分支并将其放到某个位置

git tag
git tag 0.x.x         (minor update = latest tag + 0.0.1)
git push origin --tags