Skip to content

Prioritized Profiles and ContainerFactory improvements #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Composer (Annotated Container)
run: composer install
- name: Composer (Static Analysis Tools)
- name: Composer (Code Linting)
run: cd tools/labrador-cs && composer install
- name: Code Linting
run: phpcs -q --standard=./tools/labrador-cs/vendor/cspray/labrador-coding-standard/ruleset.xml --exclude=Generic.Files.LineLength --report=checkstyle src test | cs2pr
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A Dependency Injection framework for creating an autowired, feature-rich, [PSR-1
- Use Profiles to easily use different services in different runtimes
- Create type-safe, highly flexible configuration objects
- Easily include third-party services that cannot be easily annotated
- Bring Your Own Container!
- Support for a variety of different Dependency Injection containers

## Quick Start

Expand Down Expand Up @@ -70,18 +70,18 @@ Be sure to review the generated configuration! A "normal" Composer setup might r

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<annotatedContainer xmlns="https://annotated-container.cspray.io/schema/annotated-container.xsd">
<annotatedContainer xmlns="https://annotated-container.cspray.io/schema/annotated-container.xsd" version="3.0">
<scanDirectories>
<source>
<dir>src</dir>
<dir>tests</dir>
</source>
</scanDirectories>
<cacheDir>.annotated-container-cache</cacheDir>
</annotatedContainer>
```

Now, bootstrap your Container in your app.
Now, bootstrap your Container in your app. In this example, we're going to assume that you
have `php-di/php-di` installed.

```php
<?php declare(strict_types=1);
Expand All @@ -92,16 +92,17 @@ require __DIR__ . '/vendor/autoload.php';
use Cspray\AnnotatedContainer\Bootstrap\Bootstrap;
use Cspray\AnnotatedContainer\Event\Emitter;
use Cspray\AnnotatedContainer\Profiles;
use Cspray\AnnotatedContainer\ContainerFactory\PhpDiContainerFactory;

$emitter = new Emitter();

// Add whatever Listeners are required for your application

// Include other active profiles in this list
// If the only active profile is default you can call this method without any arguments
$container = Bootstrap::from($emitter)->bootstrapContainer(
Profiles::fromList(['default'])
);
$container = Bootstrap::fromAnnotatedContainerConventions(
new PhpDiContainerFactory($emitter), $emitter
)->bootstrapContainer(Profiles::fromList(['default']));

$storage = $container->get(BlobStorage::class); // instanceof FilesystemStorage
```
Expand Down
Loading
Loading