thyyppa / laravel-filemaker-api
Requires
- php: >=7.2
- thyyppa/fluent-fm: ^1.2.4
Requires (Dev)
- nunomaduro/collision: v3.0.1
- orchestra/testbench: ^3.5 || ^4.0
- phpunit/phpunit: 8.5.4
- dev-master
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/phpunit/phpunit-8.5.19
- dev-dependabot/composer/phpunit/phpunit-8.5.18
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/nunomaduro/collision-v3.1.0
- dev-analysis-642Pao
This package is auto-updated.
Last update: 2021-08-02 12:15:27 UTC
README
FluentFM 是一个 PHP 扩展包,通过流畅的查询构建器风格界面连接到 FileMaker Server 的数据 API。
需求
- PHP 7.2+
- FileMaker Server 17
- Laravel 5+
安装
使用 Composer
使用以下命令
composer require thyyppa/laravel-fluent-fm
或者在您的 composer.json 文件中包含
{
"require": {
"thyyppa/laravel-fluent-fm": "dev-master"
}
}
准备 FileMaker
重要!所有表和布局 必须 包含一个 id 字段。
如果您想使用软删除,您的表和布局 必须 包含 deleted_at 字段
以下字段也建议使用
created_at(按最新排序)updated_at(按最后更新排序)
您希望访问的所有字段都必须在您提供的布局中可用,您将通过该 api 执行 FileMaker 操作。
理想情况下,这些将是包含所有字段的隐藏布局,镜像表,但根据您的布局结构,您可能能够使用现有的面向人类的布局。
确保在您的权限集中启用了 fmrest,您可以在以下位置定义它
文件 > 管理 > 安全 > [高亮用户] > 权限集 [编辑]
还请确保服务器上启用了数据 API。
如果您的服务器是本地安装的,此链接应带您到那里
https://:16001/admin-console/app/connectors/fmdapi
否则,将 localhost 替换为服务器地址。
注册包
此包具有自动发现功能,因此注册提供者和外观通常不是必需的,但如果自动发现对您不起作用,您可以按以下方式手动注册包。
在 config/app.php 中注册服务提供者(可选)
'providers' => [ // Other Service Providers Hyyppa\LaravelFluentFM\Providers\LaravelFluentFMServiceProvider::class, ],
在 config/app.php 中注册外观别名(可选)
'aliases' => [ // Other Aliases Hyyppa\LaravelFluentFM\Facades\FluentFM::class, ]
配置
运行以发布配置文件(可选)
php ./artisan vendor:publish --provider="Hyyppa\\LaravelFluentFM\\Providers\\LaravelFluentFMServiceProvider"
设置环境变量
在您的 .env 文件中,添加以下项
FILEMAKER_FILE=[FileMaker file name without extension] FILEMAKER_HOST=[FileMaker server address] FILEMAKER_USER=[FileMaker file user] FILEMAKER_PASS=[FileMaker file password]
用法
从布局获取记录
<?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();
执行查找操作
$bobs = FluentFM::find('customers')->where('first','Bob')->get();
创建记录
$recordId = FluentFM::create('customers', [ 'id' => 13 'first' => 'Robert', 'last' => 'Paulson', 'phone' => '406-555-0112', ]);
更新记录
// if multiple records are matched each will be updated FluentFM::update('customers', [ 'phone' => '406-555-0199' ]) ->where('id',13) ->limit(1) ->exec();
删除记录
如果您想使用软删除,您的表和布局 必须 包含 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();
上传和下载文件到记录容器
// 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();
运行FileMaker脚本
FluentFM::find('customers') ->where('id',13) ->script('scriptname', 'parameter') ->presort('presort_scriptname', 'presort_scriptparam') ->prerequest('prerequest_scriptname', 'prerequest_scriptparam') ->get()
可链式命令
... 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] )
可链式修饰符
... ->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] )
链式操作结束方法
... ->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()
杂项命令
... // 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()
许可证
MIT许可证
免责声明
本项目是一个独立实体,未经FileMaker, Inc.授权、赞助或以其他方式关联。FileMaker是FileMaker, Inc.的商标,在美国和其他国家注册。