PHP Classes

PHP MongoDB CRUD Example of API: API that provides CRUD operations with MongoDB

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 80 All time: 10,115 This week: 68Up
Version License PHP version Categories
php-mongodb-crud-api 1.0.0The PHP License5Databases, Web services, PHP 7, Appli...
Description 

Author

This package implements an API that provides CRUD operations with MongoDB.

It provides code for an example API that uses the MongoDB database to store and retrieve data records.

Currently, it implements API functions to perform operations to create, retrieve, update, and delete records of users and products.

Innovation Award
PHP Programming Innovation award nominee
October 2023
Number 6
MongoDB is a popular NoSQL database that stores information records in a document database.

This package provides an example application that shows how to implement a Web services API that can perform CRUD (Create, Retrieve, Update, and Delete) operations on records of information stored in a MongoDB database.

Manuel Lemos
Picture of Okanlawon Anuoluwapo
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

 

Example

<?php
require __DIR__ . '/config.php';

$user = new User();

if (
$_SERVER['REQUEST_METHOD'] === "GET" ) :
    try {
       
$result = $user->findAllUser();
       
//
       
HttpResponse::OK($result);
    } catch (\
Throwable $th) {
       
HttpResponse::badRequest($th->getMessage());
    }
endif;


Details

PHP and MongoDB CRUD API sample


  Files folder image Files (31)  
File Role Description
Files folder imageapi (8 files, 1 directory)
Files folder imageapp (4 files, 3 directories)
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:80
This week:0
All time:10,115
This week:68Up