WillyJimmyDev / simple-quiz

A simple quiz administration written in PHP with a MySQL backend. Uses Bootstrap 3 and Slim PHP micro framework
http://elanman.com/simple-quiz/
Apache License 2.0
165 stars 73 forks source link

class ORM error #28

Closed marcolucchese closed 7 years ago

marcolucchese commented 7 years ago

Hello, Thanks for the awesome application, I'd love to use this application, I followed all the instructions step-by-step but I keep getting this error Fatal error: Class 'ORM' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 4
I tried everything before contact you here, but I couldn't find a solution.

WillyJimmyDev commented 7 years ago

Hi, have you run the 'composer install' command from inside the main SimpleQuiz directory? It looks like the ORM class isn't being autoloaded. Running the above command should fix that.

marcolucchese commented 7 years ago

Yes I did, It says: Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating autoload files But I keep getting the same error about the ORM class Fatal error: Class 'ORM' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 4

WillyJimmyDev commented 7 years ago

OK, not sure what's going on here. I've just cloned the github repo to my local machine, ran the 'composer install' command, changed db credentials etc and everything worked as it should. Where are you getting the code from? Github or SourceForge? Try adding the following to the top of public/index.php or see if there is any more information in /var/log/apache2/error.log

ini_set('error_reporting', E_ALL); ini_set('display_errors', 1);

marcolucchese commented 7 years ago

