PHPackages                             regeda/castel - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. regeda/castel

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

regeda/castel
=============

Castel is a fast Dependency Injection Container for PHP 5.3

0.2.0(11y ago)617MITPHPPHP &gt;=5.3.0

Since Mar 18Pushed 11y ago2 watchersCompare

[ Source](https://github.com/regeda/castel)[ Packagist](https://packagist.org/packages/regeda/castel)[ RSS](/packages/regeda-castel/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Castel
======

[](#castel)

Castel is a fast Dependency Injection Container. The class for PHP 5.3 consists of just one file.

[![Build Status](https://camo.githubusercontent.com/7b83d52b050090eb031dfaac8bb3b31d0fb6af77a5d6d605f539fbe2670bc1a6/68747470733a2f2f7472617669732d63692e6f72672f7265676564612f63617374656c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/regeda/castel)

Installing
----------

[](#installing)

Pick up the `src/Castel.php` file or install it with [Composer](https://getcomposer.org/) :

```
{
    "require": {
        "regeda/castel": "0.1.*"
    }
}
```

Creating a container is a matter of instating the Castel class

```
$container = new Castel();
```

Defining parameters
-------------------

[](#defining-parameters)

```
$container->share('foo', 'bar');
$container->share('something', new Something());
```

Retrieving parameters as plain properties:

```
$container->foo; // bar
$container->something; // instance of Something class
```

Defining services
-----------------

[](#defining-services)

Services are defined by anonymous functions that return an instance of an object

```
$container->share('session', function () {
    return new Session();
});
```

Using the defined services

```
$session = $container->session; // instance of Session class
```

Extending services after creation
---------------------------------

[](#extending-services-after-creation)

```
$container->share('mail', function () {
    return new \Zend_Mail();
});
$container->extend('mail', function ($mail, $container) {
    $mail->setFrom($container->getValue('mail.default_from'));
    return $mail;
});
```

Source:

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

3

Last Release

4307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/630d4bd7b2a7fa3f825f13c56434ad6a11c31ad50623a995140b7ee4dc55851a?d=identicon)[regeda](/maintainers/regeda)

---

Tags

containerdependency-injection

### Embed Badge

![Health badge](/badges/regeda-castel/health.svg)

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

356968.3k58](/packages/aura-di)[acclimate/container

Provides adapters for various third-party service containers.

219390.6k15](/packages/acclimate-container)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)

PHPackages © 2026

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