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.
Related
I've developed a small project on a machine, using CakePHP 3.0, and I need it to run on another machine. I've tried to install it on several other machines.
If I run the composer to install the CakePHP 3.0, then I copy my stuff to overwrite it, the project works. I've tried this on two machines and had no problem so far. If I don't run the composer, and just copy the stuff to the target machine, it gives me the following error. I've tried this on 3 machines, and every machine gives me this:
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
I've copied the whole project to this server to test.
I told you this because I thought it has something to do with my problem. The point is that I have to run this on a machine that is not mine, and I can't install composer on it. The /public_html/vendor/cakephp/cakephp/src/I18n/ has files related to internationalization and localization, but my project will never be translated, so a workaround to make the project ignore those files would be enough to solve my problem.
The following code is an excerpt from the (...)/I18n/I18n.php that might be relevant:
<?php
namespace Cake\I18n;
use Aura\Intl\FormatterLocator;
use Aura\Intl\PackageLocator;
use Aura\Intl\TranslatorFactory;
use Cake\I18n\Formatter\IcuFormatter;
use Cake\I18n\Formatter\SprintfFormatter;
use Locale;
class I18n {
// lots of code here
public static function defaultLocale() {
if (static::$_defaultLocale === null) {
static::$_defaultLocale = Locale::getDefault() ?: 'en_US';
// the line above is the Line 229
}
return static::$_defaultLocale;
}
// many code here too
}
I've checked that another file also tries to access this Locale class, but I don't know if there are other files trying to access it as well. Many files from everywhere inside the project tries to access methods from I18n.php. I need it running but I can't figure out how to make it run.
Any help will be greatly appreciated.
As I just found out, prior to CakePHP 3.0, the installation must be done by composer, as stated in the 3.0 migration guide:
CakePHP should be installed with Composer
Since CakePHP can no longer easily be installed via PEAR, or in a shared
directory, those options are no longer supported. Instead you should use
Composer to install CakePHP into your application.
So it won't run on regular free web hosting services.
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);
Is there an easy to setup Codeigniter REST library which I can use to consume a RESTful service? I tried setting up this library. But could not set up Spark. Tried following steps:
Adding a directory named sparks in the root of your codeigniter directory
Adding a custom Loader Class to application/core/MY_Loader.php.
It gave me another error Cannot find spark path at sparks/curl/1.2.1/. Now I am stuck. Wondering why it is so hard to setup RESTful API in codeigniter.
Update: When I try to run
$this->load->spark('restclient/2.1.0');
// Load the library
$this->load->library('rest');
// Run some setup
$this->rest->initialize(array('server' => 'http://api.twitter.com/'));
// Pull in an array of tweets
$tweets = $this->rest->get('1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=jenksuy&count=2');
$tweetobjects = json_decode($tweets);
foreach ($tweetobjects['results'] as $tweet) {
log_message('info', $tweet['text']);
}
I am getting Error: Call to undefined method CI_Loader::spark()
sparks is not necessary SEE EDIT. use this tutorial to start, the author also wrote the libraries
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
download these two to work with the tutorial:
https://github.com/philsturgeon/codeigniter-restserver
https://github.com/philsturgeon/codeigniter-restclient
also at the end of the tutorial - theres many comments and questions, and the tutorial author has answered many of them
EDIT - whoops forgot you have to change one line. and you will need to DL the CI curl library. OK so in the rest client, in the file Rest.php starting at line 53
/* Not using Sparks? You bloody well should be.
| If you are going to be a stick in the mud then do it the old fashioned way
$this->_ci->load->library('curl');
*/
// Load the cURL spark which this is dependant on
$this->_ci->load->spark('curl/1.2.1');
so change it to load curl library the traditional way and commment out the spark reference
$this->_ci->load->library('curl');
// Load the cURL spark which this is dependant on
// $this->_ci->load->spark('curl/1.2.1');
You can install curl 1.2.1 by running the following command on your application root (not your application folder):
php tools/spark install -v1.2.1 curl
Source
I want to integrate the LiipImageBundle in my Symfony 2.1 project.
I installed the bundle and the imagine/Imagine v.0.4.0 bundle via composer.
It's seems to work fine, except, that the modified images are not saved.
The error.log states:
PHP Fatal error: Class 'Imagine\\Imagick\\Imagine' not found in /var/www/app/cache/prod/appProdProjectContainer.php on line 365
This line in appProdProjectContainer.php states:
protected function getLiipImagineService()
{
return $this->services['liip_imagine'] = new \Imagine\Imagick\Imagine();
}
I have no idea if this is correct or not. Have you guys any idea why PHP cannot find the class?
Have you added Imagine to autoload. If you haven't then u can do like this:
Open vendor/composer/autoload_namespaces.php
Add
'Imagine' => $vendorDir .'/imagine/Imagine/lib/',
'Liip\\ImagineBundle' => $vendorDir . '/liip/imagine-bundle/',
I'm starting a new project using SF 1.4.18 and sfDoctrine & sfDoctrineGuard plugins. I had both active at config/ProjectConfiguration.class.php as follow:
public function setup() {
$this->enablePlugins(
array(
'sfDoctrinePlugin',
'sfDoctrineGuardPlugin'
)
);
}
All is good so far but when I try to reach the URL http://inventario.devserver/backend_dev.php/sfGuardUser this error come up:
Fatal error: Class 'sfDoctrineRouteCollection' not found in /var/www/html/inventario
/plugins/sfDoctrineGuardPlugin/lib/routing/sfGuardRouting.class.php on line 59
I don't know what's causing the error because I follow every step at plugins docs. Any help or advice?
Symfony 1.4 is shipped with sfDoctrinePlugin. You shouldn't add the plugin on your own.
Remove the folder sfDoctrinePlugin from your /plugins folder, clear your cache and it will solve your issue.
It's exactly the same problem from this guy, on the official Symfony forum, in 2009.