rick645 Posted February 13, 2023 Share Posted February 13, 2023 $ cat docker-compose.yml version: '2' services: php: image: yiisoftware/yii2-php:7.4-apache volumes: - ~/.composer-docker/cache:/root/.composer/cache:delegated - ./:/app:delegated ports: - '8000:80' $ docker-compose up -d Starting yii_php_1 ... done $ curl http://localhost:8000/ <br /> <b>Fatal error</b>: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.4.33. in <b>/app/vendor/composer/platform_check.php</b> on line <b>24</b><br /> ???? Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/ Share on other sites More sharing options...
kicken Posted February 13, 2023 Share Posted February 13, 2023 Your application has a composer.json file that specifies a minimum PHP version of 8.1, but the docker image you created uses version 7.4 You need to use a newer container that is built using PHP 8.1 or newer. Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/#findComment-1605604 Share on other sites More sharing options...
rick645 Posted February 14, 2023 Author Share Posted February 14, 2023 I haven't created anything, I only did what they say $ curl -s https://www.yiiframework.com/doc/guide/2.0/en/start-installation | grep -m1 create-project <pre><code class="hljs bash language-bash">composer create-project --prefer-dist yiisoft/yii2-app-basic basic and therefore $ composer create-project --prefer-dist yiisoft/yii2-app-basic basic Creating a "yiisoft/yii2-app-basic" project at "./basic" Info from https://repo.packagist.org: #StandWithUkraine Installing yiisoft/yii2-app-basic (2.0.47) [CUT] $ grep image basic/docker-compose.yml image: yiisoftware/yii2-php:7.4-apache Version 7.4!!! ????.................??????????.......... Are they not themselves making these packages? Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/#findComment-1605630 Share on other sites More sharing options...
kicken Posted February 14, 2023 Share Posted February 14, 2023 yiisoft/yii2-app-basic seems to be setup for 7.4. Giving things a test I think this is what happened. Part of the create-project process is to run composer install to install the dependencies. This would be done on your host which probably has PHP 8.1 installed. Since the install was done using PHP 8.1, some of the dependencies has versions requiring PHP 8.1 installed. When you try and load the web page, it's using the PHP version in the docker container, which is 7.4. Since some of the installed dependencies require higher, it fails. You need to remove your existing vendor folder and composer.lock file and re-install the dependencies using the composer tool in the docker container. rm -r vendor/ composer.lock docker exec basic_php_1 composer install Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/#findComment-1605631 Share on other sites More sharing options...
rick645 Posted February 14, 2023 Author Share Posted February 14, 2023 57 minutes ago, kicken said: Quote yiisoft/yii2-app-basic seems to be setup for 7.4. Giving things a test I think this is what happened. ???? bah... Quote Part of the create-project process is to run composer install to install the dependencies. This would be done on your host which probably has PHP 8.1 installed. But here https://www.yiiframework.com/doc/guide/2.0/en/start-installation it doesn't seem to me that nothing like this is written. Couldn't they document it? Quote Since the install was done using PHP 8.1, some of the dependencies has versions requiring PHP 8.1 installed. ???? Quote When you try and load the web page, it's using the PHP version in the docker container, which is 7.4. Since some of the installed dependencies require higher, it fails. As already mentioned at the beginning, I do not understand why, in the docker-compose.yml file, they specified version 7.4 Quote You need to remove your existing vendor folder and composer.lock file and re-install the dependencies using the composer tool in the docker container. rm -r vendor/ composer.lock docker exec basic_php_1 composer install OK, but Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/#findComment-1605634 Share on other sites More sharing options...
Solution kicken Posted February 14, 2023 Solution Share Posted February 14, 2023 3 hours ago, rick645 said: Couldn't they document it This is a docker-specific problem and their documentation does not appear to cover docker usage. 3 hours ago, rick645 said: OK, but The error tells you essentially what to do, and this is also documented in the Installing from an Archive File section. Quote 3. Modify the config/web.php file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer): // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 'cookieValidationKey' => 'enter your secret key here', Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/#findComment-1605636 Share on other sites More sharing options...
rick645 Posted February 15, 2023 Author Share Posted February 15, 2023 thanks Quote Link to comment https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/#findComment-1605710 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.