Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/giuseppe998e/syringe

Dependency injection library for PHP8
https://github.com/giuseppe998e/syringe

autowired bean component configuration dependencies dependency-injection inject injection injector php php8 php80 php81 provides repository

Last synced: 4 months ago
JSON representation

Dependency injection library for PHP8

Awesome Lists containing this project

README

        

# Syringe
Dependency injection library for PHP8.

## Usage
#### The configuration class:

```php
prepare('SELECT * FROM users WHERE id=?');
$stmt->execute([$id]);
return $stmt->fetch();
}
}

```

#### Initialize Syringe:

```php
addConfiguration(DbConfiguration::class);
// $repo->addConfiguration(OtherConfiguration::class);
Syringe::initialize($repo);

$testClass = Syringe::new(TestClass::class);
$user = $testClass->getUserById(1);
var_dump($user);

// ...
```