F1.07 Php Laravel(and Lumen) 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 "app"-folder of the php-project
  • with MS Visual Studio choose menu item "Add/Existing Web Site"
    • select "database"-folder of the php-project
  • with MS Visual Studio right click "migrations"-subfolder of the "database"-folder and choose menu item "Add/Wpf Forms Wizard"
  • with "Wpf Forms Wizard" select dbcontext you need
  • with "Wpf Forms Wizard" for selected dbcontext execute the "==context=="-level script
    • "00520-ContextMigration.php/ContextMigration.Laravel.php.t4"
  • save generated "ContextMigration.php" file
  • close "Wpf Forms Wizard"
  • rename "ContextMigration.php" file according to the Laravel naming convention
  • open generated "ContextMigration.php" php-file
    • at the begining of the file you will find an instructions of how to modify config/database.php
  • using Laravel/Lumen-tools create tables in the database
    • php artisan migrate:fresh
  • with MS Visual Studio right click "Http/Controllers"-subfolder of the "app"-folder 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 scripts
    • "01340-Controller.php/Controller.Laravel.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 Laravel/Lumen config/database.php and config/route.php
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.