Currently trying to implement this JonnyW php-phantomjs with CakePHP 2.0. The problem seems to be that Cake can not find the the files.
When I call it this way:
App::import('Vendor', 'JonnyW/PhantomJs/Client');
CakePHP gives the error:
Error: Class 'Client' not found
When I call it this way:
App::path('Vendor', 'JonnyW/PhantomJs/Client');
CakePHP gives this error:
Error: The application is trying to load a file from the JonnyW/PhantomJs/Client plugin
Error: Make sure your plugin JonnyW/PhantomJs/Client is in the app/Plugin directory and was loaded
CakePlugin::load('JonnyW/PhantomJs/Client');
So, I thought I would give it a shot and load it into the Plugin directory, but it still gives the same error.
Just wondering if anyone has any insight on PhantomJs working with CakePHP?
Use App::import:
App::import('Vendor', 'JonnyW', array('file' => 'JonnyW/PhantomJs/Client.php'));
See http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#loading-vendor-files
I am actively using CakePHP and PhantomJS + CasperJS with the method below. You can pass variable through shell with phantomjs args and return the terminal echoed answer through last parameter of php's exec() command. Have been using this method for a while no problem so far.
putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
exec('/usr/local/bin/casperjs --ignore-ssl-errors=true --ssl-protocol=any ../Lib/ExampleCrawler/example.js ' . $url . ' 2>&1', $result);
Related
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
I want to run Guzzle on Xampp server, but when I try to run it, I get message:
Fatal error: Class 'Guzzle\Http\Exception\BadResponseException' not found in D:\2 Workspace\5 Aptana\OpenTok\Guzzle\Http\Exception\ClientErrorResponseException.php on line 8
I need it as a part of PHP API for OpenTok project. I can't use composer, so I downloaded it manually, but it doesn't work. I think it can be something with namespace and use.
What should I do to get this working?
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.
I am using linkedin plugin for my app. It was working fine for cakephp 1.3. I migrated to cakephp 2.x. I understand you need to load plugins like this
CakePlugin::load('Linkedin');
It worked. But in my plugin folder I have vendor folder. It is loaded using
App::import('Vendor', 'Linkedin.oauth', array('file' => 'OAuth' . DS . 'oauth_consumer.php'));
But it says cannot find oauth_consumer.
I appreciate any help.
*UPDATED *
I have added linkedin plugin to my app. I have loaded my plugin using CakePlugin::load('Linkedin');. Now I get error
Fatal error: Call to a member function get() on a non-object in ....\Controller\Component\LinkedinComponent.php on line 95
On line 95 of Linkedin component this is what is there
$consumer = $this->_createConsumer();
$result = $this->Consumer->get($key, $secret, $this->apiPath . $path);
It says the get method is not found on linkedincomponent. But the get method is in oauth_consumer.php.
I appreciate all your help
The plugin is not 2.x ready.
You will have to upgrade it yourself.
You could have easily figured that out looking at the folders and files.
In 2.x it would be
/Linkedin/Controller/Component/LinkedinComponent.php
etc (also note the casing which is important in 2.x)
Most likely you can use the above upgrade shells to do that and make the plugin 2.x compatible.
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.