- Notifications
You must be signed in to change notification settings - Fork8
ArangoDB components for yii2 framework
License
DevGroup-ru/yii2-arangodb
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This extension provides theArangoDB integration for the Yii2 framework.
This extension requiresArangoDB PHP Extension
The preferred way to install this extension is throughcomposer.
Either run
php composer.phar require --prefer-dist devgroup/yii2-arangodb "*"
or add
"devgroup/yii2-arangodb": "*"
to the require section of your composer.json.
To use this extension, simply add the following code in your application configuration:
return [//....'components' => ['arangodb' => ['class' =>'\devgroup\arangodb\Connection','connectionOptions' => [triagens\ArangoDb\ConnectionOptions::OPTION_DATABASE =>"mydatabase",triagens\ArangoDb\ConnectionOptions::OPTION_ENDPOINT =>'tcp://127.0.0.1:8529',//triagens\ArangoDb\ConnectionOptions::OPTION_AUTH_USER => '',//triagens\ArangoDb\ConnectionOptions::OPTION_AUTH_PASSWD => '', ], ], ],];
Using the connection instance you may access databases, collections and documents.
To perform "find" queries, you should use [[\devgroup\arangodb\Query]]:
usedevgroup\arangodb\Query;$query =newQuery;// compose the query$query->select(['name','status']) ->from('customer') ->limit(10);// execute the query$rows =$query->all();
This extension provides ActiveRecord solution similar ot the [[\yii\db\ActiveRecord]].To declare an ActiveRecord class you need to extend [[\devgroup\arangodb\ActiveRecord]] andimplement thecollectionName
and 'attributes' methods:
usedevgroup\arangodb\ActiveRecord;class Customerextends ActiveRecord{/** * @return string the name of the index associated with this ActiveRecord class. */publicstaticfunctioncollectionName() {return'customer'; }/** * @return array list of attribute names. */publicfunctionattributes() {return ['_key','name','email','address','status']; }}
Note: collection primary key name ('_key') should be always explicitly setup as an attribute.
You can use [[\yii\data\ActiveDataProvider]] with [[\devgroup\arangodb\Query]] and [[\devgroup\arangodb\ActiveQuery]]:
useyii\data\ActiveDataProvider;usedevgroup\arangodb\Query;$query =newQuery;$query->from('customer')->where(['status' =>2]);$provider =newActiveDataProvider(['query' =>$query,'pagination' => ['pageSize' =>10, ]]);$models =$provider->getModels();
useyii\data\ActiveDataProvider;useapp\models\Customer;$provider =newActiveDataProvider(['query' => Customer::find(),'pagination' => ['pageSize' =>10, ]]);$models =$provider->getModels();
ArangoDB migrations are managed via [[devgroup\arangodb\console\controllers\MigrateController]], which is an analog of regular[[\yii\console\controllers\MigrateController]].
In order to enable this command you should adjust the configuration of your console application:
return [// ...'controllerMap' => ['arangodb-migrate' =>'devgroup\arangodb\console\controllers\MigrateController' ],];
Below are some common usages of this command:
# creates a new migration named 'create_user_collection'yii arangodb-migrate/create create_user_collection# applies ALL new migrationsyii arangodb-migrate# reverts the last applied migrationyii arangodb-migrate/down
Add ArangoDb panel to your yii\debug\Module configuration
return ['bootstrap' => ['debug'],'modules' => ['debug' =>'yii\debug\Module','panels' => ['arango' => ['class' =>'devgroup\arangodb\panels\arangodb\ArangoDbPanel', ], ], ... ], ...];
About
ArangoDB components for yii2 framework
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.