Generate Entities in Symfony with two DB connections - doctrine-orm

I have a project with 2 DB connections (default and routeone). My config is like this:
dbal:
default_connection: routeone
types:
point: ACME\Infrastructure\Resources\Types\PointType
connections:
default:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
routeone:
driver: pdo_mysql
host: "%database_routeone_host%"
port: "%database_routeone_port%"
dbname: "%database_routeone_name%"
user: "%database_routeone_user%"
password: "%database_routeone_password%"
charset: UTF8
mapping_types:
enum: string
point: point
orm:
default_entity_manager: routeone
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
ACME:
type: yml
dir: '%kernel.root_dir%/../src/ACME/Infrastructure/Resources/doctrine'
is_bundle: false
prefix: ACME\Domain\Entity
alias: ACME
routeone:
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
mappings:
RouteOne:
type: yml
dir: '%kernel.root_dir%/../src/ACME/Infrastructure/Resources/doctrine/RouteOne'
is_bundle: false
prefix: RouteOne
alias: RouteOne
I have the control of the default connection, but no the routeone. I cannot change the structure of the existing DB in routeone.
When I generate the YML configuration files with this this command (NB I have put momentarily the routeone connection as a default):
php bin/console doctrine:mapping:convert yml ./src/ACME/Infrastructure/Resources/doctrine/Routeone/ --from-database
This generate a files in this path like that: AclClass.orm.yml
AclClass:
type: entity
table: acl_class
....
But when I want to generate Entities Class with this command:
php bin/console doctrine:generate:entities src/ACME/Infrastructure/Resources/doctrine/RouteOne/ --path=src/ACME/Domain/Entity/RouteOne/
Prompt this error:
[Doctrine\Common\Persistence\Mapping\MappingException]
No mapping file found named 'AclClass.orm.yml' for class 'ACME\Domain\Entity\RouteOne\AclClass'.
What I'm doing wrong?

Related

Mapping problem with Symfony 4 and Doctrine 2 on multiple schemas

I'm working on rewriting an old plain PHP bad written app with Symfony 4.4 and Doctrine 2.12. Due to the number of databases (5) and the XXL size of them (at least 50 tables per database with often more than 100 columns) I had to generate entities from reverse engineering. Here is my Doctrine configuration.
doctrine:
dbal:
connections:
fire:
url: '%env(resolve:FIRE_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair:
url: '%env(resolve:LECLAIR_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair_vad:
url: '%env(resolve:LECLAIR_VAD_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair_int:
url: '%env(resolve:LECLAIR_INT_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair_mobi:
url: '%env(resolve:LECLAIR_MOBI_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
orm:
default_entity_manager: leclair
auto_generate_proxy_classes: true
entity_managers:
fire:
connection: fire
mappings:
Fire:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Fire'
prefix: 'App\Entity\Fire'
alias: Fire
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair:
connection: leclair
mappings:
Leclair:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Leclair'
prefix: 'App\Entity\Leclair'
alias: Leclair
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair_vad:
connection: leclair_vad
mappings:
LeclairVad:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/LeclairVad'
prefix: 'App\Entity\LeclairVad'
alias: LeclairVad
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair_int:
connection: leclair_int
mappings:
LeclairInt:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/LeclairInt'
prefix: 'App\Entity\LeclairInt'
alias: LeclairInt
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair_mobi:
connection: leclair_mobi
mappings:
LeclairMobi:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/LeclairMobi'
prefix: 'App\Entity\LeclairMobi'
alias: LeclairMobi
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
The problem is that if I set a default_entity_manager Doctrine is confused with entities from the first and second namespaces (Fire and Leclair) despite I see no error in my configuration.
For instance when trying to call a TblParaImp entity from 'Fire' namespace (while default_entity_manager=leclair is configured) I get errors like
[Doctrine\Persistence\Mapping\MappingException]
The class 'App\Entity\Fire\TblParaImp' was not found in the chain configured namespaces Ap
p\Entity\Leclair
or like
[Doctrine\Persistence\Mapping\MappingException]
The class 'App\Entity\Leclair\TImports' was not found in the chain configured namespaces App
\Entity\Fire
when trying to call a TImports entity from 'Leclair' namespace while default_entity_manager=fire is configured.
So I wonder what I missed in my configuration. Does anybody see where the error is ? Or at least tell me how to dump/debug Doctrine mapping, I couldn't find a way to do this.
Thanks a lot for any help or information.
Cheers

Error creating peer channel Amazon Managed Blockchain Hyperledger Fabric v1.4

