Class 'controller' not found in codeigniter 1.6.1 - php

I'm working on an application in Codeigniter and I want to make once a day cronjobs run by a series of scripts. Earlier this worked correctly on another hosting but after doing a migration has stopped working, because I have to re-create these cronjobs.
I want to run all days this file /web/_cronjobs/application/controllers/updates.php. This performs an update in the database of the internal statistics of the web and the most important, an updated sitemap. This is the code:
http://pastie.org/10012554
I am running this statement from PuTTY:
/usr/bin/php5.5 /kunden/homepages/45/*******/htdocs/web/_cronjobs/application/controllers/updates.php
But it shows me this error:
(uiserver):*********:~ > /usr/bin/php5.5 /kunden/homepages/45/d566577055/htdocs/web/_cronjobs/application/controllers/updates.php
X-Powered-By: PHP/5.5.20
Content-type: text/html
<br />
<b>Fatal error</b>: Class 'Controller' not found in <b>/homepages/45/d566577055/htdocs/web/_cronjobs/application/controllers/updates.php</b> on line <b>3</b><br />
I've made this possible solution but it still is the same as the version I use codeigniter is 1.6.1 and not 2.0:
codeigniter 2.0 Fatal error: Class 'Controller' not found in
I hope someone can help me, thanks! :)

You have put a controller class into a file and are trying to call it directly. This will not work.
The reason for your specific error is that the class Controller has not been included. This would normally be done by CodeIgniter when you're running things through the framework. But since you appear to be directly calling the file, CodeIgniter has not been loaded and cannot help you.
Second, the code in that file is just a class. I see no code that is supposed to interact with the class or anything. Therefore nothing would happen even if the class Controller existed.
I recommend that you read this short tutorial CodeIgniter - Running via the CLI

Try this:
/usr/bin/php5.5 /kunden/homepages/45/*******/htdocs/web/_cronjobs/index.php updates

Related

Issue with the implementation of the simplesamlphp library into my web application

I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.

MongoDb not found in ZF2 controller

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

Phalcon webtools not working

So I installed Phalcon and the phalcon devtools. When I try anything, it throws an error (Generate model, generate controller and scaffolding). Looked around and I can see other people had this problem but I cannot find a solution.
Generate Model page:
Error on generate:
webtools.config.php:
define('PTOOLS_IP', '192.168.0.81');
define('PTOOLSPATH', 'C:/phalcon-tools/vendor/phalcon/devtools');
Error on generate controller:
Please specify a controller directory
Error on generate model:
Database configuration cannot be loaded from your config file
Error on scaffolding:
Adapter was not found in the config. Please specify a config variable [database][adapter]
Had this same issue the other day. I found a work around but it's far from ideal.
Find
\devtools\scripts\Phalcon\Builder\
And open Components.php
Inside this file find the line:
foreach (array('/app/config/', 'config/') as $configPath) {
This line needs to be either:
(array('/../app/config/' <- For model Generator to work.
or
(array('../app/config/' <- For scaffolding Generator to work.
I can't for the life of me work why, and it's far from ideal trying to remember to do it every time you need to use the tools, but it works.

Codeigniter Command line error - PHP Fatal error: Class 'CI_Controller' not found

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.

Codeigniter command line not working with database class / driver?

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.

Categories