Just setup CakePHP 3 and get this error after I added the plugin hooks to the code in the AppController and bootstrap.php
Error: Class 'App' not found File /var/www/fastcom-portal-one/app/plugins/DebugKit/Controller/Component/ToolbarComponent.php
Line: 16
DebugKit has not yet been updated for CakePHP 3.
Remember to run
bin/cake plugin assets symlink
So DebugKit is able to load its assets correctly.
It's already supported, install it using composer:
"require": {
"cakephp/debug_kit": "3.0.*-dev"
},
From now on you don't need to set DebugKit in your AppController, just add this to your bootstrap.php file:
Plugin::load('DebugKit', ['bootstrap' => true]);
Related
I would like to create a plugin for CakePHP 3.1.4. The documentation is straight forward, but the example doesn't work (http://book.cakephp.org/3.0/en/plugins.html#creating-your-own-plugins)
The steps are:
composer create-project --prefer-dist cakephp/app sampleapp
Create the database. Connect to the database. Create a table "contacts". Navigate in the directory and run:
bin/cake bake plugin ContactManager
Create the controller:
bin/cake bake controller --plugin ContactManager Contacts
Re-generate the autoloader:
composer dumpautoload
Add this line to the /config/bootstrap.php file:
Plugin::load('ContactManager', ['routes' => true]);
But now, the documentation sais
"If you want to access what we’ve got going thus far, visit
/contact-manager/contacts. You should get a “Missing Model” error
because we don’t have a Contact model defined yet."
But this doesn't work. Instead I get an error:
Missing Controller.
Cake\Routing\Exception\MissingControllerException.
Cake\Routing\Dispatcher->dispatch ROOT/webroot/index.php, line 37
Error: ContactManagerController could not be found. Error: Create the
class ContactManagerController below in file:
src/Controller/ContactManagerController.php
This means the plugin could not be loaded otherwise it would not suggest this. When opening the DebugKit under "Include" the plugin is not in the plugins array.
I checked the composer.json files and in both the plugin is listed correctly. The bake command ran through without errors. I tried the above steps with multiple new projects with different names.
What is the problem here? Thank you very much.
Finally, I found the solution.
What the docs say should be in /plugins/ContactManager/config/routes.php AND what bake plugin creates:
Router::plugin('ContactManager', function ($routes) {
$routes->fallbacks('DashedRoute');
});
But what really needs to be in the file instead of the above snippet is:
Router::scope('/contactmanager', ['plugin' => 'ContactManager'], function ($routes) {
$routes->fallbacks();
});
I set up the DebugKit in cakephp but I'm getting this error:
Error: DebugKit.ToolbarComponent could not be found.
Error: Create the class ToolbarComponent below in file:
C:\xampp\htdocs\eperformance\app\Plugin\DebugKit\Controller\Component\ToolbarComponent.php
<?php class ToolbarComponent extends Component { } ?>
Can anyone help me with this?
My ng case:
cakephp ver.2.6.4 and
debugkit ver.2.2 or master
My successful case:
cakephp ver.2.6.1 and
debugkit ver.2.2
Hope it helps you.
Possible walk through:
In bootstrap use this line CakePlugin::load('DebugKit'); OR CakePlugin::loadAll();
Use this link to download debug kit click here
Follow the README.md file in above link
Now I know there is a work around already for this were I can just copy the assets to the projects own webroot. And will probably just do that in a bit however . . .
I do want to know why I keep getting this issue. I was poking around in the AssetDispatcher code and placed some CakeLog::write() statements in there and when I call the page the dispatcher is only called once. Shouldn't it be called for each asset that is being requested? Is there another file that handles the dispatching of assets other than this class I can look at?
I have a fresh install of cakephp 2.5.5 and DebugKit 2.2.4
I followed the instructions in how to load the plugin and indeed the php code is seeing the plugin and tries to load it. It is just not being displayed properly because it can't find the css and js within the plugin.
I did some searching and found somethings stating that the order that the plugins are loaded and the order of the dispatchers withing the bootstrap.php file matters here. I am using a fresh install of cakephp here and that order is already present. DebugKit is loaded and then the dispatchers.
Mostly I could use some help in how to debug the dispatchers since this seems to be where the problem is. Never have had to touch these before. The cakebook gives general information on how to write your own, but I am more interested in the lifecycle here.
Or more like I am making this overly complicated and there is an even easier thing to do here to figure this out. Any information is appreciated.
I've included the relevent code on the initial setup of the DebugKit below in case I missed something simple or overlooked something I thought I had done.
app/Config/bootstrap.php
CakePlugin::load( 'DebugKit' );
Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher'
));
app/Controller/AppController.php
$components = array( 'DebugKit.Toolbar' );
app/View/Layout/default.ctp
bottom of file
<p>
<?php echo $cakeVersion; ?>
</p>
</div>
</div>
</body>
</html>
These are the paths that cake is having trouble resolving
/debug_kit/css/debug_toolbar.css
/debug_kit/js/js_debug_toolbar.js
/debug_kit/image/cake.icon.png
These are the urls that cake is generating itself
I have the same problem before when upgrading to the latest CakePHP. I solve it by adding the following codes in bootstrap.php:
Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher'
));
When upgrading to latest version, you need to also check whether there are changes in index.php and htaccess file.
Here are the steps you follow:
Install CakePHP and check installation.
Download the latest DebugKit 2.2.1, which is compatible with Cake 2.4
Copy the contents to the cake/plugins/DebugKit folder.
Call CakePlugin::load('DebugKit'); in app/Config/bootstrap.php
Include toolbar component by calling public $components = array('DebugKit.Toolbar'); within the class of AppController.php
Set Configure::write('debug', 1); in app/Config/core.php
Remove the 'sql_dump' element from my layout in app/View/Layouts/default.ctp
Copy all contents (folders 'css', 'js', 'img') of app/Plugin/DebugKit/webroot/ in app/webroot/debug_kit/
I have tried to use cakephp Debugkit toolbar for cakephp 2.1.3... but it is not working fine..
I have implemented debugkit on cakephp 1.3 it is working fine..
i downloaded debugkit for cakephp 2.1.3. I rechecked that..
How i am implementing it??
app/plugin/DebugKit ///this is my path for debugkit
I checked my debug mode is 2..
Configure::write('debug', 2);
how i am loading my debug kit in Appcontroller..'
public $components = array('DebugKit.Toolbar');
It is showing error
Parse error: syntax error, unexpected T_FUNCTION in /var/www/guest1/cakephp-2.1.3/app/Plugin/debug_kit/Controller/Component/ToolbarComponent.php on line 165
I download debugkit from different source but same result.
Thanks !
it is showing error in this function and line
public function implementedEvents() {
$before = function ($name) {
return function () use ($name) {
DebugTimer::start($name, __d('debug_kit', $name));
};
};
$after = function ($name) {
return function () use ($name) {
DebugTimer::stop($name);
};
};
I loaded file in bootstrap.php at the end
CakePlugin::loadAll();
Error:-
Error: DebugKit.ToolbarComponent could not be found.
Error: Create the class ToolbarComponent below in file: /var/www/guest1/cakephp-2.1.3/app/Plugin/DebugKit/Controller/Component/ToolbarComponent.php
You have downloaded the latest version of the DebugKit plugin, which uses closures. As you can see there, you need at least PHP 5.3 for this to work.
Simply download an earlier version of DebugKit which is compatible with your version of PHP.
I have same problem. I guess if you are using Cakphp 2.0 and higher, you cannot use Debugkit version lower than 2 because it has a different Plugin name convention. Files have a different tree structure.
So all you have to do is use a lower version and rename the files or update PHP or use lower version of Cakephp.
I had the same problem. DebugKit worked on my local server, but crashed with the same error online. The problem was that i didn't have a database connection. After i succesfully connected to the database, debugkit worked fine.
I have been attempting to use CakePHP 2.0 and most of it works pretty well, however I have not been able to get console logging working with FireCake. I have FireBug 1.8.3 and FirePHP 0.6.2 installed in Firefox 6.0.2 and my old Cake 1.3 project works fine. For CakePHP 2.0 I downloaded the new version of DebugKit, put it in Plugins, added this to my AppController in Controllers folder:
App::import('Vendor', 'DebugKit.FireCake');
class AppController extends Controller {
public $components = array('Cookie', 'DebugKit.Toolbar', 'RequestHandler', 'Session');
and this in my bootstrap
CakePlugin::load('DebugKit');
and in core
Configure::write('debug', 2);
and then put this in one of my controller actions
FireCake::log($msg);
which generates an error like this
Fatal error: Class 'FireCake' not found in C:\Users\foo\Documents\Websites\cakephp-2.0.0.35\numbering\Controller\AppController.php on line 29
I can't figure out anything I might have missed from the instructions, so is there something duh-obvious I might be overlooking? Or some extra import that is necessary? Any help would be appreciated, thanks.
Matt
[edit]
I should add that the DebugKit menu appears as expected and functions, the problem is just FireCake.
The documentation was incorrect for CakePHP v 2.0. This is now required:
App::import('Lib', 'DebugKit.FireCake');
I believe you should use
App::uses('FireCake', 'DebugKit.Lib');
if you are on CakePHP 2.2 or higher.