定制 royvermeulen/entify 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

royvermeulen/entify

最新稳定版本:v0.0.1

Composer 安装命令:

composer require royvermeulen/entify

包简介

A brief description of your package

README 文档

README

Entify is a easy to use ORM like tool, that will create entities and database tables based on a yaml file.

how to use entify:

Create configuration file: In the root of you project create a file called entify-config.php. The config must look something like this:

<?php

$config = [
    'entities' => [
        'Src\\Entities' => 'src/entities'
    ],

    'schema' => '',
    'default-data' => '',
    
    'database-connection' => [
        'DB_HOST' => '',
        'DB_USER' => '',
        'DB_PASS' => '',
        'DB_NAME' => '',
        'DB_PORT' => 3306
    ]
];

return $config;

Creating the schema file: Anywhere in you project create a yaml file specify its location inside of the config under; schema.

Example of what the schema might look like:

users: 
  columns:
    id: {type: int, primary: true, auto_increment: true}
    username: {type: varchar, length: 12}
    password: {type: varchar, length: 255}
  relations:
    usernotes: {type: oneToMany, local: id, foreign: user_id}

notes:
  columns:
    id: {type: int, primary: true, auto_increment: true}
    title: {type: varchar, length: 255}
    content: {type: text}
  relations:
    usernotes: {type: oneToMany, local: id, foreign: note_id}

usernotes:
  columns:
    id: {type: int, primary: true, auto_increment: true}
    user_id: {type: int}
    note_id: {type: int}
  relations:
    users: {type: manyToOne, local: user_id, foreign: id}
    notes: {type: manyToOne, local: note_id, foreign: id}

Adding default data to the database: Anywhere in your project create a plain php file, Specify the location under; default-data in your config.

What the default-data file might look like:

<?php

require 'vendor/autoload.php';

use Src\Entities\Notes;
use Src\Entities\Usernotes;
use Src\Entities\Users;

$users = new Users();
$users->setUsername('admin');
$users->setPassword(password_hash('admin', PASSWORD_DEFAULT));
$users->create();

$note = new Notes();
$note->setTitle('Note 1');
$note->setContent('Content 1');
$note->create();

$userNote = new Usernotes();
$userNote->setUser_id($users->getId());
$userNote->setNote_id($note->getId());
$userNote->create();

List of commands and what they do:

  • vendor/bin/entify entify --all (Creates the database tables and its corresponding entities)

  • vendor/bin/entify entify --entities (only creates the entities)

  • vendor/bin/entify entify --database (only adds the tables and relation to the database)

  • vendor/bin/entify entify --drop (drops all the database tables, and deletes the entities)

  • vendor/bin/entify entify --refresh (drops database and entities and recreates them)

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固