Giter Club home page Giter Club logo

Comments (25)

alcaeus avatar alcaeus commented on June 8, 2024 1

@holtkamp can you try composer install without --ignore-platform-reqs? The whole point of this provide vs. replace exercise is to get it working without using that nuclear option.

from mongo-php-adapter.

holtkamp avatar holtkamp commented on June 8, 2024

Aah, nevermind, I now see

"ext-mongo": "1.6.12"
already contains the provide part.

Does this part of the documentations still apply?

If your project includes a library that requires ext-mongo you need to also specify a provide option in your composer.json: "provide": { "ext-mongo": "1.6.12" }

Due to a limitation in composer you need to specify this in the root package.

Deploying to Heroku
For others reaching this issue, I think installing Heroku will fail anyhow, as Heroku itself will try to install ext-mongo anyhow, this is the output when trying to deploy to Heroku:

ERROR: Failed to install system packages.        
remote:                
remote:        Your platform requirements (for runtimes and extensions) could        
remote:        not be resolved to an installable set of dependencies, or a        
remote:        repository was unreachable.        
remote:                
remote:        Full error information from installation attempt:        
remote:                
remote:        > Loading repositories with available runtimes and extensions        
remote:        >         
remote:        > Your requirements could not be resolved to an installable set of packages.        
remote:        >         
remote:        >   Problem 1        
remote:        >     - ext-mongo 1.6.12 requires php 5.5.* -> no matching package found.        
remote:        >     - ext-mongo 1.6.12 requires php 5.6.* -> no matching package found.        
remote:        >     - doctrine/mongodb 1.2.1 requires ext-mongo ^1.2.12 -> satisfiable by ext-mongo[1.6.12].        
remote:        >     - Installation request for doctrine/mongodb 1.2.1 -> satisfiable by doctrine/mongodb[1.2.1].        
remote:        >         

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

Just a quick word about the provide directive in composer.json: that one is needed so you don't need to specify --ignore-platform-reqs during composer install. Not sure what exactly heroku needs to be satisfied all dependencies are present.

As for the error you are getting in that first example, I'll have to take a look at that.

from mongo-php-adapter.

holtkamp avatar holtkamp commented on June 8, 2024

Thanks for the response. Well, turns out my CLI was at php 5.6.18 when switching to 7.0.3 installation succeeds with:

{
  "provide": {
    "ext-mongo": "1.6.12"
  },
  "require": {
    "alcaeus/mongo-php-adapter": "dev-master"
  }
}

But also without the provide part. What is the advised approach? Leave it at the mongo-php-adapter level?

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

The provide part is important when you add another package to the require. Go ahead and try adding the following packages to the require part:

"doctrine/mongodb-odm": "dev-master",
"doctrine/mongodb": "dev-master"

You'll find that you won't be able to install it with that provide directive but composer will complain about the missing ext-mongo dependency if you remove it. Of course, using --ignore-platform-reqs overrides this all so don't try it with that switch.

from mongo-php-adapter.

holtkamp avatar holtkamp commented on June 8, 2024

Mm, ok, will experiment a bit, maybe heroku/heroku-buildpack-php#146 is not even an issue then...

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

@alcaeus should the directive not be replace instead of provide though?

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

Nevermind, just found #30 and #31. @alcaeus can you summarize your conversation with @Seldaek and explain what the Composer limitations are that cause this? Is it because platform packages get special treatment internally?

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

Summary is: root package needs to specify replace but based on my observations provide works while replace doesn't. The problem is due to all packages starting with "ext-" getting a special treatment and only being checked with extension_loaded() and extension_version(). I'll be taking a look at that once I've gotten Beta-1 out the door which should be in a day or two.

In an ideal world, mongo-php-adapter would specify a replace for ext-mongo and all projects wanting to use the adapter would just specify a require to mongo-php-adapter - no other stuff required.

from mongo-php-adapter.

holtkamp avatar holtkamp commented on June 8, 2024

Thanks for the detailed responses. The "ideal world" scenario sounds like a great place ;) Will run some additional tests to verify heroku/heroku-buildpack-php#146 is an issue or not..

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

So I had a conversation with @Seldaek yesterday and the tl;dr is that replace and provide should work pretty much the same way in this regard, and that both should be able to "override" PHP versions and extensions just like regular packages.

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

That sounds good - the question is, should it be possible to define this override somewhere other than the root package?

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

I believe the answer is yes. I have to create a few reproduce cases and then open a ticket showing which permutations work and which are broken.

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

@dzuelke Thanks for all the effort you're putting into this - I'll update the documentation to use replace instead of provide later.

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

What about this combination: mongo-php-adapter says "replace" for ext-mongo, root project composer.json says "require" for ext-mongo? Maybe that's the "correct" way, @alcaeus and @Seldaek and @naderman? See composer/composer#2690

from mongo-php-adapter.

jmikola avatar jmikola commented on June 8, 2024

If anything, this library would replace ext-mongo (i.e. the legacy driver). It depends on ext-mongodb, so I don't think you'd want to replace that.

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

Well yes of course @jmikola. Typo. Fixed.

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

Okay I can confirm that works, @alcaeus and @holtkamp (using the "composer-replace" branch since that still has it):

{
    "require": {
        "php": "^7.0",
        "alcaeus/mongo-php-adapter": "dev-composer-replace",
        "doctrine/mongodb": "dev-master"
    }
}

All is fine because doctrine/mongodb requires ext-mongo.

If no dependency requires that package, then you need to do it in the composer.json root:

