PHPackages                             phine/locator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phine/locator

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

phine/locator
=============

An implementation of the service locator design pattern.

1.1.0(12y ago)020MITPHPPHP &gt;=5.3.3

Since Sep 18Pushed 12y agoCompare

[ Source](https://github.com/kherge-archive/lib-locator)[ Packagist](https://packagist.org/packages/phine/locator)[ Docs](https://github.com/phine/lib-locator)[ RSS](/packages/phine-locator/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Locator
=======

[](#locator)

[![Build Status](https://camo.githubusercontent.com/035fffb9d72fb455f4496505d406ddf0bc6a6879feaad6568c599dbe3528bd83/68747470733a2f2f7472617669732d63692e6f72672f7068696e652f6c69622d6c6f6361746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/phine/lib-locator)[![Coverage Status](https://camo.githubusercontent.com/8dba707b1c51d3f269841c127b3b372b91e4042fd5281a4000e9d9af9e6657c7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f7068696e652f6c69622d6c6f6361746f722f62616467652e706e67)](https://coveralls.io/r/phine/lib-locator)[![Latest Stable Version](https://camo.githubusercontent.com/e5a97fabad2b04430536528e8448823bf0c2d6c570c8781617d9694caffed5f3/68747470733a2f2f706f7365722e707567782e6f72672f7068696e652f6c6f6361746f722f762f737461626c652e706e67)](https://packagist.org/packages/phine/locator)[![Total Downloads](https://camo.githubusercontent.com/6a40e5c2e9a315853013a0d27cf791e5211325ddd79a88addd4233d092a85e03/68747470733a2f2f706f7365722e707567782e6f72672f7068696e652f6c6f6361746f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/phine/locator)

An implementation of the service locator design pattern.

Usage
-----

[](#usage)

```
use Phine\Locator\Locator;
use Phine\Locator\Service\AbstractService;
use Phine\Locator\Service\ResolvableInterface;

/**
 * A service that simply gets returned.
 */
class SimpleService extends AbstractService
{
}

/**
 * A service that causes the locator to return something else.
 */
class ResolvedService extends AbstractService implements ResolvableInterface
{
    /**
     * {@inheritDoc}
     */
    public function getResolvedValue()
    {
        return 'Something else.';
    }
}

// create my locator
$locator = new Locator();

// register my services
$locator->registerService('simple', new SimpleService());
$locator->registerService('resolved', new ResolvedService());

// access my services
echo get_class($locator->getService('simple')); // "SimpleService"
echo $locator->resolveService('resolved'); // "Something else."
```

Array accessible version of above:

```
use Phine\Locator\ArrayLocator;

// create my locator
$locator = new ArrayLocator();

// register my services
$locator['simple'] = new SimpleService();
$locator['resolved'] = new ResolvedService();

// access my services
echo get_class($locator['simple']); // "SimpleService"
echo $locator['resolved']; // "Something else."
```

Examples
--------

[](#examples)

Please see the [wiki](https://github.com/phine/lib-locator/wiki) for examples.

Requirement
-----------

[](#requirement)

- PHP &gt;= 5.3.3
- [Phine Exception](https://github.com/phine/lib-exception) &gt;= 1.0.0

Installation
------------

[](#installation)

Via [Composer](http://getcomposer.org/):

```
$ composer require "phine/locator=~1.0"

```

Documentation
-------------

[](#documentation)

You can find the documentation in the [`docs/`](docs/) directory.

License
-------

[](#license)

This library is available under the [MIT license](LICENSE).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4621d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9122157?v=4)[Kevin Herrera](/maintainers/kherge)[@kherge](https://github.com/kherge)

---

Top Contributors

[![kherge](https://avatars.githubusercontent.com/u/9122157?v=4)](https://github.com/kherge "kherge (29 commits)")

---

Tags

servicelocator

### Embed Badge

![Health badge](/badges/phine-locator/health.svg)

```
[![Health](https://phpackages.com/badges/phine-locator/health.svg)](https://phpackages.com/packages/phine-locator)
```

###  Alternatives

[getsolaris/laravel-make-service

A MVCS pattern create a service command for Laravel 5+

81161.3k](/packages/getsolaris-laravel-make-service)[dynamic/silverstripe-locator

SilverStripe Locator Module. Show locations on a map. Search by geoposition.

2113.2k1](/packages/dynamic-silverstripe-locator)[prevailexcel/laravel-action-service-trait

A simple Laravel package to create actions, traits and services using artisan commands

143.0k](/packages/prevailexcel-laravel-action-service-trait)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
