SamuelTallet / MongoDB-PHP-GUI

Open-source graphical interface for MongoDB database. Written in PHP, JavaScript, HTML & CSS.
142 stars 33 forks source link

Fatal error: Uncaught Error: Class 'Controllers\LoginController' not found in routes.php #3

Closed itschrono closed 3 years ago

itschrono commented 3 years ago

Hello, I cannot get it to work with docker php-fpm 7.2. => PHP Fatal error: Uncaught Error: Class 'Controllers\LoginController' not found in routes.php

Should I install / enable another extension along mongodb ??? Thanks

SamuelTallet commented 3 years ago

Hello! :) MongoDB is the only required extension. Did you run composer install? And can you share your Docker files? Thanks.

itschrono commented 3 years ago

Dockerfile:

FROM php:7.2-fpm

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

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

RUN apt-get update
RUN pecl install mongodb
RUN apt-get install zip unzip
RUN docker-php-ext-enable mongodb

RUN rm -Rf /var/www/mongogui_src/
RUN mkdir -p /var/www/mongogui_src/
RUN mkdir -p /var/www/mongogui/
COPY ./src/* /var/www/mongogui_src/
WORKDIR /var/www/mongogui/

RUN mkdir -p /app
COPY run.sh /app/
# RUN composer install
# RUN composer update
# RUN composer dump-autoload --optimize

EXPOSE 9000

run.sh:

rm -Rf /var/www/mongogui/* && mkdir -p /var/www/mongogui/ && cp -R /var/www/mongogui_src/* /var/www/mongogui/ && composer install && composer dump-autoload --optimize && php-fpm

compose file:

  mongogui:
    container_name: mongogui
    build: ./mongodb-php-gui
    command: "sh /app/run.sh"
    ports:
      - 9000:9000
    networks:
      - api-network
      - db-network
    volumes:
      - mongogui_volume:/var/www/mongogui
itschrono commented 3 years ago

And when I target /index.php directly I have a weird redirect to /index.php/index too...

SamuelTallet commented 3 years ago

Can you try to remove && composer dump-autoload --optimize from run.sh script?

itschrono commented 3 years ago

I added it after to try fixing it so I guess it is not the culprit.

jsl04 commented 3 years ago

What do I do after running composer install? Is it running? What steps do I need to do to access the GUI?

SamuelTallet commented 3 years ago

@jsl04

  1. Check if MongoDB PHP extension is enabled
  2. Go to project dir & run php -S 127.0.0.1:5000
  3. Open your browser at: http://127.0.0.1:5000/
SamuelTallet commented 3 years ago

I commited a Dockerfile and a little doc related to Docker. If problem persists, feel free to re-open an issue.

itschrono commented 3 years ago

Thanks a lot, work like a charm. Although I modified it a bit to be ssl friendly:

FROM php:7.4-cli-alpine
RUN apk update && apk upgrade

# Clone project repository.
RUN apk add --no-cache git
WORKDIR /opt/mongodb-php-gui
RUN git clone https://github.com/SamuelTS/MongoDB-PHP-GUI.git .

# Enable MongoDB PHP ext.
RUN apk add --no-cache autoconf build-base
RUN apk add --no-cache curl-dev openssl-dev
RUN pecl install mongodb-1.8.2 && docker-php-ext-enable mongodb
RUN pecl config-set php_ini /etc/php.ini

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

# Start PHP built-in server.
EXPOSE 5000
CMD ["php", "-S", "0.0.0.0:5000"]
SamuelTallet commented 3 years ago

@itschrono Thanks for the "SSL friendly" patch 😉