This is an example of a Laravel8 with Mongodb Integration
After clone you can run it
how to achieve follow a few steps
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=
php artisan make:migration create_products_table --create=products
php artisan make:controller ProductController --resource --model=Product
use Jenssegers\Mongodb\Eloquent\Model;
config\database.php file under the “connections” object in Laravel project
'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' => []
],
'default' => env('DB_CONNECTION', 'mongodb'),
composer require mongodb/mongodb --ignore-platform-reqs
composer require jenssegers/mongodb --ignore-platform-reqs
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:
Jenssegers\Mongodb\MongodbServiceProvider::class,
php artisan serve and url /product
please refer to mongodb laravel mongodb query.
-
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();