I have few controllers in my zf2 project which work perfectly in the browser using apache and via command line.
However, I recently installed MongoDb so I can store some data using the driver found in (http://php.net/manual/en/set.mongodb.php)
My issue is, when I try to access the driver via controller + browser, I get the following message error in my apache logs :
PHP Fatal error: Class 'MongoDb\Driver\Manager' not found.
'MongoDb\Driver\Manager' is the namespace for this Driver.
If I execute some other controllers via command line, MongoDb works correctly.
Does anyone know why is this happening? I cannot see the issue :(
Thank you
I found that my php.ini was pointing to mongo.so instead of mongodb.so
That fixed the issue
http://php.net/manual/en/mongodb.installation.manual.php
Thank you for your help
Related
I am trying to initialize php unit testing with my wordpress plugin using phpunit. I am running xampp on windows. My xampp installation is also on my E: drive if that makes any difference. I am following along with this tutorial:
https://www.smashingmagazine.com/2017/12/automated-testing-wordpress-plugins-phpunit/
I have gotten to the part where I run
install-wp-tests.sh wordpress_test root '' localhost latest
I run that and it pops up and closes quickly, so I don't know if it is really working or not. I then try to run
phpunit tests/test-sample.php
and I get:
PHP Fatal error: Class 'WP_UnitTestCase' not found in E:\xampp\htdocs\wp-content\plugins\SRBC\tests\test-sample.php on line 11
Fatal error: Class 'WP_UnitTestCase' not found in E:\xampp\htdocs\wp-content\plugins\SRBC\tests\test-sample.php on line 11
I assume that means the install-wp-test.sh isn't installing correctly and it is missing those classes. Any ideas?
Ended up needing to install SVN for windows. Also had to add the mysqladmin.exe path to the PATH environment variable. Then finally needed this :
https://wordpress.stackexchange.com/questions/249402/error-when-setting-up-phpunit-tests-with-wp-cli-scaffold
And after all that and 3 hours! I got it to work correctly!
Hope this helps someone else.
Since I've upgraded to Laravel version 5.6 from Laravel version 5.5 my Logger doesn't work properly anymore.
At first I got the following error stack :
laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /home/vagrant/Code/grotesmurf/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:181)
which was solved by simply adding the new config/logging.php file that is provided by Laravel 5.6.
But now I'm getting no output from the Logger! I'm simply running \Log::info('hello!') as a tinker command, but it doesn't generate any log output anymore (same for scripts calling the \Log() method).
I've tried different LOG_CHANNEL settings (daily, single, stack), but none of these work.
Hope anyone has ran into this error already and is able to provide me with some suggestions. I have followed the upgrade guide and it doesn't help unfortunately.
Thanks in advance.
P.S. I'm running php version 7.1 & am on ubuntu.
P.P.S. I have cleared all cached config using artisan.
Well I have found the actual problem, we use an adjusted storage_path() method in our application and the new Logger is now using the storage_path() method to generate its path - this caused the log file to be created in a different directory than storage/logs.
i had the same issue, deleting the files in bootstrap/cache solved it.
I attempting to setup Phalcon PHP using a Mongo database connection. I have configured my bootstrap (index.php) file using the following:
// Mongo database connection
$di->set('mongo', function(){
$mongo = new Mongo();
return $mongo->selectDb("phalcon");
}, true);
// Collection Manager
$di->set('collectionManager', function(){
return new \Phalcon\Mvc\Collection\Manager();
});
Whenever I attempt execute an insert fucntion in using this connection, I receive a 500 Internal server error. Now, I have checked my apache server error logs and it states "PHP Fatal error: Class 'Mongo' not found in /var/www/phalcon-mongo/public/index.php on line 17".
I don't know why this request is not processing, according to the documentation given from Phalcon, the connection to mongo DB is setup up as I have displayed above.
If anyone has any advice, please let me know.
i think it's because your installation of Mongo is not valid.
try printing phpinfo() and check if mongo is loaded at all, if not - install it, add to ini files (if you use cli, don't forget to add to cli ini too) and reach the moment, when mongo is fully loaded.
try mongo w/o phalcon. any simple connection/insertation. you can see here: Fatal Error - 'Mongo' class not found that there are problems with apache module version for some people. Try reinstalling different mongo version.
if you can print this out:
echo Phalcon\Version::get();
there should be no problems with phalcon instalation
to validate mongo installation, try any of examples from php.net:
http://www.php.net/manual/en/mongo.tutorial.php
if both installations are valid, then there are problems with your custom code, but before doing anything you have to validate both installations.
After following the user guide instructions found here: http://ellislab.com/codeigniter/user-guide/general/cli.html I'm unable to run the test script via command line.
My controller located at /var/www/mysite/application/controllers/
class Tools extends CI_Controller {
public function message($to = 'World')
{
echo "Hello {$to}!".PHP_EOL;
}
}
In my browser I can access
http://mysite/tools/message/ben
And the function correctly outputs "Hello ben"
From terminal I should be able to run:
$ php index.php tools message "Ben"
My terminal should print: "Hello Ben"
However I get the following error:
PHP Fatal error: Class 'CI_Controller' not found in /var/www/mysite/system/core/CodeIgniter.php on line 233
My server is pretty standard; ubuntu LAMP. Codeigniter is pretty standard too and I have no problem running non CI scripts via command line
My PHP binary is only located in /usr/bin/php <-- This post suggests an issue running CI directly from usr/bin/php, however I'm not operating a shared PHP service, and I don't see why this would make a difference to how PHP executes a CI script.
Any help or just an indication on how to debug this would be greatly appreciated.
Thanks in advance.
Solved! (partly) the issue was CodeIgniters error logging.
In application/config/config.php, I modified the following config property:
$config['log_threshold'] = 0;
This disables logging, and allows $ php index.php to execute.
If anyone can explain why CI only shows this error on CLI PHP - might help anyone else who has this issue and needs it resolved with error logging on.
To solve error "Class 'CI_Controller' not found" try going to Application -> Config -> database.php then check the database details like hostname, username, password and database.
To Mijahn:
I had this same problem, and after about two hours of tracing through code to figure out the problem, it seems that there is some sort of conflict with loading the CI_Controller when utilizing the native PHP load_class function.
I worked around this issue by making the following changes to the Common.php file (hack, I know).
//$_log =& load_class('Log');
require_once('system/libraries/Log.php');
$_log = new CI_Log();
My logs then where created exactly like I wanted. Hope this hack helps.
This site says to run codeigniter from the command line, one must set the $_SERVER['PATH_INFO'] variable.
$_SERVER['PATH_INFO'] is usually supplied by php when a web request is made. However, since we are calling this script from the command line, we need to emulate this small part of the environment as a web request.
The answer provided in this Stack Overflow post worked for me.
Within system/core/CodeIgniter.php, on around line 75, change:
set_error_handler('_exception_handler');
to...
set_exception_handler('_exception_handler');
Other users have reported that this gave them a better backtrace with which to debug the underlying issue, but for me, this actually removed the problem altogether.
Has anyone else out there had this problem and found a possible solution. Im not getting any error msg's, simply that no data is been returned from the command line when the database class is either loaded automatically or from the controller.
(This is for CodeIgniter Reactor version.)
Update:
Reported this as a bug:
https://bitbucket.org/ellislab/codeigniter-reactor/issue/85/
Im using cURL to run the script for now and not direct php,
so this:
curl http://localhost/~derrick/mywebsite/index.php/task/run
instead of this:
php Users/derrick/sites/mywebsite/index.php task run
for now until the problem has been resolved.