I have installed net_geoip on my web host and am encountering the error Fatal error: Class 'Net_GeoIP' not found in /home/heyitspr/public_html/beta_simplecraft.biz/index.php on line 3 when I run the script that is posted below:
$geoip = Net_GeoIP::getInstance('GeoIP.dat', Net_GeoIP::SHARED_MEMORY);
$country_name = $geoip->lookupCountryName($_SERVER['REMOTE_ADDR']);
print_r ($country_name);
I am new to installing plugins with apache so please explain it in simpler terms. Thanks
Seems like you have not included your GeoIP library. Try including it on your index.php code
include_once('GeoIP.php');
Related
I'm writing a very basic catenation script and lifted this straight off the pdftk 0.10.0 packagist site:
use mikehaertl\pdftk\Pdf;
// Extract pages 1-2 into a new file
$pdf = new Pdf('sourcefile.pdf');
$result = $pdf->cat(1, 2)
->saveAs('newfile.pdf');
if ($result === false) {
$error = $pdf->getError();
}
But I'm getting this error:
Fatal error: Uncaught Error: Class "mikehaertl\pdftk\Pdf" not found in C:\PHP8\index.php:7 Stack trace: #0 {main} thrown in C:\PHP8\index.php on line 7
All the sample scripts I've seen have that same header. I'm sure it's something really basic that I'm not seeing here.
Since the error is showing the Class not found, it would make me initially think that the package wasn’t installed in your project. If you run composer require mikehaertl/php-pdftk, does that get you rolling?
If you’re not familiar with Composer, here’s a quick guide to getting started: https://packagist.org/
Apparently, when installed via composer, the pdftk.exe file is not downloaded for some reason. I downloaded it manually from the github page and referred to it in the header.
Ok, finally found the answer. You need to install pdftk beforehand as packagist does not automatically pull it for you.
I have a project with PHP 7.3, under Windows 10. I use the PHP from Xampp.
I get the following error:
Fatal error: Uncaught Error: Class 'SplEnum' not found in [...]
for
class BanLevel extends SplEnum { ... }
It seems I am misunderstanding the docu:
https://www.php.net/manual/en/class.splenum.php
https://www.php.net/manual/en/spl.installation.php
This gives me the idea it should be included in my PHP artefact.
What am I missing?
UPDATE:
The class.splenum.php page has gone offline. It is still available in Romanian, though: https://www.php.net/manual/ro/class.splenum.php, or here: https://php-legacy-docs.zend.com/manual/php5/en/class.splenum
It seems I checked the wrong documentation,
this is the right one:
https://www.php.net/manual/en/spl-types.installation.php
It clarifies:
This PECL extension is not bundled with PHP.
A DLL for this PECL extension is currently unavailable.
So I can't use SPLEnum under Windows, except I compile it into PHP.
UPDATE:
The spl-types.installation.php page does not exist on php.net anymore, but it is still available here:
https://php-legacy-docs.zend.com/manual/php5/en/spl-types.installation
After upgrading php to 5.5, the following error occurs:
PHP Fatal error: Call to undefined function bi_to_str() in /var/www/index.php
I know that it's not a coding error, but it could be a missing library. But could an empty value cause that error? Is there an easy way to load that library using apt-get in Debian?
Well with the help I received in the comments, I was able to come up with a solution.
It seems that it's just the function that is missing. I was able to create a file called big_int.php, fill it with the contents found here, and just link to it using require_once in index.php, like this:
require_once('big_int.php');
All is well. Many thanks to Barmar for the helpful tip.
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.
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.