Entity generation

Entity generation, can quickly generate entity files, swoft provides a set of simple and easy to use build. Currently, officials only support MySQL entity generation, and other types of databases refer to official examples

Installation

Using the composer installation composer require swoft/devtool

Use

php bin/swoft entity:gen

php bin/swoft entity:c

php bin/swoft entity:create [tableName] [--pool=xx] [--path=xx] [--table_prefix=xx] [--field_prefix=xxx] [--exc=xxx] [--td=xxx] [-y]

These three names are a meaning.

You can use the php bin/swoft entity:c -h View specific command Help document

  • Tablename Specifies the data table of the build entity, and if it is empty, all table entities that match to it are generated You can also use --table=tableName to specify the datasheet name, multiple tables , separated, If you set the datasheet prefix, tableName do not bring the table prefix.
  • Pool Specifies the database connection pool, which uses the db.pool connection pool by default
  • Path Support mode delivery path for the paths build entity alias , the default build entity path is @app/Model/Entity For example, @app/Model/Entity the @app absolute path to the project is resolved in.
  • Table_prefix is generated based on the datasheet prefix, abbreviated tp that the parameter will not be restricted by the parameters in the DB the prefix bottom layer will like match by table prefix
  • Field_prefix Remove the field name prefix, abbreviated is fp , For example, the database field name t_name is added when the entity is generated --fp=t_ , and the entity property name after the build name .
  • Exc does not expect to generate a datasheet name, use scenarios such as you need to generate all the entity part of the table without wanting to build the entity to use it Multiple tables are , separated by
  • TD Specifies the path support mode delivery path for the build template alias , and the template path used by default is'@devtool/devtool/resource/template'
  • Y whether the build file needs to be confirmed, -y parameters Plus will generate the file directly will not confirm the prompt

Special attention

If a db table prefix configuration exists in the configuration in the connection pool prefix , the generated entity name automatically removes the table prefix, where the [tableName] --table [--exc=xxx] two parameters are 数据表 automatically returned with the table prefix when queried.

Check db charset that the parameters are configured first, or the generated entity Chinese comments will be garbled.

/docs/2.x/en/tool/devtool/entity.html
progress-bar