matatirosoln / doctrine-fm-data-api-driver
Use FileMaker via the v17+ Data API as your backend database
Installs: 1 012
Dependents: 0
Suggesters: 1
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.2.0
- ext-json: *
- ext-pdo: *
- doctrine/dbal: 2.*|3.*
- doctrine/orm: 2.*
- greenlion/php-sql-parser: ^4.0
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
- doctrine/doctrine-bundle: ^1.6
- phpunit/phpunit: @stable
- sensio/framework-extra-bundle: 3.*
- symfony/framework-bundle: 3.*
- symfony/validator: 3.*
- symfony/yaml: 3.*
- dev-master
- 0.10.11
- 0.10.10
- 0.10.9
- 0.10.8
- 0.10.7
- 0.10.6
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.8
- 0.6.7
- 0.6.6
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-branch-0-10-11
- dev-branch-0-10-10
This package is auto-updated.
Last update: 2024-12-05 02:44:18 UTC
README
A Doctrine driver to interact with FileMaker using the v17+ Data API v1.
Installation
composer require matatirosoln/doctrine-fm-data-api-driver
Note: We recently update the version of Guzzle used by this library to v7 which requires PHP >= 7.2. If you are still working with an earlier version of PHP then require version ^0.7.5
of this library.
Configuration
In your Doctrine configuration comment out
driver: xxxx
and replace it with
driver_class: MSDev\DoctrineFMDataAPIDriver\FMDriver
Conventions
-
Create a model to represent a FileMaker layout. Set the name of the layout as the model table.
/** * Keyword * * @Table(name="Keyword") * @Entity(repositoryClass="Repository\KeywordRepository") */ class Keyword
-
In your model create an id field which is mapped to the special rec_id pseudo field
/** * @var int * * @Column(name="rec_id", type="integer") */ private $id;
-
Create your 'actual' ID field, as used for relationships, as a separate property of your model. Set its GeneratedValue strategy to be
Custom
which will mean that Doctrie will wait for FM to assign that value - the assumption being that this is an auto-enter calc field (probaby Get(UUID)). You then need to specifiy the CustomIdGenerator and set this toMSDev\DoctrineFMDataAPIDriver\FMIdentityGenerator
so that the value is returned as a string./** * @var string * * @Column(name="__pk_ClientID", type="string" length=255) * @Id * @GeneratedValue(strategy="CUSTOM") * @CustomIdGenerator(class="MSDev\DoctrineFMDataAPIDriver\FMIdentityGenerator") */ private $uuid;
Alternatively you could generate the UUIDs in your model constructor (using for example ramsey/uuid). In this case you'd end up with something like
/** * @var string * * @Column(name="__pk_CanvasID", type="string", length=255) * @Id */ private $uuid; public function __construct() { $this->uuid = Uuid::uuid4()->toString(); }
-
Add other properties as required. To access related fields on your layout enclose the field name in single quotes in the column mapping.
/** * @var string * * @Column(name="'absCon::email'", type="string", length=255) */ private $contactEmail;
-
If you need access to the record modification ID you can add the special mod_id pseudo property
/** * @var int * * @Column(name="mod_id", type="integer") */ private $modId;
Considerations
- Because of the way in which more 'conventional' databases handle relationships, there is no concept of a portal. To access related data create a corresponding model for that table (layout) and create standard Doctrine relationships (OneToOne, OneToMany, ManyToOne etc).
- If your model contains calculation fields you will run into issues when trying to create a new record, since Doctrine will try and set those fields to null. One 'solution' to this is to create a 'stub' of your model which contains only the fields which are necessary to create a new record and to instantiate that for record creation. If you head down this route you'll likely want to create an interface which both your stub and your real entity implement so that you can typehint appropriately.
- If you wish to perform an IN query, then it needs to be the last
andWhere
set in the query builder so that the previous conditions will be applied to all of the query objects which the Data API requires to simulate an IN query.
See also
This driver has been developed for use within Symfony applications (because that's what we do). The Doctrine FileMaker bundle creates services to access scripts, containers, etc.