Thank for all the help you're giving me! I added the lines at the top of index.php, unfortunately the error is still the same: Fatal error: Class 'ORM' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 5 I cloned the github repo. This is the error.log [Sun Oct 16 09:08:36.983132 2016] [mpm_prefork:notice] [pid 4202] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 configured -- resuming normal operations [Sun Oct 16 09:08:36.983242 2016] [core:notice] [pid 4202] AH00094: Command line: 'apache2' [Sun Oct 16 09:09:03.369160 2016] [:error] [pid 4220] [client 10.240.0.185:54836] PHP Warning: require(../vendor/autoload.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/index.php on line 2 [Sun Oct 16 09:09:03.369208 2016] [:error] [pid 4220] [client 10.240.0.185:54836] PHP Fatal error: require(): Failed opening required '../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/index.php on line 2 [Sun Oct 16 09:09:11.296660 2016] [:error] [pid 4221] [client 10.240.0.225:36260] PHP Warning: require(../vendor/autoload.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/index.php on line 2 [Sun Oct 16 09:09:11.296708 2016] [:error] [pid 4221] [client 10.240.0.225:36260] PHP Fatal error: require(): Failed opening required '../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/index.php on line 2 [Sun Oct 16 09:09:25.911147 2016] [mpm_prefork:notice] [pid 4202] AH00169: caught SIGTERM, shutting down [Sun Oct 16 09:09:49.290311 2016] [mpm_prefork:notice] [pid 4810] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 configured -- resuming normal operations [Sun Oct 16 09:09:49.290368 2016] [core:notice] [pid 4810] AH00094: Command line: 'apache2' [Sun Oct 16 09:09:57.999602 2016] [mpm_prefork:notice] [pid 4810] AH00169: caught SIGTERM, shutting down [Sun Oct 16 09:10:22.554618 2016] [mpm_prefork:notice] [pid 5350] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 configured -- resuming normal operations [Sun Oct 16 09:10:22.554688 2016] [core:notice] [pid 5350] AH00094: Command line: 'apache2' [Sun Oct 16 09:10:28.273912 2016] [:error] [pid 5357] [client 10.240.1.18:43848] PHP Warning: require(../vendor/autoload.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/index.php on line 2, referer: https://-----------/quizbeta [Sun Oct 16 09:10:28.273956 2016] [:error] [pid 5357] [client 10.240.1.18:43848] PHP Fatal error: require(): Failed opening required '../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/index.php on line 2, referer: https://-------------/quizbeta [Sun Oct 16 09:14:01.569109 2016] [mpm_prefork:notice] [pid 5350] AH00169: caught SIGTERM, shutting down [Sun Oct 16 11:49:29.084925 2016] [mpm_prefork:notice] [pid 10661] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 configured -- resuming normal operations [Sun Oct 16 11:49:29.084977 2016] [core:notice] [pid 10661] AH00094: Command line: 'apache2' [Sun Oct 16 11:49:33.214834 2016] [:error] [pid 10668] [client 10.240.0.224:58838] PHP Fatal error: Class 'SimpleQuiz\\Utils\\Base\\Config' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 4, referer: https://-----------/quizbeta [Sun Oct 16 11:49:40.031096 2016] [mpm_prefork:notice] [pid 10661] AH00169: caught SIGTERM, shutting down [Sun Oct 16 11:50:16.556141 2016] [mpm_prefork:notice] [pid 11194] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 configured -- resuming normal operations [Sun Oct 16 11:50:16.556205 2016] [core:notice] [pid 11194] AH00094: Command line: 'apache2' [Sun Oct 16 11:50:23.459451 2016] [core:info] [pid 11203] [client 10.240.0.215:49286] AH00128: File does not exist: /home/ubuntu/workspace/favicon.ico, referer: https://-----------------/simple-quiz/Utils/Base/Installer.php [Sun Oct 16 11:50:40.648379 2016] [:error] [pid 11204] [client 10.240.0.224:59946] PHP Fatal error: Class 'SimpleQuiz\\Utils\\Base\\Config' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 4, referer: https://----------------/simple-quiz/ [Sun Oct 16 11:51:09.389158 2016] [:error] [pid 11205] [client 10.240.0.225:43106] script '/home/ubuntu/workspace/simple-quiz/public/index.php' not found or unable to stat [Sun Oct 16 11:51:15.280797 2016] [:error] [pid 11202] [client 10.240.0.181:59926] PHP Fatal error: Class 'ORM' not found in /home/ubuntu/workspace/simple-quiz/index.php on line 4, referer: https://-----------/ [Sun Oct 16 11:51:37.461740 2016] [mpm_prefork:notice] [pid 11194] AH00169: caught SIGTERM, shutting down

WillyJimmyDev commented 7 years ago

OK, it can't find your vendor/autoload.php file. What is the structure of your files? Is the vendor directory on the same level as the public directory as shown in the readme?

marcolucchese commented 7 years ago

Yes,I checked multiple times. This is the structure I have: capture7

WillyJimmyDev commented 7 years ago

Where is the document root on your web server pointing to? I notice you have script '/home/ubuntu/workspace/simple-quiz/public/index.php' not found and also Class 'ORM' not found in /home/ubuntu/workspace/simple-quiz/index.php in your log files which point to different index.php files.

marcolucchese commented 7 years ago

That is because I've tried moving the index file from public to simple-quiz, that's why I said that I've tried nearly everything :) (put back after that failed try) . The document root should be simple-quiz

WillyJimmyDev commented 7 years ago

If you just change the contents of index.php file to <?php echo 'hello'; ?> what do you see when you try to load the page?

marcolucchese commented 7 years ago

It prints hello

WillyJimmyDev commented 7 years ago

can you try running 'composer dump-autoload' to regenerate the autoload.php file?

marcolucchese commented 7 years ago

Same error: Fatal error: Class 'ORM' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 5

WillyJimmyDev commented 7 years ago

OK, just have the following in index.php... <?php include('../vendor/autoload.php'); ?>

marcolucchese commented 7 years ago

No errors, blank page

WillyJimmyDev commented 7 years ago

Change it to require instead of include

marcolucchese commented 7 years ago

Same, blank page

WillyJimmyDev commented 7 years ago

OK, so it's finding the autoload.php file. Try adding the following line: $session = new \SimpleQuiz\Utils\Session();

marcolucchese commented 7 years ago

I get this error: Fatal error: Class 'SimpleQuiz\Utils\Session' not found in /home/ubuntu/workspace/simple-quiz/public/index.php on line 2

WillyJimmyDev commented 7 years ago

I've just noticed in your screenshot. You should have the Utils and Tests folders inside a SimpleQuiz folder...

marcolucchese commented 7 years ago

Yes because I tried moving thing in and out trying to run it. capture8 Now I'm getting this error: `Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php:255 Stack trace: #0 /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php(255): PDO->construct('sqlite::memory:', NULL, NULL, NULL) #1 /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php(237): ORM::_setup_db('default') #2 /home/ubuntu/workspace/simple-quiz/SimpleQuiz/Utils/Session.php(73): ORM::for_table('sessions') #3 [internal function]: SimpleQuiz\Utils\Session->read('m89cutnlf43dnen...') #4 /home/ubuntu/workspace/simple-quiz/SimpleQuiz/Utils/Session.php(22): session_start() #5 /home/ubuntu/workspace/simple-quiz/public/index.php(2): SimpleQuiz\Utils\Session->construct() #6 {main} thrown in /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php on line 255

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php:255 Stack trace: #0 /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php(255): PDO->__construct('sqlite::memory:', NULL, NULL, NULL) #1 /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php(237): ORM::_setup_db('default') #2 /home/ubuntu/workspace/simple-quiz/SimpleQuiz/Utils/Session.php(82): ORM::for_table('sessions') #3 [internal function]: SimpleQuiz\Utils\Session->write('m89cutnlf43dnen...', '') #4 {main} thrown in /home/ubuntu/workspace/simple-quiz/vendor/j4mie/idiorm/idiorm.php on line 255` Thanks for all your help

WillyJimmyDev commented 7 years ago

OK, we're getting somewhere :) You need the PDO driver installed. Change index.php to <?php phpinfo(); ?> and look for the PDO extension in the output

marcolucchese commented 7 years ago

I'm getting this: `PDO

PDO support enabled PDO drivers mysql, pgsql

pdo_mysql

PDO Driver for MySQL enabled Client API version 5.5.50

Directive Local Value Master Value pdo_mysql.default_socket /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock

pdo_pgsql

PDO Driver for PostgreSQL enabled PostgreSQL(libpq) Version 9.3.11 Module version 1.0.2 Revision $Id$`

Additional .ini files parsed /etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-gd.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-mcrypt.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-pdo_pgsql.ini, /etc/php5/apache2/conf.d/20-pgsql.ini, /etc/php5/apache2/conf.d/20-readline.ini, /etc/php5/apache2/conf.d/80-c9.ini

WillyJimmyDev commented 7 years ago

For some reason. ORM is trying to use its default setting of using a sqlite db instead of mysql. That's why you are seeing a 'could not find driver' message. Are you using the original index.php file which sets the ORM::configure options to use mysql?

marcolucchese commented 7 years ago

Yes, I've cloned it from github and I've edited just the config php file, is there anything I can do to find this? I've even tried installing it again, but no luck