E1.25 Php Symfony Security Step 6: Configure Doctrine for Security Deployment Entities (Wpf, Xamarin, Angular SPA, Reactjs SPA) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki

  • Open the "AspnetdashboardViewEntity.php"-file

picture

At the begining of the file you wil find the following instructions

// ///////////////////////////////////////////////////////////////////////////////
// to create database tables you can apply the following config parameters in the "config/packages/doctrine.yaml"-file
// than create DB tables with the following commands:
//
// php bin/console make:migration --em=aspnetforphpchckdbcontextdeploymanager
// php bin/console doctrine:migrations:migrate --em=aspnetforphpchckdbcontextdeploymanager
//
// or commands:
//
// php bin/console doctrine:migrations:diff --em=aspnetforphpchckdbcontextdeploymanager
// php bin/console doctrine:migrations:migrate --em=aspnetforphpchckdbcontextdeploymanager
//
// ///////////////////////////////////////////////////////////////////////////////
// doctrine:
//    dbal:
//       default_connection: here is a name of default connection (for instance, default_connection: aspnetforphpchckdbcontextdeployconnection)
//
//       connections:
//       ...
//          aspnetforphpchckdbcontextdeployconnection:
//                # configure these for your database server 
//                url: '%env(resolve:DATABASE_ASPNETFORPHPCHCKDBCONTEXT_URL)%'
//                # driver: 'pdo_mysql'
//                # server_version: '5.7'
//                # charset: utf8mb4
//    orm:
//       default_entity_manager: here is a name of default manager (for instance, default_entity_manager: aspnetforphpchckdbcontextdeploymanager)
//
//       entity_managers:
//       ...
//          aspnetforphpchckdbcontextdeploymanager:
//              connection: aspnetforphpchckdbcontextdeployconnection
//              mappings:
//                  Aspnetforphpchckdbcontextdeploy:
//                      is_bundle: false
//                      type: annotation 
//                      dir: '%kernel.project_dir%/src/Deployment/AspNetSecurity'
//                      prefix: 'App\Deployment\AspNetSecurity'
//                      alias: aspnetforphpchckdbcontextdeploymanager  
//
// ///////////////////////////////////////////////////////////////////////////////
// "config/packages/doctrine.yaml"-file  expects ".env"-file to have the following config parameters like below
// ///////////////////////////////////////////////////////////////////////////////
// ...
// ### > doctrine/doctrine-bundle ###
// # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
// # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
// #
// DATABASE_ASPNETFORPHPCHCKDBCONTEXT_URL="mysql://root:[email protected]:3306/schema_name_here?serverVersion=8.0"
// ### < doctrine/doctrine-bundle ###
// ...
// ///////////////////////////////////////////////////////////////////////////////

  • modify "config/packages/doctrine.yaml"-file according to the instructions:
doctrine:
    dbal:
        default_connection: litdbcontextdeployconnection
        connections:
            litdbcontextdeployconnection:
                # configure these for your database server 
                url: '%env(resolve:DATABASE_LITDBCONTEXT_URL)%'
                # driver: 'pdo_mysql'
                # server_version: '5.7'
                # charset: utf8mb4
            litdbcontextconnection:
                # configure these for your database server 
                url: '%env(resolve:DATABASE_LITDBCONTEXT_URL)%'
                # driver: 'pdo_mysql'
                # server_version: '5.7'
                # charset: utf8mb4
            aspnetforphpchckdbcontextdeployconnection:
                # configure these for your database server 
                url: '%env(resolve:DATABASE_ASPNETFORPHPCHCKDBCONTEXT_URL)%'
                # driver: 'pdo_mysql'
                # server_version: '5.7'
                # charset: utf8mb4

    orm:
        default_entity_manager: litdbcontextdeploymanager
        entity_managers:
            litdbcontextdeploymanager:
                connection: litdbcontextdeployconnection
                mappings:
                    Litdbcontextdeploy:
                        is_bundle: false
                        type: annotation 
                        dir: '%kernel.project_dir%/src/Deployment/Literature'
                        prefix: 'App\Deployment\Literature'
                        alias: litdbcontextdeploymanager  
            litdbcontextmanager:
                connection: litdbcontextconnection
                mappings:
                    Litdbcontext:
                        is_bundle: false
                        type: annotation 
                        dir: '%kernel.project_dir%/src/Production/Literature/Entity'
                        prefix: 'App\Production\Literature\Entity'
                        alias: litdbcontextmanager  
            aspnetforphpchckdbcontextdeploymanager:
                connection: aspnetforphpchckdbcontextdeployconnection
                mappings:
                    Aspnetforphpchckdbcontextdeploy:
                        is_bundle: false
                        type: annotation 
                        dir: '%kernel.project_dir%/src/Deployment/AspNetSecurity'
                        prefix: 'App\Deployment\AspNetSecurity'
                        alias: aspnetforphpchckdbcontextdeploymanager  
  • modify ".env"-file according to the instructions:

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_LITDBCONTEXT_URL="mysql://root:[email protected]:3306/litxamarindemo?serverVersion=8.0"
DATABASE_ASPNETFORPHPCHCKDBCONTEXT_URL="mysql://root:[email protected]:3306/aspnet?serverVersion=8.0"
# DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

Note:

With DATABASE_ASPNETFORPHPCHCKDBCONTEXT_URL we defined new schema: aspnet for for the security.