定制 thyyppa/laravel-fluent-fm 二次开发

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

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

thyyppa/laravel-fluent-fm

Composer 安装命令:

composer require thyyppa/laravel-fluent-fm

包简介

A Laravel package for FileMaker Server's Data API using a fluent query builder style interface.

README 文档

README

FluentFM is a PHP package that connects to FileMaker Server's Data API using a fluent query builder style interface.

Requirements

  • PHP 7.2+
  • FileMaker Server 17
  • Laravel 5+

Installation

Using Composer

Use the command

composer require thyyppa/laravel-fluent-fm

or include in your composer.json file

{  
    "require": {  
        "thyyppa/laravel-fluent-fm": "dev-master"  
    }  
}  

Prepare FileMaker

Important! All tables and layouts must contain an id field.

If you wish to use soft deletes your table and layout must contain the field deleted_at

The following fields are also recommended:

  • created_at (for sorting by latest)
  • updated_at (for sorting by last update)

All fields that you wish to access must be available in the layout that you provide while performing FileMaker operations through the api.

Ideally these will be hidden layouts that contain all fields raw, mirroring the table, but depending on your layout structure you may be able to use existing human-facing layouts.

Ensure that fmrest is enabled on your privilege set, which you can define in

File > Manage > Security > [highlight user] > Privilege Set [Edit]

Also be sure that the Data API is enabled on the server.

If your server is installed locally this link should take you there:

http://localhost:16001/admin-console/app/connectors/fmdapi

Otherwise replace localhost with the server address.

Register package

This package features auto-discovery, so registering the provider and facade should not be necessary, but if for any reason auto-discovery does not work for you, you can register the package manually as shown below.

Register the service provider in config/app.php (optional)

'providers' => [
    // Other Service Providers

    Hyyppa\LaravelFluentFM\Providers\LaravelFluentFMServiceProvider::class,
],

Register the facade alias in config/app.php (optional)

'aliases' => [
    // Other Aliases

    Hyyppa\LaravelFluentFM\Facades\FluentFM::class,
]

Config

Publish the config files by running (optional)

php ./artisan vendor:publish --provider="Hyyppa\\LaravelFluentFM\\Providers\\LaravelFluentFMServiceProvider"

Set Environment Variables

In your .env file, add the following items

FILEMAKER_FILE=[FileMaker file name without extension]
FILEMAKER_HOST=[FileMaker server address]
FILEMAKER_USER=[FileMaker file user]
FILEMAKER_PASS=[FileMaker file password]

Usage

Getting records from layout

<?php  
  
use Hyyppa\LaravelFluentFM\Facades\FluentFM;
  
// get a single record as array
$record = FluentFM::record('layout', 'id')->get();

// get multiple records as array
$records = FluentFM::records('layout')->limit(10)->get();  

Performing a find operation

$bobs = FluentFM::find('customers')->where('first','Bob')->get();

Creating a record

$recordId = FluentFM::create('customers', [
    'id'    => 13
    'first' => 'Robert',
    'last'  => 'Paulson',
    'phone' => '406-555-0112',
]);

Updating a record

// if multiple records are matched each will be updated
FluentFM::update('customers', [ 'phone' => '406-555-0199' ])
        ->where('id',13)
        ->limit(1)
        ->exec();

Deleting records

If you wish to use soft deletes your table and layout must contain the field deleted_at

// hard delete removes record
FluentFM::delete('customers')
        ->where('id',13)
        ->limit(1)
        ->exec();

// soft delete sets record's deleted_at field
FluentFM::softDelete('customers')
        ->where('id',13)
        ->limit(1)
        ->exec();

// undeletes soft deleted records
FluentFM::undelete('customers')
        ->where('id',13)
        ->limit(1)
        ->exec();

// returns matching records that have not been soft deleted
$active = FluentFM::find('customers')
                  ->where('first','Bob')
                  ->withoutDeleted()
                  ->get();

// returns matching records even if soft deleted (default behavior)
$all = FluentFM::find('customers')
               ->where('first','Bob')
               ->withDeleted()
               ->get();

Uploading and downloading files to a record's container

// if query matches multiple, file will be added to each
FluentFM::upload('customers', 'photo', './path/to/photo.jpg')
        ->where('id', 13)
        ->limit(1)
        ->exec();

// if query matches multiple, all files will be downloaded to path
FluentFM::download('customers', 'photo', './save/to/path/')
        ->where('id', 13)
        ->limit(1)
        ->exec();

Running FileMaker scripts

FluentFM::find('customers')
        ->where('id',13)
        ->script('scriptname', 'parameter')
        ->presort('presort_scriptname', 'presort_scriptparam')
        ->prerequest('prerequest_scriptname', 'prerequest_scriptparam')
        ->get()

Chainable commands

...

FluentFM::find( <layout> )
FluentFM::update( <layout>, [fields], [recordId] )
FluentFM::delete( <layout>, [recordId] )
FluentFM::softDelete( <layout>, [recordId] )
FluentFM::undelete( <layout>, [recordId] )
FluentFM::upload( <layout>, <field>, <filename>, [recordId] )
FluentFM::download( <layout>, <field>, [output_dir], [recordId] )

Chainable modifiers

...

->record( <layout>, <id> )
->records( <layout>, [id] )
->limit( <limit> )
->offset( <offset> )
->sort( <field>, [ascending] )
->sortAsc( <field> )
->sortDesc( <field> )
->withPortals()
->withoutPortals()
->where( <field>, <params> ) // multiple calls act as "and"
->orWhere( <field>, <params> )
->whereEmpty( <field> )
->has( <field> )
->whereNotEmpty( <field> )
->withDeleted()
->withoutDeleted()
->script( <script>, [param], [type] )
->prerequest( <script>, [param] )
->presort( <script>, [param] )

End of chain methods

...

->get()
->exec()
->create( <layout>, [fields] )
->latest( <layout>, [field] )       # table must have created_at field if [field] undefined 
->oldest( <layout>, [field] )       # table must have created_at field if [field] undefined 
->lastUpdate( <layout>, [field] )   # table must have updated_at field if [field] undefined 
->first()
->last()

Misc commands

...

// set global fields on table
FluentFM::globals( [table], [ key => value ] )

// clear query parameters
FluentFM::clearQuery()

// clear query parameters and reset to default options
FluentFM::reset()

License

MIT License

Disclaimer

This project is an independent entity and has not been authorized, sponsored, or otherwise affiliated with FileMaker, Inc. FileMaker is a trademark of FileMaker, Inc., registered in the U.S. and other countries.

thyyppa/laravel-fluent-fm 适用场景与选型建议

thyyppa/laravel-fluent-fm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 537 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-24