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/
Related
I'm trying to work with this CakePHP 3 plugin which I think does exactly what I need it to do, but am struggling big time! I'm new to CakePHP 3, composer and fiddling with routes etc (previously CakePHP 2.x and manual installation and never played with routes).
The plugin does not appear to be maintained any longer and the package does not exist when trying to install via composer, so I forked it and cloned the files to /plugins/AuditLog/
I've run updated my app composer.json file, loaded the plugin in my bootstrap.php, and run composer install on /plugins/AuditLog/ to load the dependencies from the plugin composer.json file (not sure if this is the right thing to do?)
In plugins/AuditLog/config/routes.php there is the following code
Router::plugin('AuditLog', function ($routes) {
$routes->prefix('admin', function ($routes) {
$routes->fallbacks('DashedRoute');
});
$routes->fallbacks('DashedRoute');
});
So a bit of searching in the CookBook and I read for the first time about 'prefix routing', which from what I can tell means I should be able to reach the pages via /admin/audit-log/audits (for example).
Not surprisingly, I get a missing controller error here
Error: Create the class AdminController below in file: src/Controller/AdminController.php
The instructions for the plugin don't mention anything about creating an admin controller, and there are no controller files anywhere in the plugin at all actually, despite there being views and models.
I'm really out of my depth here, can anyone help me untangle this? Where/how to add which controllers and get them pointing to the right place?
I'm having some issues installing and configuring a plugin, and I think if I had a better idea of how things worked I might be able to figure it out?!
When I install the cakemanager/cakephp-settings plugin via composer it adds to my vendor folder a 'cakemanager' folder with 3 sub-folders: 'cakephp-settings', 'cakephp-utils' (a dependency) and 'Settings'. The 'cakephp-settings' folder is essentially empty, and all the plugin files are in the 'Settings' folder.
However, when I try to run the migrations I get an error that it cant find the /vendor/cakemanager/cakephp-settings/config/bootstrap.php file - no small wonder as this file doesnt exist! Same error pretty much everywhere in my application
In the vendor/cakephp-plugins.php file I have this:
'Settings' => $baseDir . '/vendor/cakemanager/cakephp-settings/',
If I temporarily change this to
'Settings' => $baseDir . '/vendor/cakemanager/Settings/',
I can get the migrations done and my pages look normal again, however this reverts when I run composer dumpautoload and causes further issues down the track - I need a permanent solution.
How do I edit the plugin (composer.json files?) so that it builds the cakephp-plugins.php file correctly and it looks in the correct path for the bootstrap.php file?
I would suggest that you try to push merging this pull request, as that will fix the problem at its root, the installer-name option in the plugins composer.json will cause the target folder to be named "incorrectly" in case composer/installers is installed.
There is no reason to change the folder name, and as of Version 3, CakePHP doesn't need composer/installers anymore, so removing the option should fix the problem.
You could also try to remove composer/installers if you don't actually need it. In case that isn't possible, you should also be able to work around the problem by specifying the actual path via the Plugin::load() calls path option:
Plugin::load('Settings', [
'path' => ROOT . DS . 'vendor' . DS . 'cakemanager' . DS . 'Settings'
]);
It may also be worth reporting the problem to https://github.com/cakephp/plugin-installer and/or https://github.com/composer/installers, maybe it's possible to get them working together with respect to the installer-name option.
See also
API > \Cake\Core\Plugin::load()
I am trying to import DebugKit and CakePHP is producing the following error: DebugKit.ToolbarComponent could not be found.
Right below it, it says:
Create the class ToolbarComponent below in file:
/Users/SomeUser/Sites/SomeProject/app/Plugin/DebugKit//Controller/Component/ToolbarComponent.php
If you notice though, there are two slashes between DebugKit and Controller for some reason, and that's obviously not a real directory. The server running PHP 5.4.17. I have followed the exact installation instructions listed here. Any suggestions?
I had the same problem and solved it by changing the permissions to 755 to folders within DebugKit.
When I encountered this problem, I realized I had a Plugin/DebugKit folder structure in my project's root, and under the app directory. The one under app was empty, save for a blank file called empty. Strange. I have no idea how this happened. (Perhaps from accidentally running composer as non-root?) I deleted app/Plugin/DebugKit, and moved the one from the project root into app. No more error.
DebugKit does not currently seem to be compatible with cakephp 3.0 even though it is the example in the documentation.
The latest version still seems to use the 2.x methods.
I will also submit a ticket regarding this to update their documentation to prevent confusion.
If there is something I missed regarding this issue and it is actually possible to install this, let me know.
More easy questions - this time, how do I install a CakePHP plugin? I get that I take the plugin folder and put it in the, well, the plugins directory.
so
/app
/plugins
/what is this?
And I ask this, because I just downloaded a plugin - here:
http://milesj.me/blog/read/changelog-forum-2.3
And the name of the folder that everything is in is milesj-cake-forum-29a0699
This doesn't appear to be a good plugin name... is there some place that lists or describes what the plugin should be called? I know i know, I'm going to try it out without the 29stuff, but I like things to be silky smooth, not "trial and error".
Yes, I am a terrible programmer.
Based on the plugin's documentation, they refer to models as Forum.Profile for example which suggests that the plugins should be installed in APP/plugins/forum as that's where the CakePHP autoloader will look unless instructed otherwise (section 2).
for example fb plugin ; Load the plugin in your app/Config/bootstrap.php file:
//app/Config/bootstrap.php
CakePlugin::load('Facebook');
You can use all or some of the Facebook plugin as you see fit. At the very least you will probably want to use the Facebook Helper
public $helpers = array('Facebook.Facebook');
Trying to get CakePHP work with subfolders for Controllers, Views, or Models is not really working and from what I've read I need to use "Plugins". Right now I have the following folder structure:
/app/Plugin/Manager/
/Controller
CandyController.php
/Models
/View
/Candy
viewCandy.ctp
ManagerAppController.php
ManagerAppModel.php
When I try and set my url to: http://localhost/Manager/Candy/viewCandy/123. I get the error message: "ManagerController does not exist". Why is CakePHP not picking up that it should look in the Manager plugin folder?
Now that 2.0 has been released the docs are fleshed out a bit more. This is described in the Plugin section of the cookbook.
They suggest putting this in bootstrap.php instead of routes.php:
CakePlugin::loadAll(); // Loads all plugins at once
CakePlugin::load('ContactManager'); //Loads a single plugin
Here is the solution:
Go to /app/Config/routes.php and add the line CakePlugin::load(array('YourPluginName')); after the line CakePlugin::routes();. In my case it was line 40.
Basically CakePHP 2.0 doesn't automatically load plugins. I think that's fine and dandy, but there isn't really any documentation for this.