Download the PHP package rockeinstein/eloquent-zf2 without Composer
On this page you can find all versions of the php package rockeinstein/eloquent-zf2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rockeinstein/eloquent-zf2
More information about rockeinstein/eloquent-zf2
Files in rockeinstein/eloquent-zf2
Package eloquent-zf2
Short Description Eloquent ORM module for Zend Framework 2
License MIT
Homepage https://github.com/RockEinstein/eloquent-zf2
Informations about the package eloquent-zf2
EloquentZF2
Eloquent ORM module for Zend Framework 2.
Features
Eloquent Model
andCapsule
suppot out of the box.Validators
for forms:RecordExists
andNoRecordExists
(equivalent ofZend\Validator\Db\RecordExists
andZend\Validator\Db\noRecordExists
).Authentication
adapters (Abstract
implementation supporting AuthenticationService and two implementationsCallbackCheckAdapter
andCredentialTreatmentAdapter
).
Planned Features
- Multi-connection configuration support.
- Caching support.
- Paginator support.
- Logger support.
- Session Handlers (not sure if needed yet).
- Migration support (via ZFTool).
Install
$ composer require edvinasme/eloquent-zf2:dev-master
Setup
- Add
EloquentZF2
to themodules
array inconfig/application.config.php
- You can now retrieve EloquentZF2 via SM:
$sm->get('EloquentZF2')
This gives you access to Eloquent Query Builder, Schema Builder etc. (see http://laravel.com/docs/database for more information) - Copy
vendor/edvinasme/eloquent-zf2/config/database.eloquent.config.php.dist
toconfig/autoload/database.eloquent.config.php
and add database credentials.
Models
Your models should extend Illuminate\Database\Eloquent\Model
for example:
Validators
When populating InputFilter (usually in Model's getInputFilter() method), you
can use EloquentZF2\Validator\RecordExists
or EloquentZF2\Validator\NoRecordExists
validators which will check records existance in the database and validate the
field accordingly.
The following option keys are supported:
table
=> The database table to validate againstschema
=> The schema (database) to check for a matchfield
=> The field to check for a matchexclude
=> An optional where clause or field/value pair to exclude from the queryconnection
=> An optional database connection name to use
An example below checks table users
, field login
with form input's value
while excluding records where login = [email protected]
:
Authentication
To help you implement Authentication with EloquentZF2 in a similar way as with
ZendDB, there is an Abstract Authentication Adapter provided
(Authentication\\Adapter\EloquentDb.php
) and two adapters implemented:
Authentication\Adapter\CallbackCheckAdapter.php
- lets you supply a custom callback function. This is useful when you want to check credentials with e.g. bcrypt. Defaults to simple ($a == $b) comparison if callback function is not provided. See example below.Authentication\Adapter\CredentialTreatmentAdapter.php
- lets you supply SQL statement, function or routine (e.g. MD5(?), PASSWORD(?) etc.) which should be applied to given gredential before checking it. Defauls to '?' which would be same as (passwordField
=password
) comparison. See example below.
Both of these Adapters are implemented in a very similar way as Zend's Authentication adapters and they are compatible with Authentication Service. Please refer to Zend's Authentication Service Documentation for more information.
CallbackCheckAdapter.php Example
This is example using Bcrypt (Zend's implementation). This would usually go in your controller's login action:
CredentialTreatmentAdapter.php Example
This is example using MD5(?). This would usually go in your controller's login action: