Dau
Dau

Reputation: 8858

How to define schema for mongoDB Collections in Yii2

I am using the mongoDB with PHP and want to define the schema.

I know that mongoDB is schemaless, but in NodeJS we have a plugin mongoose by which we can define the schema for mongoDB.

So how can I define the schema for mongoDB collection in Yii2 like mongoose.

Upvotes: 0

Views: 1208

Answers (1)

Stennie
Stennie

Reputation: 65363

Yii2's standard MongoDB extension provides Yii2 ActiveRecord support with declarative schema and validation similar to Mongoose. The Yii2 extension also includes support for generating starter classes (models, controllers, etc) using the gii generator.

For more information and examples see:

Upvotes: 1

Related Questions