I use two self developed libraries located in github as a private repository so I can reuse it in several projects. I include them via composer:
"license": "proprietary",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/my-account/puc-web-sap-client.git",
"options": {
"ssl": {
"verify_peer": "false"
}
}
},
{
"type": "vcs",
"url": "https://github.com/my-account/puc-web-soap-client.git",
"options": {
"ssl": {
"verify_peer": "false"
}
}
}
],
Now symfony complains that the classes and services cannot be found. My first question is: Why are they not autoloaded like other classes from libraries symfony is using e.g. swiftmailer, phpmd, diablomedia/prettyprinter ? All are libraries, which are not by default part of symfony.
However other answers here said, that I have to add the services manually in my services.yaml Symfony4 use external class library as a service
So I added loads of services from my library to the services.yaml file:
Puc\SapClient\:
resource: '../vendor/puc/sap-client/src/*'
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscriber
public: true
Puc\SapClient\Country\CountrySapServiceInterface:
alias: Puc\SapClient\Country\CountrySapService
Puc\SapClient\Country\CountryService:
autowire: true
Puc\SapClient\Currency\CurrencyService:
autowire: true
Puc\SapClient\House\HouseService:
autowire: true
Puc\SapClient\Ressort\RessortService:
autowire: true
Puc\SapClient\Country\CountrySapService:
autowire: true
Puc\SapClient\Currency\CurrencySapService:
autowire: true
....
now php bin/console debug:autowiring gives me the following error:
Cannot autowire service "Puc\SapClient\Model\Currency": argument "$currencyIsoCode" of method "__construct()" is type-hinted "string", you should configure its value explicitly.
Well Currency is a Model and not a service. It is filled with values by my library and given back to my main app. This is the constructor:
public function __construct(
string $currencyIsoCode,
string $name,
string $ident,
int $numberOfDecimals
) {
$this->currencyIsoCode = $currencyIsoCode;
$this->name = $name;
$this->sapIdent = $ident;
$this->numberOfDecimals = $numberOfDecimals;
}
How can I configure this model to use strings? where do I do it? Do I really have to declare each and every single class my library is using? To define each parameter of each class?