Closed garrettw closed 2 years ago
Can you post the commands you run?
There's no yii
by default on an image.
root@f557761a3c07:/app# echo $PATH
/app:/app/vendor/bin:/root/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root@f557761a3c07:/app# which yii
Right, but there is in /app/vendor/bin
as long as composer install
has run. If I have reported this to the wrong repo, do let me know what repo I should report it on.
docker-compose.yml:
version: '3'
services:
php-apache:
build: ./docker
ports:
- "80:80"
- "443:443"
volumes:
- ~/.composer-docker/cache:/root/.composer/cache:cached
- .:/app:cached
networks:
- default
links:
- 'test_mysql'
test_mysql:
image: mysql:5.7.24
container_name: testmysql
ports:
- "6603:3306"
environment:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: "mypassword"
volumes:
- ./docker/dbdata:/var/lib/mysql
networks:
- default
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: 10.20.22.0/24
volumes:
dbdata:
driver: local
docker/Dockerfile:
FROM yiisoftware/yii2-php:7.3-apache
ENV DEBIAN_FRONTEND=noninteractive
# mkdir is for installing java for pdftk
RUN mkdir -p /usr/share/man/man1; \
apt-get update \
&& apt-get install -y gnupg2 \
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-key update \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
nodejs \
g++ \
git \
curl \
imagemagick \
libfreetype6-dev \
libcurl3-dev \
libicu-dev \
libfreetype6-dev \
libjpeg-dev \
libjpeg62-turbo-dev \
libmagickwand-dev \
libpq-dev \
libpng-dev \
libxml2-dev \
libzip-dev \
zlib1g-dev \
default-mysql-client \
openssh-client \
nano \
unzip \
xmlsec1\
pdftk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN npm install -g yarn \
&& yarn install
# Add configuration files
COPY 000-default.conf /etc/apache2/sites-available/
COPY ssl-cert-snakeoil.pem /etc/ssl/certs/
COPY ssl-cert-snakeoil.key /etc/ssl/private/
# Create a symlink for apache (if `/var/www/html` is available)
RUN (rm -rf /var/www/html && mkdir /var/www/html && ln -s /app/web/ /var/www/html) || true
RUN a2enmod ssl
RUN chmod -R 777 /var/log
composer.json: (I know some deps need updating, I'm handling those separately)
{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "~2.0.15",
"yiisoft/yii2-jui": "~2.0.0",
"yiisoft/yii2-bootstrap4": "~2.0.6",
"yiisoft/yii2-swiftmailer": "~2.0.0",
"yiisoft/yii2-composer": "~2.0.4",
"setasign/fpdi-fpdf": "1.6.1",
"mikehaertl/php-pdftk": "0.5.0",
"aws/aws-sdk-php": "^3.55",
"phpseclib/phpseclib": "^2.0"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",
"yiisoft/yii2-gii": "~2.0.0",
"yiisoft/yii2-faker": "~2.0.0",
"codeception/base": "^2.2.3",
"codeception/verify": "~0.3.1",
"codeception/specify": "~0.4.3"
},
"config": {
"process-timeout": 1800,
"fxp-asset": {
"enabled": false
}
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
]
},
"extra": {
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}
Do you have a yii
executable in /app
?
[edit] Can you run /app/yii
?
@schmunk42 yes -- I just don't understand why I have to have that file instead of being able to rely on vendor/bin/yii
. (What is the point of the latter if it doesn't even work?)
The yii
file basically defines which configs to load for your console application.
The latter does not load any config at all (just uses defaults), or? https://github.com/yiisoft/yii2/blob/master/framework/yii
What's the usefulness of it then, if it doesn't even load a db config?
It's not that useful. I guess we have it for historical reasons (I forgot to remove it after moving entry point to the application) but I might be wrong since it was about 10 years ago when I did that.
@samdark Instead of removing it, why not make it more useful along the lines of the yii
file included in the app template?
Because vendor location might get customized, it might be symlinked and it's very non-trivial to determine location of the app correctly from within vendor's yii.
You should be able to load a custom config like so:
yii help --appconfig=/app/config/main.php
[addon] see also https://www.yiiframework.com/doc/guide/2.0/en/tutorial-console#configuration
I have noticed when using the official yii2 docker image that running the
yii
command in the project root (which refers tovendor/bin/yii
according to thePATH
set in the container) always complains about not being able to instantiate the db class. I was able to determine that it is not loading myconfig/console.php
file.In order to get it working, I had to include the
yii
file from the basic app template in my project root, set it as executable, and restart my terminal -- so then theyii
command refers to this new file.Is this a bug? It sure seems like it is. If not, am I doing something wrong? I would prefer not to include the extra executable in my project if possible.