PHPackages                             crodas/service-provider - 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. crodas/service-provider

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

crodas/service-provider
=======================

Little configuration manager and dependency injection

v0.1.32(10y ago)24.2k↓83.3%4BSD-4-ClausePHP

Since Oct 27Pushed 10y ago2 watchersCompare

[ Source](https://github.com/crodas/ServiceProvider)[ Packagist](https://packagist.org/packages/crodas/service-provider)[ RSS](/packages/crodas-service-provider/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (6)Versions (36)Used By (4)

ServiceProvider
===============

[](#serviceprovider)

Little configuration manager and dependency injection.

It is an attempt to build a simple library to define services, and how to consume them. A *service* is a configurable resource that is consumed by our software, think of it as a `mysql_connect` resource, where you can have different configuration for you local and production environment.

A service can be defined using annotations.

```
/**
 *  @Service(mysql, {
 *    host: {default:"localhost", type: string},
 *    user: {default:"root", type: string},
 *    pass: {default:"", type: string},
 *    port: {default: 3306, type: integer},
 *    db: {type: string},
 *  })
 */
function get_mysql_service(Array $config)
{
    return new mysqli(
      $config['host'],
      $config['user'],
      $config['pass'],
      $config['db'],
      $config['port']
    );
}
```

That's it, we just defined a service which in a reallity it is a function or method which returns something. In its annotation we defined its name and their configuration validation.

When you want to get access to the mysql service

```
$service = new \ServiceProvider\Provider(
  'production.config.yml',  // the configuration file
  'where/services/are/defined/',  // where the files are defined.  It can use * comodin
  'production.generated.php' // to improve things we generate code, here is where to save it
);
$db = $service->get('mysql');
$db->query("SELECT * FROM users");
```

Events
------

[](#events)

As a bonus this library support events triggering/handling the right way. Basically at generation time it would look for `@EventSubscriber(, [=0])` over a method or function. To trigger an event is very simple:

```
$service = new \ServiceProvider\Provider(
  'production.config.yml',  // the configuration file
  'where/services/are/defined/',  // where the files are defined.  It can use * comodin
  'production.generated.php' // to improve things we generate code, here is where to save it
);

$events = $service->get('event_manager');
$result = $events->trigger('foo.bar', array('arg1' => 'foo'));
var_dump('this event had ' . $result->getCalls() . ' handlers');
```

And somewhere in the code

```
/**
 *  @EventSubscriber(foo.bar)
 */
function some_handler($event)
{
    $args = $event->getArguments();
    $event->stopPropagation(); /* I'm the last one */
}
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

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

Recently: every ~69 days

Total

33

Last Release

3843d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36463?v=4)[C](/maintainers/crodas)[@crodas](https://github.com/crodas)

---

Top Contributors

[![crodas](https://avatars.githubusercontent.com/u/36463?v=4)](https://github.com/crodas "crodas (191 commits)")

### Embed Badge

![Health badge](/badges/crodas-service-provider/health.svg)

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

###  Alternatives

[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.3M976](/packages/phpro-grumphp)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

292943.4k27](/packages/craftcms-feed-me)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49517.1k](/packages/blackfire-player)[altis/local-server

Local Server module for Altis

18217.0k2](/packages/altis-local-server)

PHPackages © 2026

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