I hope someone could help me with the following problem.
I am using Amazon Managed Blockchain with the framework Hyperledge Fabric v1.4 and I followed this documentation https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/get-started-create-channel.html.
This is the error I get when I try to create the channel with that command line:
Command line:
docker exec cli peer channel create -c mychannel -f /opt/home/mychannel.pb -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls
Error:
2022-01-17 10:34:47.356 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: got unexpected status: BAD_REQUEST -- error validating channel creation transaction for new channel 'mychannel', could not succesfully apply update to template configuration: error authorizing update: error validating DeltaSet: policy for [Group] /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied
The admin certificate is in a folder "admin-msp".
My configxt.yaml (I did not get any error executing a previous step with "docker exec cli configtxgen -outputCreateChannelTx /opt/home/mychannel.pb -profile OneOrgChannel -channelID mychannel --configPath /opt/home/"):
Organizations:
- &Org1
Name: m-Q37N3LRUKNFDXBZ7GARMYFBYIE
ID: m-Q37N3LRUKNFDXBZ7GARMYFBYIE
Policies: &Org1Policies
Readers:
Type: Signature
Rule: "OR('Org1.member')"
# If your MSP is configured with the new NodeOUs, you might
# want to use a more specific rule like the following:
# Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')"
Writers:
Type: Signature
Rule: "OR('Org1.member')"
# If your MSP is configured with the new NodeOUs, you might
# want to use a more specific rule like the following:
# Rule: "OR('Org1.admin', 'Org1.client')"
Admins:
Type: Signature
Rule: "OR('Org1.admin')"
# MSPDir is the filesystem path which contains the MSP configuration.
MSPDir: /opt/home/admin-msp
# AnchorPeers defines the location of peers which can be used for
# cross-org gossip communication. Note, this value is only encoded in
# the genesis block in the Application section context.
AnchorPeers:
- Host: 127.0.0.1
Port: 7051
Capabilities:
Channel: &ChannelCapabilities
V1_4_3: true
V1_3: false
V1_1: false
Orderer: &OrdererCapabilities
V1_4_2: true
V1_1: false
Application: &ApplicationCapabilities
V1_4_2: true
V1_3: false
V1_2: false
V1_1: false
Channel: &ChannelDefaults
Policies:
# Who may invoke the 'Deliver' API
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
# Who may invoke the 'Broadcast' API
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
# By default, who may modify elements at this config level
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ChannelCapabilities
Application: &ApplicationDefaults
Policies: &ApplicationDefaultPolicies
LifecycleEndorsement:
Type: ImplicitMeta
Rule: "ANY Readers"
Endorsement:
Type: ImplicitMeta
Rule: "ANY Readers"
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ApplicationCapabilities
Profiles:
OneOrgChannel:
<<: *ChannelDefaults
Consortium: AWSSystemConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *Org1
My docker-compose-cli.yaml file:
version: '2'
services:
cli:
container_name: cli
image: hyperledger/fabric-tools:1.4
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- FABRIC_LOGGING_SPEC=info # Set logging level to debug for more verbose logging
- CORE_PEER_ID=cli
- CORE_CHAINCODE_KEEPALIVE=10
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem
- CORE_PEER_LOCALMSPID=$Member
- CORE_PEER_MSPCONFIGPATH=/opt/home/admin-msp
- CORE_PEER_ADDRESS=$MyPeerNodeEndpoint
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- /home/ec2-user/fabric-samples/chaincode:/opt/gopath/src/github.com/
- /home/ec2-user:/opt/home
Thanks in advance :).

Doctrine2 multiple entity managers, no restrictions in between them

I need to use 2 different entity managers, as I need to run $em->clear(); for performance reason - batching of inserts.
My config.yml contains
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
options:
1001: true
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
errorlog:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
AppBundle:
type: yml
dir: Entity
is_bundle: true
prefix: AppBundleEntity
alias: AppBundleEntity
However I'm still getting an error
[Doctrine\ORM\ORMException]
Unknown Entity namespace alias 'AppBundle'.
From looking at other questions, it seems entities need to be separated into different folders at least. Is this the only solution to use different entity managers in the same bundle?
As per #Cerad s comment, this works:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
options:
1001: true
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
AppBundle: ~
errorlog:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
AppBundle: ~

Test Kitchen, store credentials

With Test Kitchen, in the yaml configs... where is the best place to store globally used attributes that apply to multiple platforms and multiple suites?
To use my .kitchen.yml as an example:
---
provisioner:
name: chef_solo
platforms:
- name: centos-6.5
driver:
name: vagrant
- name: amazon
driver:
name: ec2
image_id: ami-ed8e9284
flavor_id: t2.medium
aws_ssh_key_id: <snip>
ssh_key: <snip>
availability_zone: us-east-1a
subnet_id: subnet-<snip>
require_chef_omnibus: true
iam_profile_name: <snip>
ebs_delete_on_termination: true
security_group_ids: sg-<snip>
# area in question (does not work here)
attributes:
teamcity:
server: 'build.example.com'
port: 80
username: 'example'
password: 'example'
# end area in question
suites:
- name: resin4
run_list:
- recipe[example_server::resin4]
- recipe[example_server::deploy_all_artifacts]
- name: deploy
run_list:
- recipe[example_server::deploy_all_artifacts]
- name: default
run_list:
- recipe[example_server::elasticsearch]
- recipe[example_server::resin4]
- recipe[example_server::deploy_all_artifacts]
I know there are other kitchen files, such as ~/kitchen/config.yml and .kitchen.local.yml but I've been unable to find a away to get attributes to apply to all platforms and suites. Is copy and pasting attributes to platforms the best way?
Is there a reason to specify these attributes in kitchen's yaml and not recipe[example_server::deploy_all_artifacts]? If necessary you could set overrides in kitchen.
Also, this post might be helpful: Access Attributes Across Recipes

how to install bootstrap in symfony2?

I installed bootstrap through this link
But when I run
php app/console server:run
To check if it is working it returns an error.
The error is
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Invalid configuration for path "assetic.filters.file":
The assetic.filters
config "C:/wamp/www/bootstrap/app/../vendor/leafo/lessphp/lessc.in
c.php" must be either null or an array.
How to remove this exception?
here is my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: %kernel.debug%
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
# Twig Configuration
twig:
form:
resources:
- "AcmeBundle:Form:form_div_layout.html.twig"
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
bc_bootstrap:
assets_dir: %kernel.root_dir%/../vendor/twitter/bootstrap
jquery_path: %kernel.root_dir%/../vendor/jquery/jquery/jquery-1.9.1.js
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
The indentation is important in yml files.
file and apply_to should be with 4 more spaces.