devmustafa / yii2-blog-mongodb
Yii2 blog working with mongodb
Installs: 84
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Type:yii2-extension
Requires
- yiisoft/yii2: *
- yiisoft/yii2-imagine: *
- yiisoft/yii2-mongodb: ~2.1.0
- zxbodya/yii2-elfinder: *@dev
- zxbodya/yii2-tinymce: *@dev
This package is not auto-updated.
Last update: 2025-01-18 21:36:10 UTC
README
It's a multi-language blog extension that uses Mongodb that gives you an awesome performance.
Check this tutorial that I like, in order to know more about Mongodb.
Installation
- You have to have Mongodb up and running, so download it from here.
- Also you have to have Mongodb PHP driver installed.
And you run Mongodb through the following command:
mongod --fork --logpath /var/log/mongodb/mongodb.log
-
And you setup the extension through the composer:
composer require devmustafa/yii2-blog-mongodb
Or add the following line in your composer.json:
"devmustafa/yii2-blog-mongodb": "*"
Configuration
-
In your common config file add the following db component:
... 'components' => [ ... 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://127.0.0.1/DB_MONGO_NAME', // local // 'dsn' => 'mongodb://DB_MONGO_USERNAME:DB_MONGO_PASSWORD@DB_MONGO_HOST/DB_MONGO_NAME, // remote ], ... ], ...
-
In your frontend config file add the following module:
... 'modules' => [ ... 'blog' => [ 'id' => 'blog', 'class' => devmustafa\blog\modules\frontend\Module::className(), 'used_languages' => ['en', 'ar'], // list of languages used 'default_language' => 'en', // default language 'listing_size' => 10, // default size of listing page 'rules' => [ // setup rules for frontend routes // change key not value 'posts' => '/post', 'post/<slug>' => '/post/single', 'category/<slug>' => '/post/category', // posts related to a specific category ] ], ... ] ...
-
In your backend config file add the following module:
... 'modules' => [ ... 'blog' => [ 'id' => 'blog', 'class' => devmustafa\blog\modules\backend\Module::className(), 'upload_url' => 'http://example.com/uploads', // full upload url 'upload_directory' => '/full/path/to/uploads/dir', // full upload directory 'used_languages' => ['en', 'ar'], // list of languages used 'default_language' => 'en', // default language ], ... ] ...
Note:
default_language
must be one of your used_languages
array, and if you would like to use a dynamic language in your app, so leave it empty:
'default_language' => '', // empty (don't remove)
In this case the extension reading the value of Yii::$app->langauge
and it should be one of your defined used_languages
array.
Usage
-
Go to your backend url to add some posts/authors/categories:
- /blog/post
- /blog/author
- /blog/category
-
Then you check it out on your frontend:
- /posts