I installed yii2 through composer:
composer require yiisoft/yii2
And followed this Guide on using Yii2 with a Yii1 application:
When running my app, an error occurs because the following file can’t be found:
The file really isnt there, but the file is listed on the github project page:
This file has been truncated.
* Yii core class map.
* This file is automatically generated by the "build classmap" command under the "build" folder.
* Do not modify it directly.
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
'yii\base\Action' => YII2_PATH . '/base/Action.php',
'yii\base\ActionEvent' => YII2_PATH . '/base/ActionEvent.php',
'yii\base\ActionFilter' => YII2_PATH . '/base/ActionFilter.php',
'yii\base\Application' => YII2_PATH . '/base/Application.php',
'yii\base\ArrayAccessTrait' => YII2_PATH . '/base/ArrayAccessTrait.php',
'yii\base\Arrayable' => YII2_PATH . '/base/Arrayable.php',
'yii\base\ArrayableTrait' => YII2_PATH . '/base/ArrayableTrait.php',
Is the installation through composer not complete?
Is the guide not up to date?
This is displayed after requiring yii2 through composer:
-bash-4.2$ composer require yiisoft/yii2
Using version ^2.0@dev for yiisoft/yii2
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
- Installing yiisoft/yii2-composer (dev-master 99e52c7): Cloning 99e52c7aa9
- Installing cebe/markdown (1.1.2): Loading from cache
- Installing psr/http-message (dev-master efd67d1): Cloning efd67d1dc1
- Installing psr/simple-cache (dev-master 408d5ea): Cloning 408d5eafb8
- Installing psr/log (1.0.2): Loading from cache
- Installing yiisoft/yii2 (2.1.x-dev 86f1bfd): Cloning 86f1bfd701
yiisoft/yii2 suggests installing ezyang/htmlpurifier (version '~4.6' required at 'yii\helpers\HtmlPurifier' for 'html' data format support (e.g. 'yii\i18n\Formatter:asHtml()' and 'yii\helpers\StringHelper::truncateHtml()'))
Writing lock file
Generating autoload files
classes.php is in the framework dir.
After quite some reading, and lots of trial and error, I found these lines of code has to be added to composer.json of your project:
Else composer won’t download yii version 2.0.x,
and the asset dependencies also will download instead of these errors:
yiisoft/yii2 2.0.32 requires bower-asset/jquery 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable -> no matching package found.
It looks like the
dependency section of the yii2 framework does not bubble up to project level if yii2 is not installed yet, while it’s needed there already?
Looks weird but I remember something like that was reported before. I wasn’t able to fine the reason though…
So, should the docs on how to install yii2 through composer be updated?
Or does the package on packagist contain a bug/wrong version info?
(I am really very new with composer, so maybe I don’t quite get it yet!)