Download the PHP package openpsa/midgard-portable without Composer
On this page you can find all versions of the php package openpsa/midgard-portable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download openpsa/midgard-portable
More information about openpsa/midgard-portable
Files in openpsa/midgard-portable
Package midgard-portable
Short Description ActiveRecord ORM built on top of Doctrine 2
License LGPL-2.1-or-later
Informations about the package midgard-portable
midgard-portable
This library provides an ActiveRecord ORM built on top of Doctrine 2 and is modeled after the Midgard API.
In a Nutshell
You can define your entities in XML (usually referred to MgdSchema):
Running midgard-portable schema
will create a corresponding database table and a PHP class (usually referred to as the MgdSchema class). You can use this to read from and write to the DB:
midgard-portable automatically adds metadata to the record:
It also supports soft-delete:
You can query entries like this:
Or, you simply use Doctrine's builtin QueryBuilder
.
Then, there's object trees, links, working with files, import/export of data and lots more, but until there is time to document all that, you'll have to read the source to find out (the unit tests might also be a good starting point).
Usage
To include midgard-portable
in your application, simply require
it in your composer.json
. You can bootstrap the adapter like this:
Change the parameters as required. After calling connection::initialize()
, you can interact with the database through Midgard API as outlined above.
CLI tools
midgard-portable
needs to generate entity classes as well as ClassMetadata
and Proxy
classes for Doctrine. In development setups, this is done automatically on each request. For production installations, you can run the following CLI command:
It works very much like the midgard-schema
tool of old, i.e. it will generate midgard_object
classes based on MgdSchema XML files, the accompanying mapping data and proxy classes, and also create/update the corresponding database tables. You will need to run this once during initial installation, and then again each time the MgdSchemas change.
You can also use Doctrine's CLI runner and all the functionality it provides if you create a file under the name cli-config.php
, with this content:
All versions of midgard-portable with dependencies
doctrine/orm Version ^2.14
doctrine/dbal Version ^3.5
symfony/console Version >=6.0.0
symfony/cache Version >=4.4.0
monolog/monolog Version ^1.15 || ^2.0
ext-xml Version *