定制 glance-project/locations-service 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

glance-project/locations-service

Composer 安装命令:

composer require glance-project/locations-service

包简介

Experiment-agnostic SDK for retrieving office locations across GLANCE instances

README 文档

README

PHP CI Coverage Packagist License

Experiment-agnostic office location retrieval SDK for PHP 8.2+.

Overview

locations-service provides a stable, reusable API for querying office locations and their usage attributes across GLANCE deployments. It is designed as a layered library with strict domain modeling and an SQL adapter based on Doctrine DBAL.

The package exposes one application entry point, LocationsProvider, which supports:

  • listing by experiment
  • listing by current-use code
  • lookup by location id
  • lookup by exact address
  • fuzzy search by address fragment

Etymology

The name reflects its role in the GLANCE ecosystem: a dedicated service-style library that encapsulates location domain logic and infrastructure concerns behind a compact provider API.

Stack

LayerToolVersion
LanguagePHP^8.2
Data accessDoctrine DBAL^4.2
Unit testsPHPUnit^10
Static analysisPsalm^5
Coding standardPHP_CodeSniffer^3.6 (PSR-12)
CI/CDGitLab CI-
Package registryPackagist-

Architecture follows the same Domain / Application / Infrastructure layering used in the ALICE GLANCE suite:

src/
├── Domain/                    # Value objects, entity, repository contract, exceptions
│   ├── Exception/
│   ├── Address.php
│   ├── Capacity.php
│   ├── CurrentUse.php
│   ├── Experiment.php
│   ├── FloorType.php
│   ├── Height.php
│   ├── IntendedUse.php
│   ├── IntegerId.php
│   ├── Location.php
│   ├── LocationId.php
│   ├── LocationRepository.php
│   ├── PersonId.php
│   ├── PhysicalCharacteristics.php
│   ├── SurfaceArea.php
│   └── Usage.php
├── Application/               # Use-case oriented query facade
│   └── LocationsProvider.php
└── Infrastructure/            # Driver config, factory, DI bindings, SQL adapter
	├── LocationsProviderConfig.php
	├── LocationsProviderFactory.php
	├── LocationsServiceDependencies.php
	└── Sql/
		├── SqlLocation.php
		├── SqlLocationsProviderConfig.php
		└── SqlLocationsRepository.php

Installation

composer require glance-project/locations-service

Usage

Standalone

use Glance\LocationsService\Application\LocationsProvider;
use Glance\LocationsService\Domain\Experiment;
use Glance\LocationsService\Infrastructure\LocationsProviderFactory;
use Glance\LocationsService\Infrastructure\Sql\SqlLocationsProviderConfig;

$config = SqlLocationsProviderConfig::create(
	username: 'my-user',
	password: 'my-password',
	dns: 'MY_ORACLE_SERVICE'
);

$factory = LocationsProviderFactory::create();
$provider = $factory->getInstance($config);

$aliceLocations = $provider->listLocationsByExperiment(Experiment::alice());
$atlasLocations = $provider->listLocationsByExperiment(Experiment::atlas());
$lhcbLocations = $provider->listLocationsByExperiment(Experiment::lhcb());
$cmsLocations = $provider->listLocationsByExperiment(Experiment::cms());

With a PSR-11 DI Container (php-di)

use DI\ContainerBuilder;
use Glance\LocationsService\Application\LocationsProvider;
use Glance\LocationsService\Infrastructure\LocationsProviderConfig;
use Glance\LocationsService\Infrastructure\LocationsServiceDependencies;
use Glance\LocationsService\Infrastructure\Sql\SqlLocationsProviderConfig;

$builder = new ContainerBuilder();

// Default package bindings (configuration from environment variables).
$builder->addDefinitions(LocationsServiceDependencies::definitions());

