Installing the PHP 7 MongoDB Client/Driver?

后端 未结 12 932
日久生厌
日久生厌 2020-11-28 06:17

I am very eager to start working with PHP 7 however one issue is getting in the way... I primarily use MongoDB for the database, and the problem is that I don\'t know how to

12条回答
  •  自闭症患者
    2020-11-28 06:37

    UBUNTU 16.0.4 (07.12.2016)

    install PHP-MONGODB drivers : Commandes :
    - sudo pecl install mongodb -> résultat : Build process completed successfully Installing '/usr/lib/php/20151012/mongodb.so' install ok: channel://pecl.php.net/mongodb-1.2.0 configuration option "php_ini" is not set to php.ini location You should add "extension=mongodb.so" to php.ini

                        -> la librairie se trouve dans "/usr/lib/php/20151012/mongodb.so"
                - sudo systemctl restart apache2.service
                https://secure.php.net/manual/en/mongodb.installation.pecl.php
                - create 2 new files called "30-mongodb.ini" in both path to add the extension to your server:
                    -/etc/php/7.0/fpm/conf.d/30-mongodb.ini
                    -/etc/php/7.0/cli/conf.d/30-mongodb.ini
                    Commandes :
                        sudo nano /etc/php/7.0/fpm/conf.d/30-mongodb.ini
    
                            -> add "extension=mongodb.so"
    
                        sudo nano /etc/php/7.0/cli/conf.d/30-mongodb.ini
    
                            -> add "extension=mongodb.so"
    
    
                - Test if the mongodb extension is running in your server :
                    Commandes :
                        php --ini
    

    install DoctrineMongoDBBundle : http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html, http://www.doctrine-project.org/2016/06/09/odm-1-1-0-and-1-0-6.html,

        Commandes :
            - cd
            - cd my_project_name
            - ls -a composer*
                -> résultat : composer.json  composer.lock
            - sudo nano composer.json
            - Add to the composer.json in "require" array
                "doctrine/mongodb-odm": "^1.0",
                "doctrine/mongodb-odm-bundle": "^3.0"
            - Add to the composer.json in "require" array
                "alcaeus/mongo-php-adapter": "^1.0",
                "ext-mongo": "*"
            - Add a new array :
                "provide": 
                {
                    "ext-mongo": "1.6.12"
                }
            - Move 
            sudo cp -i /usr/lib/php/20151012/mongodb.so /etc/php/7.0/cli
    

    To give the solution I need at least 10 reputation to post...

提交回复
热议问题