yiisoft / yii2-apidoc

Yii 2 apidoc extension.
https://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
258 stars 121 forks source link

Not installable using composer anymore? #294

Open ondics opened 1 year ago

ondics commented 1 year ago

What steps will reproduce the problem?

In my Docker container (php:8.2-bullseye) I use yii2-app-basic:

git clone https://github.com/yiisoft/yii2-app-basic

Then add https://github.com/yiisoft/yii2-app-basic to require section:

"minimum-stability": "stable",
"require": {
    "php": ">=7.4.0",
    "yiisoft/yii2": "~2.0.45",
    "yiisoft/yii2-bootstrap5": "~2.0.2",
    "yiisoft/yii2-symfonymailer": "~2.0.3",
    "yiisoft/yii2-apidoc": "~2.1.0"
},
[...]

Then start composer to resolve dependencies:

$ composer update

What's expected?

This should work now:

$ ./yii help api 

What do you get instead?

root@cc81f319ee70:/app/yii2-app-basic# composer update

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - yiisoft/yii2-apidoc[2.1.0, ..., 2.1.6] require yiisoft/yii2-bootstrap ~2.0.0 -> satisfiable by yiisoft/yii2-bootstrap[2.0.0, ..., 2.0.11].
    - yiisoft/yii2-bootstrap[2.0.9, ..., 2.0.11] require bower-asset/bootstrap 3.4.* | 3.3.* | 3.2.* | 3.1.* -> satisfiable by bower-asset/bootstrap[v3.1.0, ..., v3.4.1].
    - yiisoft/yii2-bootstrap[2.0.1, ..., 2.0.8] require bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> satisfiable by bower-asset/bootstrap[v3.1.0, ..., v3.3.7].
    - yiisoft/yii2-bootstrap 2.0.0 requires bower-asset/bootstrap 3.2.* | 3.1.* -> satisfiable by bower-asset/bootstrap[v3.1.0, v3.1.1, v3.2.0].
    - You can only install one version of a package, so only one of these can be installed: bower-asset/bootstrap[v3.1.0, ..., v3.4.1, v5.1.0, ..., v5.3.0].
    - yiisoft/yii2-bootstrap5[2.0.2, ..., 2.0.4] require bower-asset/bootstrap ^5.1.0 -> satisfiable by bower-asset/bootstrap[v5.1.0, ..., v5.3.0].
    - Root composer.json requires yiisoft/yii2-bootstrap5 ~2.0.2 -> satisfiable by yiisoft/yii2-bootstrap5[2.0.2, 2.0.3, 2.0.4].
    - Root composer.json requires yiisoft/yii2-apidoc ~2.1.0 -> satisfiable by yiisoft/yii2-apidoc[2.1.0, ..., 2.1.6].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Is there something missing in the installations section of yii2-apidoc ?

mtangoo commented 1 year ago

What happens if you remove Bootstrap5 extension from composer.json?

ondics commented 1 year ago

Without Bootstrap5 this is the new composer.json require: section:

"require": {
    "php": ">=7.4.0",
    "yiisoft/yii2": "~2.0.45",
    "yiisoft/yii2-symfonymailer": "~2.0.3",
    "yiisoft/yii2-apidoc": "~2.1.0"
},

But these errors remain:

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires yiisoft/yii2-symfonymailer ~2.0.3 -> satisfiable by yiisoft/yii2-symfonymailer[2.0.3, 2.0.4].
    - yiisoft/yii2-apidoc[2.1.0, ..., 2.1.6] require phpdocumentor/reflection-docblock ^2.0.4 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.5].
    - Conclusion: don't install phpdocumentor/reflection-docblock 2.0.5 (conflict analysis result)
    - Root composer.json requires yiisoft/yii2-apidoc ~2.1.0 -> satisfiable by yiisoft/yii2-apidoc[2.1.0, ..., 2.1.6].
ondics commented 1 year ago

If I remove the require-dev section and the symfonymailer to

"require": {
    "php": ">=7.4.0",
    "yiisoft/yii2": "~2.0.45",
    "yiisoft/yii2-apidoc": "~2.1.0"
},

then it works. But I need the yii2-symfonymailer!

ondics commented 1 year ago

Next error: ./yii help api results in:

# ./yii help api
Exception 'yii\di\NotInstantiableException' with message 'Failed to instantiate component or class "yii\gii\Module".'

