E1.07 Php Symfony development process cycle (Wpf, Xamarin, Angular SPA, Reactjs SPA) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki

The Wizard to generate php code

Only "# 4 Wpf Forms Wizard" will be used to generate php code.

Reminder 1:

Normally "# 4 Wpf Forms Wizard" is used to create Client App only.

Reminder 2:

"ViewModel"-term is used in the current docset. We want to remind the meaning of this term. Given an entity.

  • ViewModel is a subset of scalar properties of the current entity and all direct and indirect master entities.
  • In terms of SQL, ViewModel is a SQL VIEW.
  • View (or ViewModel) is the structure that the Web Api service (or Microservice) sends to and receives from the client. For each entity, the developer must create at least one view.

Reminder 3:

Wpf Forms Wizard can be used only after runing "#2 ModelView Wizard" and "#3 WebApiServices Wizard"

  • With "#2 ModelView Wizard" we define the ViewModels. But our setting can be saved to Wizard Rrepository only after generating and saving ViewModel for the given Entity.
  • With "#3 WebApiServices Wizard" we define which method to generate (insert/update/delete/select witth filter) and we define the names of the WebApi Services. And again our setting can be saved to Wizard Rrepository only after generating and saving ViewModel for the given Entity.

Reminder 4:

"#2 ModelView Wizard" works only with "C# Entity Framework (EF)" classes (i.e. Entities and DbContext).

Conclusion:

Before generating php code we must generate C#-code, which is a code for the primary platform. More over, Entity Framework was used as a modeling tool. From the point of view of php developer it is a big disadvantage. Of course, we can say that without Client App (Wpf or Xamarin) generated php code is not so useful. But really, at the very begining we do not plan to work under php-subprojects at all. On the other hand, EF was chosen as the starting point for modeling because of the "dotnet ef"-tool. With the "Database First" approach, using dotnet ef, we can quickly generate all the code for the DbContext and Entities. With the "Model First" approach, we already have everything we need. That was why we decided to use EF as a modeling tool.

After philosophy, let us formulate the Php development process cycle.

Php development process cycle

  • Create Entities which are Entity Framework classes
  • With "#1 DBContext Wizard" generate Dbcontext which is Entity Framework class
  • With "#2 ModelView Wizard" generate ViewModels which are C# classes
  • With "#3 WebApiServices Wizard" generate WebApi services which are C# classes
    • Note 1:
      • If you do not plan to use "Entity Framework" classes, C# ViewModels and C# WebApi please create simple console app and generate the code into the folders of that app.
    • Note 2:
      • Do not worry about Client App. Client App has its own copies of ViewModels and do not reference classes of the WebApi-project.
  • Run MS Visual Studio
  • with MS Visual Studio Open solution with a Clien App
  • with MS Visual Studio choose menu item "Add/Existing Web Site"
    • select "src"-folder of the php-project
  • with MS Visual Studio Create "deployment"-subfolder under "src"-folder of the php-project
  • with MS Visual Studio right click "deployment"-subfolder and choose menu item "Add/Wpf Forms Wizard"
  • with "Wpf Forms Wizard" select ViewModel you need
  • with "Wpf Forms Wizard" for selected ViewModel execute the script
    • "01140-Entity.php/Entity.Doctrine.php.t4"
  • save generated "*Entity.php" file
    • the generated file will be used by "Doctrine"-db-migration tool
  • close "Wpf Forms Wizard"
  • open generated php-file
    • at the begining of the file you will find an instructions of how to configure doctrine entity manager and connection for deployment
  • with MS Visual Studio Create "production/entity"-subfolder under "src"-folder of the php-project
    • you can replace "production" with "ultimate" or "main" or something else that does not match the word "deployment". Any way the classes of this folder (we mean "production"/"ultimate"/"main"-folder) will be used by generated controllers.
    • never use "src/entity" folder directly. "src/entity"-folder will be used by security classes
  • with MS Visual Studio Create "production/pagination"-subfolder under "src"-folder of the php-project
    • you can replace "production" with "ultimate" or "main" or something else that does not match the word "deployment". Any way the classes of this folder (we mean "production"/"ultimate"/"main"-folder) will be used by generated controllers.
    • never use "src/entity" folder directly. "src/entity"-folder will be used by security classes(for instance, "src/entity"-folder will contain security "User"-class)
  • with MS Visual Studio right click "production/entity"-subfolder and choose menu item "Add/Wpf Forms Wizard"
  • with "Wpf Forms Wizard" select the same ViewModel
  • with "Wpf Forms Wizard" for selected ViewModel execute the scripts
    • "01142-EntityUpd.php/EntityUpd.Doctrine.php.t4"
    • "01144-EntitySel.php/EntitySel.Doctrine.php.t4"
    • "01146-EntityTotal.php/EntityTotal.Doctrine.php.t4"
  • close "Wpf Forms Wizard"
  • with MS Visual Studio right click "production/pagination"-subfolder and choose menu item "Add/Wpf Forms Wizard"
  • with "Wpf Forms Wizard" select the same ViewModel
  • with "Wpf Forms Wizard" for selected ViewModel execute the scripts
    • "01240-Page.php/Page.Doctrine.php.t4"
  • close "Wpf Forms Wizard"
  • with MS Visual Studio Create "Controller"-subfolder under "src"-folder of the php-project
  • with MS Visual Studio right click "Controller"-subfolder and choose menu item "Add/Wpf Forms Wizard"
  • with "Wpf Forms Wizard" select the same ViewModel
  • with "Wpf Forms Wizard" for selected ViewModel execute the scripts
    • "01340-Controller.php/Controller.Symfony.MySql.php.t4"
  • close "Wpf Forms Wizard"
  • open generated php-file
    • at the begining of the file you will find an instructions of how to configure doctrine entity manager and connection for production
      • again you can replace "production" with ultimate or "main" or something else that does not match the word "deployment".
Repeat all the steps for other ViewModels. You must start with the entities which have not master-entity. After that, you continue to work with entities that have only direct masters that you have already worked with.