承接 jinn/laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jinn/laravel

Composer 安装命令:

composer require jinn/laravel

包简介

Jinn for Laravel. Models, Migrations and API generator.

README 文档

README

Jinn is a code generator that speeds up your work by generating Models, Migrations, and APIs from simple YAML-based definitions. What makes Jinn different from other generators is that it lets you customize the generated code without losing the ability to update it when definitions change.

Read full documentation at jinncode.dev.

Key Concepts

Of course, there are plenty of frameworks and libraries which serve the same purposes using various approaches. This section describes key design decisions which make Jinn different.

Code generation

Unlike many API and admin panel frameworks, Jinn uses code generation, as it gives the following benefits:

  • Only the code that is needed is generated, i.e., if you don't need an update method in your API, it will not be generated at all.
  • The generated code does not have to be very generic, which makes it much simpler.

Symfony and Laravel frameworks also use code generation. However, they apply caching approach, i.e., generate the code at runtime. Jinn generates the code at build-time, which means that there are no first-run performance drawbacks and lets you inspect the code easily.

All the above means that:

  • Jinn carries no performance drawbacks compared to the other approaches.
  • It is easy to inspect the code, understand how it works, extend and customize it.

Base classes

Each class generated by Jinn (except for Migrations) is split into two files:

  1. An empty class under your sources folder which extends a
  2. Base class, located in a separate folder which contains all the logic

The idea is borrowed from Propel, a well-known in the past PHP ORM. The main class is generated only once and never updated, so you can use it to customize generated logic freely. At the same Jinn can update the base class logic for you whenever the definition changes.

Database

Currently, Jinn supports SQL databases only. MongoDB support is planned.

Jinn is designed to manage its database tables and models, i.e., it is not able to work with existing models and database tables. It also expects that no changes will be made to its database tables; otherwise, they may be overwritten. At the same time, it is possible to have Jinn-managed and non-Jinn-managed tables in the same database.

Frameworks

The Jinn reference implementation is made for Laravel, but it is designed to allow implementation for any framework. Contributors are welcome.

Further down this guide, the sections which are specific to Laravel will be marked correspondingly.

Installation

Setup via composer

composer require jinn/jinn-laravel@dev-master

Publish Jinn config file

php artisan vendor:publish --provider="Jinn\Laravel\JinnServiceProvider"

Create Jinn folder structure

Default structure:

jinn 
- def
- gen 

An alternative structure can be configured via config/jinn.php. Further, this guide will use a default configuration. Changing the Jinn configuration should result in corresponding changes to the next steps.

Configure autoload

Edit composer.json, locate autoload section, and add a line as follows:

"autoload": {
    "psr-4": {
        ...
        "JinnGenerated\\": "jinn/gen/" 
    }
}

Then ask the composer to update autoload files:

composer dump-autoload

Getting Started

Basic Definition

Copy the following definition into jinn/def/entities.yaml or create your own.

User:
  class:
    extends: Illuminate\Foundation\Auth\User
  properties:
    name: string
    email: { type: string, unique: true }
    password: string
    avatar_filename: { type: string, required: false }

Post:
  properties:
    content: text
    author: { entity: User, relation: many-to-one }
    published_at: datetime
    comments: { entity: Comment, relation: one-to-many }

Comment:
  properties:
    content: text
    author: { entity: User, relation: many-to-one }
    published_at: datetime

Generation

Ask Jinn to generate the files

php artisan jinn

Inspect generated files under app and jinn/gen folders.

TODO

  • Models:
    • More field types?
    • Different types for id
    • Allow making a required (non-nullable) many-to-one relation
  • APIs:
    • Related controller
    • Additional methods: associated/disassociate, other?
    • Specs
  • Migrations:
    • MongoDB
  • Admin panel
  • File watcher
  • Symfony implementation

jinn/laravel 适用场景与选型建议

jinn/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 8, 最近一次更新时间为 2022 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「jinn」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jinn/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jinn/laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 jinn/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-27