triun/laravel-model-base 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

triun/laravel-model-base

Composer 安装命令:

composer require triun/laravel-model-base

包简介

Generate Eloquent Model Bases for Laravel

README 文档

README

Latest Stable Version Latest Version on Packagist Pre Release Version on Packagist Latest Unstable Version Build Status Total Downloads Software License

Generate Eloquent Model Base for Laravel.

About

Laravel-Model-Base is a Laravel command to perform repetitive tasks while creating new models, and saving it into a abstract model base, so you can update it any time, without need to worry about overwriting your manual changes in the model.

The main goal of the model base it's generate eloquent configurations based on the database table architecture, meaning that it could not be any business logic implemented, or any other logic not comming from the database itself. If you are interested in adding extra properties, methods, interfaces or traits, you can do so in the model itself.

This generator can be customised by the config parameters, but it can also be extended by the modifiers.

The model will be optionally generated too, but in this case, it will never be able to be overwritten by this tool.

Installation

Require this package with composer using the following command:

composer require --dev triun/laravel-model-base

After updating composer, add the service provider to the providers array in config/app.php

Triun\ModelBase\ModelBaseServiceProvider::class,

Development only installation

To install this package on only development systems, add the --dev flag to your composer command:

composer require --dev triun/laravel-model-base:dev-master

Instead of adding the service provider in the config/app.php file, you should add the following code to your app/Providers/AppServiceProvider.php file, within the register() method:

public function register()
{
    if ($this->app->environment() !== 'production') {
        $this->app->register(\Triun\ModelBase\ModelBaseServiceProvider::class);
    }
    // ...
}

This will allow your application to load the Laravel Model Base on non-production environments.

Usage

To create one model base

php artisan make:mode-base table_name [--connection connection_name]

For Bulk creation

php artisan make:mode-base-bulk [--connection connection_name]

Note: If you don't set up the connections in the config file (model-base.bulk.connections), it will try to run all available connections from your database config file (database.connections).

Customize

You can publish the configuration file into your app with:

php artisan vendor:publish --provider="Triun\ModelBase\ModelBaseServiceProvider" --tag=config

Lumen

If you are using Lumen, you may need to do some manual steps...

Copy the config file into your config directory:

cp vendor/triun/laravel-model-base/config/model-base.php config/

And you may also need to uncomment the following lines in bootstrap/app.php file:

<?php
# bootstrap/app.php

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

$app->withFacades(true, [
    Illuminate\Support\Facades\App::class => 'App',
    Illuminate\Support\Facades\File::class => 'File',
]);
$app->withEloquent();
$app->register(App\Providers\AppServiceProvider::class);

So we can use Facades and Eloquent, as well as add some content in the AppServiceProvider:

<?php
namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->instance('path.config', app()->basePath() . DIRECTORY_SEPARATOR . 'config');
        
        if ($this->app->environment() !== 'production') {
            $this->app->configure('model-base');
            $this->app->register(\Triun\ModelBase\ModelBaseServiceProvider::class);
        }
    }
}

// TODO

Besides the configuration file, you can also add or create your own modifiers.

Modifiers

If you want to add behaviours to the generator, you can do so using the skeleton modifiers.

Modifiers Packages

Those are some modifiers packages:

// TODO

Add modifiers

If you already have any modifier package, you can load it by adding it in the config/model-base.php file, in the 'modifiers' array.

// TODO

Create your own modifiers

How to create a modifier.

// TODO

Documentation

The documentation for Laravel-Model-Base is available on the Github wiki.

Issues

Bug reports and feature requests can be submitted on the Github Issue Tracker.

Contributing

See CONTRIBUTING.md for information.

License

The Laravel Model Base is open-sourced software licensed under the MIT license

triun/laravel-model-base 适用场景与选型建议

triun/laravel-model-base 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.11k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-09