in /app/yii2-app-basic/vendor/yiisoft/yii2/di/Container.php:509
Caused by: Exception 'ReflectionException' with message 'Class "yii\gii\Module" does not exist'
in /app/yii2-app-basic/vendor/yiisoft/yii2/di/Container.php:507

Stack trace:
#0 /app/yii2-app-basic/vendor/yiisoft/yii2/di/Container.php(507): ReflectionClass->__construct('yii\\gii\\Module')
#1 /app/yii2-app-basic/vendor/yiisoft/yii2/di/Container.php(385): yii\di\Container->getDependencies('yii\\gii\\Module')
#2 /app/yii2-app-basic/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('yii\\gii\\Module', Array, Array)
#3 /app/yii2-app-basic/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('yii\\gii\\Module', Array, Array)
#4 /app/yii2-app-basic/vendor/yiisoft/yii2/base/Module.php(445): yii\BaseYii::createObject(Array, Array)
#5 /app/yii2-app-basic/vendor/yiisoft/yii2/base/Application.php(313): yii\base\Module->getModule('gii')
#6 /app/yii2-app-basic/vendor/yiisoft/yii2/base/Application.php(271): yii\base\Application->bootstrap()
#7 /app/yii2-app-basic/vendor/yiisoft/yii2/console/Application.php(124): yii\base\Application->init()
#8 /app/yii2-app-basic/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\console\Application->init()
#9 /app/yii2-app-basic/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#10 /app/yii2-app-basic/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#11 /app/yii2-app-basic/yii(19): yii\console\Application->__construct(Array)
#12 {main}
mtangoo commented 1 year ago

then it works. But I need the yii2-symfonymailer!

What happens if you change version of mailer from ~2.0.3 to ~3.0.0?

mtangoo commented 1 year ago

Exception 'yii\di\NotInstantiableException' with message 'Failed to instantiate component or class "yii\gii\Module".'

Can you check if Gii module is defined in the console config?

ondics commented 1 year ago

then it works. But I need the yii2-symfonymailer!

What happens if you change version of mailer from ~2.0.3 to ~3.0.0?

/app/yii2-app-basic# composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires yiisoft/yii2-symfonymailer ~3.0.0 -> satisfiable by yiisoft/yii2-symfonymailer[3.0.0].
    - yiisoft/yii2-apidoc[2.1.0, ..., 2.1.6] require phpdocumentor/reflection-docblock ^2.0.4 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.5].
    - Conclusion: don't install phpdocumentor/reflection-docblock 2.0.5 (conflict analysis result)
    - Root composer.json requires yiisoft/yii2-apidoc ~2.1.0 -> satisfiable by yiisoft/yii2-apidoc[2.1.0, ..., 2.1.6].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
ondics commented 1 year ago

Exception 'yii\di\NotInstantiableException' with message 'Failed to instantiate component or class "yii\gii\Module".'

Can you check if Gii module is defined in the console config?

I'm using https://github.com/yiisoft/yii2-app-basic out of the box - Nothing modified in configs.

Do I have to modify config settings?

mtangoo commented 1 year ago

I'm using https://github.com/yiisoft/yii2-app-basic out of the box - Nothing modified in configs.

I thought this was problem only in docker which is not set in my machine. I will install it from Basic and check it out. Sorry for what you are facing. It should just work

mtangoo commented 1 year ago

Hi, Please remove vendor directory and composer.lock Change apidoc version to 3.0.6 i.e. "yiisoft/yii2-apidoc": "~3.0.6" Run composer install

when completed then run ./vendor/bin/apidoc help

Then let me know if you get everything successful!

ondics commented 1 year ago

Thx, seems to work.

I didn't know that I've to run ./vendor/bin/apidoc help.

I assumed apidoc can be called using ./yii command line executor. Maybe this should be clarified in the README.md

mtangoo commented 1 year ago

I didn't know that I've to run ./vendor/bin/apidoc help.

apidoc installs a command-line tool for doing the tasks

mtangoo commented 1 year ago

I will leave this open until doc is updated

neoacevedo commented 1 year ago

The issue comes with bootstrap5. Removed it from the requires section, apidoc can be installed.

This package has the dependency to yiisoft/yii2-bootstrap but if anyone need to install bootstrap5, then won't be able to install due to yii2-apidoc dependency.