https://github.com/chandrakantapanda/laravel-mongodb-crud
Laravel8 with Mongodb Integration
https://github.com/chandrakantapanda/laravel-mongodb-crud
crud-application laravel8 laravel8-with-mongodb-crud laravel8-with-mongodbsetup laravelcrud mango mongocrud mongodb
Last synced: 2 months ago
JSON representation
Laravel8 with Mongodb Integration
- Host: GitHub
- URL: https://github.com/chandrakantapanda/laravel-mongodb-crud
- Owner: chandrakantapanda
- Created: 2023-09-01T11:23:16.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-04T16:27:18.000Z (almost 2 years ago)
- Last Synced: 2025-02-03T09:47:43.638Z (4 months ago)
- Topics: crud-application, laravel8, laravel8-with-mongodb-crud, laravel8-with-mongodbsetup, laravelcrud, mango, mongocrud, mongodb
- Language: PHP
- Homepage:
- Size: 9.47 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel8 with Mongodb Integration and crud operation
This is an example of a Laravel8 with Mongodb IntegrationAfter clone you can run it
how to achieve follow a few steps
## Getting Started
### Step 1: setup database in .env file
````javascript
env file from your laravel application directory and Configure MongoDB Database
DB_CONNECTION=mongodb
DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=myappdb
DB_USERNAME=
DB_PASSWORD=
````![]()
## Step 2:Create a schema for product table.
````javascript
php artisan make:migration create_products_table --create=products````
## Step 3: create a controller and model
````javascript
php artisan make:controller ProductController --resource --model=Product````
## Step 4: In the product model comment the line use Illuminate\Database\Eloquent\Model then add
````javascript
use Jenssegers\Mongodb\Eloquent\Model;
````
## Step 5: add db connection
config\database.php file under the “connections” object in Laravel project
````javascript
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_DB_HOST', 'localhost'),
'port' => env('MONGO_DB_PORT', 27017),
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => []
],
````![]()
## Step 6: Set the default database connection name in config\database.php at top section
'default' => env('DB_CONNECTION', 'mongodb'),## Step 7: In order to make connections with MongoDB you need Jenssegers Library:
````javascript
composer require mongodb/mongodb --ignore-platform-reqs
composer require jenssegers/mongodb --ignore-platform-reqs
````## Step 7: add dependencies
If Laravel project does not load dependencies automatically, you may also need to add the following to the provider’s section in your app.php file:````javascript
Jenssegers\Mongodb\MongodbServiceProvider::class,
````![]()
## Run the project
php artisan serve and url /product## for more mongodb query related
please refer to mongodb laravel mongodb query.## installing MongoDB in XAMPP Windows
- Download mongoDB from this link: mongodb download (the download button is located under “Community Server” tab). Download and install it
- Download the mongoDB driver from this link:
https://pecl.php.net/package/mongodb/1.13.0/windows
- Open the ZIP file then extract the file: php_mongodb.dll to C:\xampp\php\ext directory.
- Go to xampp/php/ and open up php.ini using your favorite editor, add the following lines to your extensions: extension=mongodb
- Restart XAMPP.
- create a file in your xampp/htdocs folder, in it put the following code: phpinfo();![]()