Symfony learning

Recently I took time to sort out the PHP framework, and found that Yii2 documents, especially Chinese culture, are relatively large, but Symfony's documents are relatively backward in culture, but they are still sufficient.

Symfony4 and Symfony5 have been used a lot now, but Symfony should be regarded as a practical PHP standard code base

There are many components in it, all of which can be learned and used. There will be time to analyze the basic ideas of each component one after another. The overall call logic of the previous TP, I now seem to be very meaningful and helpful. The main reason is that although the official website has it, it does not mention the specific implementation and status inside. To put it bluntly, without directly contacting every line of code, it makes people feel distant

I think in terms of the framework's calling ideas, the previous TP calling process should be universal.

I still like Symfony, especially the rapid development of symfony5, which
involves all aspects of web development, including not limited to the type of configuration, routing, HTTP request flow, the nature of the Controller, Doctrine's object mapping, several common databases, mysql,
Service allocation and configuration of PostgreSQL, sqlite, Docker-compose, git version control, branch development, test merge, test, development, git operation and deployment in the production environment, database migration and update, PHP regular PC side commonly used Template engine, webpack for single page application, API development.

Talk to Doctirne today

This is an object mapping component.

It can realize data structure and provide data support for business logic. With the data structure, the program can run normally. The persistence of data is secondary, which I agree with.
Although it does not have a more flexible model and service, looking at the development of Java, the combination of JavaBean and Servlet, I think this Symfony logic is still feasible.

The first step of Doctrine is to create an entity. The
second step is to create the relationship and connection of the
entity. The third step is to create the operation and data logic of the entity. Repository

Although not the same as the Entity of the model, there are still some similarities
(the less convenient is the SQL table design paradigm, the relationship is placed in the third table) and
it is not very similar to the Repository of the Service

The similarity is that it not only supports the streaming SQL writing of the model object and the SQL writing of the DB

Doctrine provides more standardized DQL and Query Builder. These two should be familiar to users who are familiar with SQL

The more unfamiliar is the annotation.

The established php ordinary classes have nothing to do with Doctrine, only annotations appear. There are several forms of annotations, xml, yaml, annotation.
Annotations tell Doctrine how the class is mapped to the database, including relationships, connections and operations. Fields, field attributes, table structure

The annotation parser
use Doctrine\ORM\Mapping as ORM is used here; the annotation
is obtained through the PHP reflection API, and then all the metadata information is mapped out

Through the obtained metadata,
there are two solutions for generating a list of SQL statements for persistence
: 1. A series of commands of doctrine:schame, which can be used in the development environment, and cannot be traced back
2.make:migration

Through these two, you can generate a lot of sql and persist the data to the database

About Doctrine more related component usage, follow up

Guess you like

Origin blog.51cto.com/10725691/2636929