PHPackages                             rehmat/service-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. rehmat/service-locator

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

rehmat/service-locator
======================

A simple dependency injection library for php

2.0.0(1y ago)773PHPPHP ^5.3.3 || ^8.0

Since Apr 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/RehmatFalcon/PHP-SERVICE-LOCATOR)[ Packagist](https://packagist.org/packages/rehmat/service-locator)[ RSS](/packages/rehmat-service-locator/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

PHP-SERVICE-LOCATOR
===================

[](#php-service-locator)

A simple and light weight Dependency Injection library for PHP projects.

\##Requires composer autoloading

\#How to use?

In your php code, make sure to require composer's autoload

```
require 'vendor/autoload.php';
```

You have to import the Rehmat\\ServiceLocator\\ServiceLocator namespace

```
use Rehmat\ServiceLocator\ServiceLocator;
//instantiate ServiceLocator
$serviceLocator = ServiceLocator::getInstance();

//add configuration through which ServiceLocator can locate the factory to create your desired classes
// the ::class is required for retrieving the Fully Qualified Class Name (FQCN)
$serviceLocator->register(MyClassInterface::class, MyClassFactory::class, 'prod' );

```

The first parameter is the class that we want to register, the second parameter is the factory that we want to use when locating our class, the third parameter is used as a mode, while retrieving our class, if same class is registered twice but under different mode, the mode we specify takes precedence.

```
$myClassObj = $serviceLocator->create(MyClassInterface::class, 'prod');

```

Or, you can use our config reader and do it in a much quicker way.

```
//change this line to use ConfigReader too
use Rehmat\ServiceLocator\{ServiceLocator, ConfigReader};

$configs = [
	'prod'	=> [
		MyClassInterface::class => MyClassFactory::class
	]
];

(new ConfigReader())->fromArray($configs);

```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance46

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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 ~520 days

Recently: every ~650 days

Total

6

Last Release

409d ago

Major Versions

V1.34 → 2.0.02025-05-17

PHP version history (2 changes)v1.0PHP ^5.3.3 || ^7.0

2.0.0PHP ^5.3.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c5c4d9de4fa8c81976e85886cebbd876e2a11e1d80a8ee061b5974dca79e2ac?d=identicon)[RehmatFalcon](/maintainers/RehmatFalcon)

---

Top Contributors

[![niroula-kushal](https://avatars.githubusercontent.com/u/28915667?v=4)](https://github.com/niroula-kushal "niroula-kushal (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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