I’m encountering an issue where error messages in my CodeIgniter 3 application are displaying differently between my local development environment and my server environment where Docker is being used.
In my local environment (Windows host), when I encounter a validation error, such as a required field not being filled in, the error message includes the variable name, like “The Username field is required.”
However, when I deploy the same application to my server environment (Ubuntu host with Docker), the error message does not include the variable name; instead, it just says “The field is required.”
Both environments are running PHP 8.3, and I’ve ensured that the CodeIgniter version is the same (3.x). I’ve checked the PHP error reporting settings, and they seem to be consistent between environments.
my docker composer file
version: '3'
services:
db:
build:
context: .
dockerfile: docker/mysql/Dockerfile
restart: always
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_DATABASE: ${MARIADB_DATABASE}
volumes:
- ./db_data:/usr/data
ports:
- "3309:3306"
web:
build:
context: .
dockerfile: docker/apache/Dockerfile
restart: unless-stopped
volumes:
- .:/var/www/html
- ./apache_log:/var/log/apache2
ports:
- 84:80
depends_on:
- db
links:
- db
adminer:
image: adminer
restart: unless-stopped
ports:
- 8084:8080
my docker file
# use php 8.3 apache image
FROM php:8.3-apache
# Update it
RUN apt-get update
# install necessary libraries
RUN apt-get install -y
git
zip
curl
sudo
unzip
libicu-dev
libbz2-dev
libpng-dev
libjpeg-dev
libmcrypt-dev
libreadline-dev
libfreetype6-dev
g++
# install docker extensions
RUN docker-php-ext-install
bz2
intl
bcmath
opcache
calendar
pdo_mysql
mysqli
# set up document root for apache
COPY docker/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
# mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers
# start with base php config, then add extensions
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
# composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN composer self-update
COPY . /var/www/html/
RUN chown -R www-data:www-data /var/www/html &&
chmod -R 755 /var/www/html
EXPOSE 80
I examined the config.php and database.php files in my CodeIgniter application to see if there are any environment-specific configurations that could affect error message formatting. However, I couldn’t find anything