How do I install a CakePHP plugin? - cakephp

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');

Related

CakePHP 3 Audit Log, working with admin routes?

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?

CakePHP searching for DebugKit at wrong path

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.

CakePHP Twitter plugin

Appologies if this is something obvious I've missed.
I'm trying to use this Cake plugin to add a twitter feed to my cake app (just display my latest tweet). I've followed the docs in the readme but I get this:
Missing Controller
Error: Twitter.UsersController could not be found.
Error: Create the class UsersController below in file: C:\wamp\www\mysite\app\Plugin\Twitter\Controller\UsersController.php
Heres what I've done so far (as the readme instructs):
Cloned all the files into app/Plugin/Twitter/
Rename Config/twitter.default.php to Config/twitter.php
Updated the config file with my twitter app keys
Visited mysite/twitter/twitter/connect - which gives me the above error.
The readme mentions that the plugin uses - http_socket_oauth, another cake plugin, I trust that this is included in this plugin and that I dont have to install that plugin aswel?
Could someone point me in the right direction?
Thank you

Sencha Cmd v3 build error when implementing Bryntum Scheduler

Using Cmd 3.0.0.141, I have successfully generated a workspace and an Ext app in that workspace. The application builds correctly until I attempt to integrate the Bryntum Scheduler, where I encounter an error when I try to build:
"Failed to resolve dependency Sch.panel.SchedulerTree for file ExtCalendar.view.Tree"
the app is very simple at this point, uses Ext.application and follows the MVC pattern where I have a view defined "ExtCalendar.view.Tree" that extends 'Sch.panel.SchedulerTree". I also have models and stores that extend Bryntum classes as well, so I assume the compiler will trip over those as well, since it can't see the Sch namespace.
I've added a 'js' path to my app.json that points to the bryntum js file where 'Sch.panel.SchedulerTree' comes from. I've tried to run the 'refresh' command with the same results (Failed to resolve...). I've regenerated the bootstrap.js file manually using 'compile', but nothing from the Sch namespace ever gets added to it, despite the Brytum lib file being in the classpath.
What do I need to do in order to successfully run the 'build' command with libs like this?
Or, do I need to take a more granular approach using the 'compile' command?
With the help of the nice folks on the Sencha forums, I was able to resolve my build issues. The solution, for me, involved a shim. I added an external shim.js file to my index with as many //#require and //#define directives as needed in order to resolve the dependency issues.
According to the nice folks at Bryntum, once I upgrade from the free-trial version of the Bryntum Scheduler, I will be able to get rid of the shim and simply rely on the sencha.cfg classpath pointing at the Bryntum src.
Also, as an aside, the app.json file is not used in ExtJS apps, its inclusion in the generated files was a bug in build 141 of Cmd v3.
See this thread for more detail.

CakePHP 2.0 Plugin URL

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.

Resources