yiisoft / demo

Yii 3 demo application
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
318 stars 133 forks source link

Commit composer.lock to repository #165

Open BoShurik opened 4 years ago

BoShurik commented 4 years ago

This is not a library and most of the changes relates to specific package versions/commits so commit composer.lock, package-lock.json and yarn.lock would be ok

samdark commented 4 years ago

We don't need package-lock.json and yarn.lock anymore since foxy was replaced with asset-packagist in demo and app.

samdark commented 4 years ago

It's alright to have it.

lubosdz commented 2 years ago

Well, that foxy needs some polishing .. cannot make work composer update, cannot downgrade PHP below 8.0 :-| Using phar composer 2.2.5 (latest).

......
  - Locking yiisoft/yii-http (1.0.0)
  - Locking yiisoft/yii-middleware (dev-master 38ad72a)
  - Locking yiisoft/yii-runner (1.0.0)
  - Locking yiisoft/yii-runner-console (1.0.0)
  - Locking yiisoft/yii-runner-http (1.0.0)
  - Locking yiisoft/yii-swagger (1.1.0)
  - Locking yiisoft/yii-view (4.0.2)
  - Locking yosymfony/resource-watcher (v2.0.1)
  - Locking zircote/swagger-php (4.2.4)
Writing lock file
Installing dependencies from lock file (including require-dev)

Fatal error: Uncaught TypeError: Composer\Package\Locker::__construct(): Argument #3 ($installationManager) must be of type Composer\Installer\InstallationManager, Composer\Repository\RepositoryManager given, called in D:\_projects\yii3\yii-demo\vendor\foxy\foxy\Util\LockerUtil.php on line 41 and defined in phar://D:/_projects/composer-2.2.5.phar/src/Composer/Package/Locker.php:63
Stack trace:
#0 D:\_projects\yii3\yii-demo\vendor\foxy\foxy\Util\LockerUtil.php(41): Composer\Package\Locker->__construct(Object(Composer\IO\ConsoleIO), Object(Composer\Json\JsonFile), Object(Composer\Repository\RepositoryManager), Object(Composer\Installer\InstallationManager), '{\n    "name": "...')
#1 D:\_projects\yii3\yii-demo\vendor\foxy\foxy\Fallback\ComposerFallback.php(101): Foxy\Util\LockerUtil::getLocker(Object(Composer\IO\ConsoleIO), Object(Composer\Repository\RepositoryManager), Object(Composer\Installer\InstallationManager), './composer.json')
#2 D:\_projects\yii3\yii-demo\vendor\foxy\foxy\Foxy.php(179): Foxy\Fallback\ComposerFallback->save()
#3 [internal function]: Foxy\Foxy->init(Object(Composer\Installer\InstallerEvent))
#4 phar://D:/_projects/composer-2.2.5.phar/src/Composer/EventDispatcher/EventDispatcher.php(192): call_user_func(Array, Object(Composer\Installer\InstallerEvent))
#5 phar://D:/_projects/composer-2.2.5.phar/src/Composer/EventDispatcher/EventDispatcher.php(152): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Installer\InstallerEvent))
#6 phar://D:/_projects/composer-2.2.5.phar/src/Composer/Installer.php(714): Composer\EventDispatcher\EventDispatcher->dispatchInstallerEvent('pre-operations-...', true, true, Object(Composer\DependencyResolver\LocalRepoTransaction))
#7 phar://D:/_projects/composer-2.2.5.phar/src/Composer/Installer.php(583): Composer\Installer->doInstall(Object(Composer\Repository\InstalledFilesystemRepository), true)
#8 phar://D:/_projects/composer-2.2.5.phar/src/Composer/Installer.php(279): Composer\Installer->doUpdate(Object(Composer\Repository\InstalledFilesystemRepository), true)
#9 phar://D:/_projects/composer-2.2.5.phar/src/Composer/Command/InstallCommand.php(139): Composer\Installer->run()
#10 phar://D:/_projects/composer-2.2.5.phar/vendor/symfony/console/Command/Command.php(245): Composer\Command\InstallCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar://D:/_projects/composer-2.2.5.phar/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 phar://D:/_projects/composer-2.2.5.phar/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\InstallCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 phar://D:/_projects/composer-2.2.5.phar/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 phar://D:/_projects/composer-2.2.5.phar/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 phar://D:/_projects/composer-2.2.5.phar/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 phar://D:/_projects/composer-2.2.5.phar/bin/composer(83): Composer\Console\Application->run()
#17 D:\_projects\composer-2.2.5.phar(29): require('phar://D:/_proj...')
#18 {main}
  thrown in phar://D:/_projects/composer-2.2.5.phar/src/Composer/Package/Locker.php on line 63
vjik commented 2 years ago

@lubosdz maybe foxy/foxy don't support composer 2.2? Try composer 2.1.

lubosdz commented 2 years ago

So it worked finally with composer 2.0.14 (probably 2.0.X branch) - with warnings not supported version of composer, PHP. Configured CLI PHP path to 8.0.13. Installing 125 installs, 87 updates, 25 removals. Crash yii-console has unpushed changes ... Deleted again whole vendor directory and ran composer install. Installing 222 installs, 0 updates, 0 removals. Now it worked. Another exception - required PHP >= 8.0.2 for HTTP requests. OK, switched WAMP to 8.0.13. Next exception .env invalid path. OK - created .env file from env.example. IMO .env file should not be required, but assume default DEVEL settings if not found. Next exception Class "Cycle\Database\Config\SQLiteDriverConfig" not found in yii-demo\config\params.php in line 153: I gave up, file is missing in repo, cannot make running yii3 demo :-(

Few notes:

samdark commented 2 years ago

Thanks for feedback, @lubosdz.

I've re-tested starting from scratch:

git clone git@github.com:yiisoft/demo.git
cd demo
composer install
./yii serve

Then opened http://localhost:8080/ and got a working demo.

Things to be improved:

  1. Yii3 could be installed with Composer 2 only since version 1 doesn't see many of it's packages at all (that was announced by Composer team wheny they've deprecated version 1). I don't think we can improve it but mentioning it is a good idea.
  2. During composer install it asks for trusting plugins. That could be part of composer.json so it installs right away.
  3. Dependencies should be reviewed, indeed. While Yii 3 is divided into many packages, removing unnecessary onces is a good idea.
  4. PHP 8 is already 34% of all PHP installations and is going up. I assume that it will increase soon and that older PHP versions are used in legacy projects while new ones are started with new PHP versions.
  5. We suck at marketing, I know. But overall:
    • It is less magic. It is, actually, quite strict in practices used.
    • It has nearly 100% test/type coverage.
    • It it leveraging and implementing PSRs.
    • It suits projects of any sizes and any architectures.
    • No vendor lock. It is wide open to PHP community in general.
    • Suits TDD and unit-testing well.
    • Aids you during debug with great error screen, logs, friendly exceptions etc.
    • Code you write is the code executed. No pre-generation is involved.
lubosdz commented 2 years ago

@samdark Thank you for feedback. Yes, trusted plugins should be directly committed to composer file and unnecessary packages removed. I re-tested demo site once again today on another computer - following exact steps you wrote above. And yes - it worked now - but partially. No missing Cycle config file anymore. The difference I see:

I may try to debug & supply PR if I have more time, unless won't be fixed till then.

samdark commented 2 years ago

Yes, that's known thing. Currently there's no support for subdirectories out of the box and it should be added via https://github.com/yiisoft/yii-middleware/blob/master/src/SubFolder.php to the main middleware settings. That was done to avoid unneeded entry point calculations in case there's no sub-directory involved (which is majority of cases).