crovitche/swiss-geo-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

crovitche/swiss-geo-bundle

Composer 安装命令:

composer require crovitche/swiss-geo-bundle

包简介

Import swiss building addresses, streets and localities locally on your MySQL database using Doctrine ORM

README 文档

README

SwissGeoBundle provide you a clean way to use swiss and liechtensteinian building addresses. If you have the following use cases, this bundle can be useful for you :

  • An autocomplete address input without incorrect address entries
  • Store addresses locally (offline !)
    • "I want to locate my clients on a map offline."
  • Create statistics based on addresses:
    • "In which locality do I have the majority of my customers?"
  • Avoid Google Map services and therefore save money
  • Avoid having postal addresses that are no longer valid.
    • "How can this customer live here? This building has been destroyed!"
  • Get some information about addresses:
    • "Is this building partly residential ?"
    • "Is this address on a street or a place?"
    • "Is this address already built or planned ?"
  • ...

Technical requirements

SwissGeoBundle requires the following:

  • MySQL 8.0 or higher (other RDBMS coming soon...) with this options activated:
  • PHP 8.1 or higher
  • Symfony components specified in composer.json
  • Doctrine ORM entities (Doctrine ODM is not supported)
  • Meilisearch v1.5 - Necessary for full address search (performance too low otherwise)
    version: '3.7'
    
    services:
       meilisearch:
           hostname: meilisearch
           image: getmeili/meilisearch:v1.5
           environment:
             - MEILI_ENV=development
             # set the max payload to 200Mb instead of 100 default one
             # addresses file is around 170Mb
             - MEILI_HTTP_PAYLOAD_SIZE_LIMIT=209715200
             - MEILI_NO_ANALYTICS=true
           ports:
             - '7701:7700'
           networks:
             - network
           volumes:
             - meilisearch-data:/data.ms
           restart: unless-stopped

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

composer require crovitche/swiss-geo-bundle

Then make sure the bundle is enabled in registered bundles in config/bundles.php if your application doesn't use Symfony Flex.

Getting started

Run the following commands and put them in a cron if you want your data to be updated regularly.

1. Configure your entity

<?php

declare(strict_types=1);

namespace App\Entity;

use Crovitche\SwissGeoBundle\Entity\BuildingAddress;
use Doctrine\ORM\Mapping as ORM;

//...
#[ORM\Entity(CustomerRepository::class), ORM\Table("Customer")]
#[ORM\Index(columns: ["egaid"], name: "IX___Customer___building_address")]
class Customer
{
    //...
    #[ORM\ManyToOne(BuildingAddress::class)]
    #[ORM\JoinColumn(
        name: "egaid",
        referencedColumnName: "egaid",
        nullable: true,
        onDelete: "SET NULL"
    )]
    private ?BuildingAddress $postalAddress = null;
}

2. Create a database migration.

To do this, you have to use DoctrineMigrationBundle.

Generate a migration using Maker bundle.

php bin/console make:migration

This command will automatically generate the SQL you in a migration php file.

Check the created migration and add this piece of code if it does not exist :

    public function up(Schema $schema): void
    {
        // ...
        $this->addSql(/** @lang MySQL */'
            ALTER TABLE Building_address
                ADD CONSTRAINT CK___Building_address___building_name__xor__address_number
                    CHECK ((building_name IS NOT NULL XOR address_number IS NOT NULL) OR (building_name IS NULL AND address_number IS NULL));
        ');
        // ...
    }

    public function down(Schema $schema): void
    {
        // ...
        $this->addSql(/** @lang MySQL */'
            ALTER TABLE Building_address DROP CONSTRAINT CK___Building_address___building_name__xor__address_number;
        ');
        // ...
    }

    public function isTransactional(): bool
    {
        return false;
    }

3. Execute the migration

php bin/console doctrine:migrations:migrate -n

4. Import data

Note: you can also run the following commands in a cron job so that your data is regularly updated.

4.1 Localities

php bin/console swiss-geo-bundle:import:localities --no-debug

4.2 Streets

php bin/console swiss-geo-bundle:import:streets --no-debug

4.3 Building addresses

php bin/console swiss-geo-bundle:import:building-addresses --no-debug

4.4 Generate/update documents in Meilisearch

php bin/console swiss-geo-bundle:import:meilisearch:documents:generate --no-debug

crovitche/swiss-geo-bundle 适用场景与选型建议

crovitche/swiss-geo-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.15k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「orm」 「doctrine」 「addresses」 「symfony-ux」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 crovitche/swiss-geo-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 crovitche/swiss-geo-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 crovitche/swiss-geo-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2022-10-03