代码之家  ›  专栏  ›  技术社区  ›  Joseph Astrahan

无法重新声明CodeIgniter帮助程序类

  •  0
  • Joseph Astrahan  · 技术社区  · 7 年前
      [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
    

    上面是错误,我想这可能是一个简单的重命名我的目录中的文件为我的url_helper的大写字母,但这并没有像一些网站所说的那样修复错误。目前我不知道如何解决这个问题,但我有一些线索。

    我不是一个代码点火专家,我从另一个开发人员那里接手了这个项目,但它目前在他们的服务器上工作。但是它在我的服务器上不工作。既然问题可能是自动加载,那么我做错了什么呢?PHP中的其他版本可能会导致此问题吗?

    enter image description here

    另一个预感可能是我得换个缓存?但我不确定。。。任何想法都值得赞赏。

    enter image description here

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

    Update::有没有echo CI_VERSION命令来查找这个(2.2.0)。也许这个版本与PHP7.0不兼容?

    php56肯定是另一台服务器上的版本。。。我看看能不能弄到一张码头工人的照片。

    5.6井仍有误差。

    enter image description here

    停靠文件

    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"]
    
    2 回复  |  直到 7 年前
        1
  •  0
  •   Alex    7 年前

    可能您已经在自动加载中加载了帮助程序,或者在尝试再次加载之前已初始化了某个类。CI能够防止类的重复,但不能防止纯php助手文件的重复。这就是为什么它们的功能围绕着:

    if (!function_exists('functionname')) { ... }

    我建议你也这样做。

        2
  •  0
  •   Joseph Astrahan    7 年前

    所以我解决了这个问题。结果发现PHP版本并没有真正起到作用,我的docker文件被改成了PHP 7.0,因为它可以使用它,我将在下面附加它。

    原来CodeIgniter 2.x使用的是mysql而不是mysql I,因此我相应地更改了代码中的所有引用。另外,我不得不将文件重命名为my url helper,使其仅为urlhelper,然后在自动加载文件中相应地更改它,以便加载正确的文件。出于某种原因,即使它在旧服务器上工作,我也必须这样做才能使它与两个版本的PHP一起工作。

    这些修复是修复它所必需的。

    推荐文章