// Optional override to control config source.
$builder->addDefinitions([
	LocationsProviderConfig::class => static fn(): SqlLocationsProviderConfig =>
		SqlLocationsProviderConfig::fromArray([
			'username' => $_ENV['LOCATIONS_DB_USERNAME'] ?? 'user',
			'password' => $_ENV['LOCATIONS_DB_PASSWORD'] ?? 'password',
			'dns' => $_ENV['LOCATIONS_DB_DSN'] ?? 'MY_ORACLE_SERVICE',
		]),
]);

$container = $builder->build();
$provider = $container->get(LocationsProvider::class);

LocationsServiceDependencies::definitions() returns plain closure factories and remains compatible with any PSR-11 container workflow.

Locations Data

The service retrieves location data from CERN's central office locations database. Visit their documentation for details on the data model and maintenance. This SDK is designed to be resilient to changes in the underlying database schema, but breaking changes may require updates to the SQL adapter layer.

You may need to coordinate with the locations database administrators to ensure your database user has the necessary permissions to access the relevant views and that any schema changes are communicated in advance.

Environment Variables

The SQL adapter configuration can be provided through environment variables:

  • LOCATIONS_DB_USERNAME: Database username that has read access to the locations views
  • LOCATIONS_DB_PASSWORD: Database password for the above user
  • LOCATIONS_DB_DSN: Database DSN (e.g., cerndb1) for the Oracle service hosting the locations database

SQL Model

The SQL adapter joins two views under schema AISPUB:

  • LOC_CL_CUR_LOCAL_INFO: physical attributes
  • LOC_CL_CUR_GESLOC_ROOMS: usage attributes

Selected columns are mapped through SqlLocation into the domain aggregate Location.

Make sure the database user has read access to these views and that the column names match the expected schema for correct mapping.

Domain Model

Location Aggregate root representing one office location, composed of:

  • LocationId id
  • PhysicalCharacteristics physicalCharacteristics
  • Usage usage

PhysicalCharacteristics Immutable value object containing location physical data:

  • Address address
  • IntendedUse intendedUse
  • ?string comment
  • ?Height height
  • SurfaceArea surfaceArea
  • ?SurfaceArea windowSurfaceArea
  • ?FloorType floorType

Usage Immutable value object containing occupancy/organizational data:

  • Experiment experiment
  • CurrentUse currentUse
  • bool isMailboxAvailable
  • ?string organicUnit
  • ?Capacity capacity
  • ?PersonId responsible
  • ?string shortComment

Core value objects:

  • Address: {BUILDING}/{FLOOR}-{ROOM} format
  • Experiment: constrained list (alice, atlas, lhcb, cms)
  • CurrentUse: controlled code list with display names
  • IntendedUse: controlled intended-use labels
  • Height: meters and feet conversion helper
  • SurfaceArea: square meters and square feet conversion helper
  • FloorType: controlled floor-type labels
  • Capacity: non-negative integer value
  • LocationId, PersonId: typed integer identifiers

Repository contract:

  • findLocationById(LocationId): ?Location
  • findLocationByAddress(Address): ?Location
  • findLocationsByExperiment(Experiment): Location[]
  • findLocationsByCurrentUse(CurrentUse): Location[]
  • searchLocationsByAddress(string): Location[]

Running Locally

# Install dependencies
composer install

# Run tests
composer run test:unit

# Static analysis
composer run test:types

# Coding standard
composer run test:lint

# Auto-fix coding standard
composer run fix:lint

Coverage (requires Xdebug coverage mode):

XDEBUG_MODE=coverage composer run test:ci

Contributing

  1. Branch naming: feature/short-description or fix/short-description
  2. Commit style: prefer the project convention with a gitmoji prefix
  3. Quality gates: test:unit, test:types, and test:lint must pass before merge
  4. Coverage: CI target is at least 95% line coverage

Project Links

ResourceURL
GitLab repositoryhttps://gitlab.cern.ch/fence/common/locations-service
Packagist packagehttps://packagist.org/packages/glance-project/locations-service
CERN GitLabhttps://gitlab.cern.ch

glance-project/locations-service 适用场景与选型建议

glance-project/locations-service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 312 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 glance-project/locations-service 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-03-18