无法重新声明CodeIgniter Helper类 [英] Cannot redeclare CodeIgniter Helper Class

查看:104
本文介绍了无法重新声明CodeIgniter Helper类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  [Fri Jul 27 03:08:18.935217 2018] [:error] [pid 11] [client 172.18.0.1:54146] PHP Fatal error:  Cannot redeclare CreateUniqeSlugOfuser() (previously declared in /var/www/public_html/livesite/application/helpers/MY_url_helper.php:111) in /var/www/public_html/livesite/application/helpers/my_url_helper.php on line 111

上面是错误,我认为这可能是将目录中的文件简单地重命名为MY_url_helper,但使用大写字母,但这不能解决错误正如一些网站所说。就目前情况而言,我不知道如何解决此问题,但我确实有一些线索。

Above is the error, I thought maybe this was a simple rename the file in my directory to MY_url_helper with the uppercase but this did not fix the error as some sites have said. As it stands I have no idea how to fix this but I do have some clues.

我不是代码点火专家,我从另一个开发人员那里接手了这个项目。 ,但目前可在其服务器上使用。但是,它在我的服务器上不起作用。看到问题可能与自动加载有关,我做错了什么?

I'm not a code igniter expert, I took on this project from another developer, but it currently works on their server. It does not work on my server however. Seeing as the issue is probably with autoloading, what could be the thing I'm doing wrong? Could a different version in PHP be causing this issue?

另一个预感可能是我必须更改某些缓存了吗?不过,我不确定...有什么想法。

Another hunch is maybe it's some cache I have to change? I'm not sure though... any ideas are appreciated.

我会说更改文件名后,错误仍然认为我使用的是小写版本吗?我知道它正在读取文件,因为我可以在文件中抛出phpinfo,看来从而触发我由此上传的图像。

I will say after changing the file name the error still thinks I'm using the lowercase version? I know it's reading the file cause I can throw phpinfo in the file and it seems to trigger hence the image I uploaded as a result of that.

更新::做了echo CI_VERSION命令来找到它(2.2.0)。也许此版本与PHP 7.0不兼容?

Update:: Did echo CI_VERSION command to find this (2.2.0). Maybe this version is not compatible with PHP 7.0?

php56肯定是另一台服务器上的版本...我将看看是否可以获得此的Docker映像

php56 is for sure the version on the other server... I will see if I can get a docker image of this somehow.

还是5.6错误。

Dockerfile

Dockerfile

FROM php:5.6-apache
MAINTAINER Joe Astrahan <jastrahan@poolservice.software>

RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y \
    bzip2 curl git less mysql-client sudo unzip zip \
    libbz2-dev libfontconfig1 libfontconfig1-dev \
    libfreetype6-dev libjpeg62-turbo-dev libpng-dev libzip-dev && \
    rm -rf /var/lib/apt/lists/*


RUN docker-php-ext-install bz2 && \
    docker-php-ext-configure gd \
        --with-freetype-dir=/usr/include/ \
        --with-jpeg-dir=/usr/include/ && \
    docker-php-ext-install gd && \
    docker-php-ext-install iconv && \
    docker-php-ext-install opcache && \
    docker-php-ext-install pdo_mysql && \
    docker-php-ext-install zip

RUN curl -sS https://getcomposer.org/installer \
    | php -- --install-dir=/usr/local/bin --filename=composer

# Set environment variables for Apache so we know its user and group names
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data

# Configure Apache SSL and Standard Virtualhosts
COPY config/apache_default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache_default-ssl.conf /etc/apache2/sites-available/default-ssl.conf
COPY config/run /usr/local/bin/run

# Configure SSL Directories & Create Temporary SSL Keys
RUN mkdir /etc/apache2/ssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt  -subj "/C=US/ST=Florida/L=Fort Lauderdale/O=Pool Service Software LLC/OU=IT Department/CN=dev.poolservice.software.local"

RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite

#Configure SSL On Apache2 & Headers Mod
RUN a2enmod ssl
RUN a2enmod headers
RUN service apache2 restart
RUN a2ensite default-ssl.conf
RUN service apache2 restart

#Install Zip & Unzip
RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install zip unzip -y

#Install NodeJS
RUN apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -y \
     software-properties-common

EXPOSE 80
EXPOSE 443

CMD ["/usr/local/bin/run"]


推荐答案

所以我解决了问题。事实证明,PHP版本并没有真正改变,我的docker文件因为可以使用而被更改为PHP 7.0,所以我将其附在下面。

So I solved the issue. Turns out PHP version didn't really make a difference, my docker file was changed to PHP 7.0 since it worked with that, I'll attach it below.

因为CodeIgniter 2.x使用的是mysql而不是mysqli,所以我相应地更改了代码中的所有引用。另外,我还不得不将文件my_url_helper重命名为urlhelper_helper,然后在自动加载文件中进行相应更改,以便加载正确的文件。由于某种原因,即使它可以在旧服务器上运行,我也必须这样做才能使其与任何版本的PHP一起使用。

It turns out that CodeIgniter 2.x was using mysql instead of mysqli, so I changed all references in the code accordingly. Also I had to rename the file my_url_helper to just urlhelper_helper and then in the autoload file change it accordingly so it would load the correct file. For some reason even though it worked on the old server, I had to do this to get it to work with either version of PHP.

这些修补程序都是必需的修复它。

These fixes were all that were necessary to fix it.

这篇关于无法重新声明CodeIgniter Helper类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