Jump to content

docker-compose and yii2 not work


Go to solution Solved by kicken,

Recommended Posts

$ 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 />

????

Link to comment
https://forums.phpfreaks.com/topic/315907-docker-compose-and-yii2-not-work/
Share on other sites

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?

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

 

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

1335904269_Schermataa2023-02-1410-55-19.thumb.png.5987845f92eccb8e07c66b7dad39e107.png

  • Solution
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',

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.