承接 spiriitlabs/poliris-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

spiriitlabs/poliris-bundle

最新稳定版本:v1.0.0

Composer 安装命令:

composer require spiriitlabs/poliris-bundle

包简介

Poliris bundle for CSV

README 文档

README

This bundle provide Poliris generation CSV.

Poliris Current version is V4.1.17.

Latest Stable Version CI Tests CI Tests

Installation

Add spiriitlabs/poliris-bundle to your composer.json file:

$ php composer.phar require "spiriitlabs/poliris-bundle"

Documentation

📚 Complete Documentation

The documentation provides:

  • 🚀 Detailed getting started tutorial
  • 🎯 Illustrated use cases (SeLoger, photos, automation)
  • 📊 Model reference tables
  • 🔧 Common error solutions
  • 💡 Complete and tested code examples

How to use

A CSV Poliris is very long. More than 333 columns.

Here we propose to use the pattern Builder to create it.

Some classes:

The Column class represents a position in a CSV file by associating an index with a value:

$column1 = new Column(1, 'Agence id'); // a string
$column2 = new Column(2, true); // OUI / NON
$column2 = new Column(2, new \DateTimeImmutable('2023-05-01')); // format d/m/Y
$column2 = new Column(2, object); // return toString on object
$column2 = new Column(2, 1); // 1 

If a string is used, we remove spaces and EOL.

Exemple:

beautiful  house
with garage

is transformed into:

beautiful house with garage

After that we have a lot of classes, exemple "Exterieur"

If we look at the constructor:

    public function __construct(
        $ascenseur,
        $calme,
        $piscine,
        $vueDegagee,
        $entree,
        $visAVis,
        $monteCharge
    ) {
        $this->ascenseur = new Column(41, $ascenseur);
        $this->calme = new Column(63, $calme);
        $this->piscine = new Column(65, $piscine);
        $this->vueDegagee = new Column(78, $vueDegagee);
        $this->entree = new Column(189, $entree);
        $this->visAVis = new Column(192, $visAVis);
        $this->monteCharge = new Column(197, $monteCharge);
    }

In this example, the CSV file contains data about Exterior features of a property, which are not sequentially arranged in consecutive columns. To simplify the handling of this data, we decided to consolidate them using the Column class.

Each property is represented by an instance of Column, where the index specifies the column position in the CSV file, and the value holds the associated data. This approach allows for easier access to the exterior features of the property, even if they are scattered throughout the CSV file.

There is 31 classes. models

Usage

$builder = new AnnonceExportBuilder();

foreach ($lines as $line) {
    try {
        $this->createLine($builder, $line);
    } catch (\Throwable $throwable) {
        // log
    }
}

return $builder->build();
function createLine() {
    $builder
        ->startLine()
        ->withIdentifiant(
            'somewhere',
            'agence_id',
            Annonce::ANNONCE_TYPE_VENTE,
            'REF_BA123'
        )
        ->withType(
            getType(),
            getSubType()
        )

Important - No validation

There is no validation on the data. Why? A CSV file can have several thousand rows, multiplied by approximately 300 columns, and PHP struggles to keep up.

Historically, there were validation classes using the Validator component, but it is too memory-intensive.

One solution would be to batch process the CSV and validate only a few rows at a time. However, that is not currently on the agenda.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-16