glance-project/locations-service
Composer 安装命令:
composer require glance-project/locations-service
包简介
Experiment-agnostic SDK for retrieving office locations across GLANCE instances
README 文档
README
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
| Layer | Tool | Version |
|---|---|---|
| Language | PHP | ^8.2 |
| Data access | Doctrine DBAL | ^4.2 |
| Unit tests | PHPUnit | ^10 |
| Static analysis | Psalm | ^5 |
| Coding standard | PHP_CodeSniffer | ^3.6 (PSR-12) |
| CI/CD | GitLab CI | - |
| Package registry | Packagist | - |
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 viewsLOCATIONS_DB_PASSWORD: Database password for the above userLOCATIONS_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 attributesLOC_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 idPhysicalCharacteristics physicalCharacteristicsUsage usage
PhysicalCharacteristics
Immutable value object containing location physical data:
Address addressIntendedUse intendedUse?string comment?Height heightSurfaceArea surfaceArea?SurfaceArea windowSurfaceArea?FloorType floorType
Usage
Immutable value object containing occupancy/organizational data:
Experiment experimentCurrentUse currentUsebool isMailboxAvailable?string organicUnit?Capacity capacity?PersonId responsible?string shortComment
Core value objects:
Address:{BUILDING}/{FLOOR}-{ROOM}formatExperiment: constrained list (alice,atlas,lhcb,cms)CurrentUse: controlled code list with display namesIntendedUse: controlled intended-use labelsHeight: meters and feet conversion helperSurfaceArea: square meters and square feet conversion helperFloorType: controlled floor-type labelsCapacity: non-negative integer valueLocationId,PersonId: typed integer identifiers
Repository contract:
findLocationById(LocationId): ?LocationfindLocationByAddress(Address): ?LocationfindLocationsByExperiment(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
- Branch naming:
feature/short-descriptionorfix/short-description - Commit style: prefer the project convention with a gitmoji prefix
- Quality gates:
test:unit,test:types, andtest:lintmust pass before merge - Coverage: CI target is at least 95% line coverage
Project Links
| Resource | URL |
|---|---|
| GitLab repository | https://gitlab.cern.ch/fence/common/locations-service |
| Packagist package | https://packagist.org/packages/glance-project/locations-service |
| CERN GitLab | https://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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 312
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-03-18