{
    "require": {
        "php": "^7.0",
        "ext-mongo": "*",
        "alcaeus/mongo-php-adapter": "dev-composer-replace"
    }
}

This appears to be the preferred approach according to composer/composer#2690, and it works under all circumstances - both with ext-foo, as well as with "non-platform" packages (such as on Heroku, where "ext-foo" gets transformed to "heroku-sys/ext-foo").

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

PR here: #70

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

PR has been merged. @holtkamp Can you close this issue if it's confirmed fixed with the latest dev-master or follow up with any errors you encounter? Thanks!

from mongo-php-adapter.

holtkamp avatar holtkamp commented on June 8, 2024

mm, after removing my vendor dir, composer.lock and clearing composer caches, running composer install --ignore-platform-reqs with this composer.json:

{
  "require": {
    "php": "^7.0",
    "alcaeus/mongo-php-adapter": "dev-master",
    "doctrine/mongodb": "dev-master"
  }
}

succeeds. However when pushing to Heroku, the buildpack still complains:

git push heroku master         
Counting objects: 16, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (16/16), 4.22 KiB | 0 bytes/s, done.
Total 16 (delta 10), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Using set buildpack heroku/php
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing system packages...
remote: 
remote:  !     ERROR: Failed to install system packages.
remote:        
remote:        Your platform requirements (for runtimes and extensions) could
remote:        not be resolved to an installable set of dependencies, or a
remote:        repository was unreachable.
remote:        
remote:        Full error information from installation attempt:
remote:        
remote:        > Loading repositories with available runtimes and extensions
remote:        > 
remote:        > Your requirements could not be resolved to an installable set of packages.
remote:        > 
remote:        >   Problem 1
remote:        >     - ext-mongo 1.6.12 requires php 5.5.* -> no matching package found.
remote:        >     - ext-mongo 1.6.12 requires php 5.6.* -> no matching package found.
remote:        >     - doctrine/mongodb dev-master requires ext-mongo ^1.5 -> satisfiable by ext-mongo[1.6.12].
remote:        >     - Installation request for doctrine/mongodb dev-master -> satisfiable by doctrine/mongodb[dev-master].
remote:        > 
remote:        
remote:        Please verify that all requirements for runtime versions in
remote:        'composer.lock' are compatible with the list below, and ensure
remote:        all required extensions are available for the desired runtimes.
remote:        
remote:        For reference, the following runtimes are currently available:
remote:        
remote:        PHP:  7.0.3, 7.0.2, 7.0.1, 7.0.0, 5.6.18, 5.6.17, 5.6.16, 
remote:        5.5.32, 5.5.31, 5.5.30
remote:        HHVM: 3.5.1

When doing the same attempt for the other described scenario, with a composer.json like:

{
  "require": {
    "php": "^7.0",
    "alcaeus/mongo-php-adapter": "dev-master",
    "ext-mongo": "*"
  }
}

This results in:

git push heroku master                 
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (20/20), 4.59 KiB | 0 bytes/s, done.
Total 20 (delta 13), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Using set buildpack heroku/php
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing system packages...
remote: 
remote:  !     ERROR: Failed to install system packages.
remote:        
remote:        Your platform requirements (for runtimes and extensions) could
remote:        not be resolved to an installable set of dependencies, or a
remote:        repository was unreachable.
remote:        
remote:        Full error information from installation attempt:
remote:        
remote:        > Loading repositories with available runtimes and extensions
remote:        > 
remote:        > Your requirements could not be resolved to an installable set of packages.
remote:        > 
remote:        >   Problem 1
remote:        >     - ext-mongo 1.6.12 requires php 5.5.* -> no matching package found.
remote:        >     - ext-mongo 1.6.12 requires php 5.6.* -> no matching package found.
remote:        >     - Installation request for ext-mongo * -> satisfiable by ext-mongo[1.6.12].
remote:        > 
remote:        
remote:        Please verify that all requirements for runtime versions in
remote:        'composer.lock' are compatible with the list below, and ensure
remote:        all required extensions are available for the desired runtimes.
remote:        
remote:        For reference, the following runtimes are currently available:
remote:        
remote:        PHP:  7.0.3, 7.0.2, 7.0.1, 7.0.0, 5.6.18, 5.6.17, 5.6.16, 
remote:        5.5.32, 5.5.31, 5.5.30
remote:        HHVM: 3.5.1
remote:        

So, I am not sure whether this issue can be closed just yet, did I test correctly?

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

Yes @holtkamp the change is not merged yet for the buildpack. Please test according to the instructions at heroku/heroku-buildpack-php#146 (comment)

from mongo-php-adapter.

holtkamp avatar holtkamp commented on June 8, 2024

Mm, ok, sorry for my ignorance ;).

In both cases this results in problems when on PHP 7.0.3 CLI:

composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for doctrine/mongodb dev-master -> satisfiable by doctrine/mongodb[dev-master].
    - doctrine/mongodb dev-master requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system.

And without doctrine/mongodb

composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-mongo * is missing from your system. Install or enable PHP's mongo extension.

from mongo-php-adapter.

dzuelke avatar dzuelke commented on June 8, 2024

That's weird; if that happens on your box then it would have to happen on push to Heroku as well!?

from mongo-php-adapter.

alcaeus avatar alcaeus commented on June 8, 2024

Closing this - the composer issue is being tracked in composer/composer#5030 while the actual install issue is tracked in #30.

from mongo-php-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.