birdsystem / common
Common bundle for Birdsystem
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- symfony/config: ^v5.2.0
- symfony/dependency-injection: ^v5.2.0
- symfony/flex: ^1.10
- symfony/http-client: ^v5.2.0
- symfony/http-kernel: ^v5.2.0
- symfony/yaml: ^5.2
Requires (Dev)
- phpunit/phpunit: ^9.4
- symfony/contracts: ^2.3
- symfony/dotenv: ^v5.2.0
- symfony/framework-bundle: ^5.2
- symfony/phpunit-bridge: ^5.2
- symfony/string: ^5.2
This package is auto-updated.
Last update: 2020-12-04 16:19:56 UTC
README
Purpose
This component contains some common libraries/services used by all micro-services in BirdSystem
Installation
In your composer.json
file, add the following code:
"extra": {
"symfony": {
"endpoint": "https://flex-server.birdsystem.com"
}
}
To do so is to use our own flex-server, so we can use our own private Flex Recipes.
Then require this lib from packagies:
composer require -W birdsystem/common:dev-master
The -W
option is to update all dependencies required by this lib.
Verify Installation
You should be able to see more environment variables being added to your .env file. (This is achived by flex recipes)
In your own micro-service, run
bin/console debug:container birdsystem
If you see some services listed, then it means the installation has been successful.
Usage
To follow the best practice of Symfony Service Container, normally we should mark all our own services as private.
With private services you cannot use $container->get('service_name')
.
Instead, use the service by type-hinting (the following example is to use the Company
micro-service, which is just
a Scoped HttpClient with predefined base_uri):
<?php
namespace App;
use Birdsystem\CommonBundle\MicroServiceClient\Company;
class Test{
public function test(Company $company){
$company->request('GET','/company');
}
}
The above code should send a GET request to http://company/api/company
, because in your .env file there should be a defination of
SERVICE_URL_COMPANY=http://company/api/
Update the recipe
In case we later on added more configurations into the system, and we have updated the recipe, you will need to update it
bin/console recipes:install birdsystem/common --force