سؤال

Sorry for the lengthy post. I try to be as specific as I can with my question. I have been having problems migrating a cakephp1.2 site to cakephp2.x. I am new to cakephp and have read and follow the migration manual and docs at Cakephp website.

So far so good but I can only view logo, and background of the site but no content was loaded. And I also receive an error :

An Internal error has occurred. Component class XAjaxComponent could not be found

In the stack trace:

"CORE/Cake/Controller/ComponentCollection.php line 53 → ComponentCollection->load(string, array) 'XAjax' array()"

I didn't see and find any XAjax information in the manual and the website. The previous developer have included XAjax as a component array in the AppController.

public $components = array( 0 => 'RequestHandler', 1 => 'Security', 2 => 'Auth',  3 => 'XAjax', 4=> 'DebugKit.Toolbar', 5 => 'Cookie', 6 => 'Session' );

In a thread somewhere here I read that XAjax is no longer actively maintained (last updated was in 2012 and is still in beta)? And suggest using alternatives like jQuery?

As i browse the app files I found out XAjax is used to call the following functions(listed below in no particular order):

$this->XAjax->autocomplete( $param_encode, $param_hash, $conditions );
$this->XAjax->flashuploadset($this->request->data);
$this->XAjax->normalupload($this->request->data, false);
$this->XAjax->flashuploadset($this->request->data);

These have something to do with forms. I couldn't find any XAjax function anywhere or any XAjax plugin or component for that matter for the class to be called. I am not very familiar with XAjax actually.

My question is if I were to still want to implement XAjax in my cakephp site, then how best should I do it?

Any form of help or suggestions will be very much appreciated.Thanks!

هل كانت مفيدة؟

المحلول

(CakePHP 3.0) If you're using a custom component (or writing your own like I am) you need to specify your namespace at the top of your controller, and tell your component where it can find the Component class. I received a similar error in my application:

Missing Component Error: SuperComponent could not be found.

Error: Create the class SuperComponent below in file: src/Controller/Component/SuperComponent.php

<?php
class SuperComponent extends Component {

}

The file src/Controller/Component/SuperComponent.php already existed, but I needed to add these lines at the top (under

namespace App\Controller\Component;
use Cake\Controller\Component;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top