PHP code example of nligo / mongodb

1. Go to this page and download the library: Download nligo/mongodb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nligo / mongodb example snippets


php bin/hyperf.php mongodb:publish --config
shell script
namespace App\Controller;

use App\Document\User;

class UserController extends AbstractController
{
    protected $user;
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    public function index()
    {
        return $this->user->findOne();
    }
}