CakePHP 2.6 DebugKit not loading properly - cakephp

So I recently tried to install DebugKit for cakephp 2.6 and run into an interesting propblem. I have loaded the plugin in bootstrap.php. I have debug set to 1 in core.php. I have the component loaded in AppController.php. And I have removed the sql_dump from default.ctp. When I load my app I don't see the cake logo in the upper right corner and I get a message that prints at the bottom of the page that says.
There are no active panels. You must enable a panel to see its output.
Any help is greatly appreciated.
Code in files as requested:
bootstrap.php
CakePlugin::load( [ 'DebugKit', 'BoostCake', 'Search' ] );
core.php
Configure::write('debug', 1);
AppController.php
public $helpers = [
'DebugKit.Toolbar',
'Session',
'Html',
'Form',
'Paginator' => [ 'className' => 'BoostCake.BoostCakePaginator' ],
]

I saw my problem as soon as I posted my code.
I declared the Debugkit.Toolbar in the helpers array not the components array so now I have
$components = [ 'DebugKit.Toolbar' ];
And everything works just fine. Thank you to everyone who posted

Related

requestAction is not working in CakePHP 2 Shell Command

I'm attempting to make a cron shell, and the ability to use requestAction for this is crucial.
For testing purposes, I've reduced my Shell down to just this:
class CronShell extends AppShell {
public $uses = array('Cron');
public function main() {
$this->requestAction(['controller' => 'events', 'action' => 'play', 38, 0, true, true]);
echo "This will never be printed to the console, it dies before this.";
}
}
And I still cannot get this to run. It simply returns apparently successful, but actually is not. (no error) Another SO question suggested beforeFilter (and other lifecycle methods) could be the cause, but I've ensured that is not the case. See update.
Other controller/actions aren't working.
Removing the action's return doesn't help.
Using a string-based call doesn't help.
CakePHP v2.10.22
Update: It looks like the Auth component may be causing a redirect to users/login in AppController. Yet I see nowhere that I tell it to redirect here, and I don't even have a users/login action. When I remove 'Auth' from my public $components = [], the shell runs on CLI.
But I'm having trouble disabling Auth! I've tried allow(*), setting the redirects to false, even trying $this->components = ['']. I am always redirected to users/login.
Well, it turns out it wasn't the beforeFilter or any part of the lifecycle, but I did have the Auth component on my AppController like such:
public $components = [
'Session',
'Auth' => [
'loginRedirect' => ['controller' => 'worlds', 'action' => 'route']
]
];
Which, no matter what I did to allow or simulate Auth for cli, just constantly redirected me. So I reduced the above to just Session and wrote under,
if (php_sapi_name() !== 'cli')
This:
$this->components = [
'Session',
'Auth' => [
'loginRedirect' => ['controller' => 'worlds', 'action' => 'route']
]
];
And that removed Auth from the equation. I would have expected CakePHP 2's console to give me any indication it was being redirected, but I'll bet future versions handle it better.

how to rander .html file using cakephp : CakePHP

I am working on CakePHP and I have a URL http://admin.example.com/Pages .
How can I create http://admin.example.com/Pages.html ? Is there any solution or component to solve this issue?
According to CakeBook , You can define extensions you want to parse in routes
E.g. Write the code below in app/Config/routes.php
Router::parseExtensions('html');
This will allow you to send .html extenstion in routes(url)
Not create a link
E.g:
$this->Html->link('Link title', array(
'controller' => 'pages',
'action' => 'index',
'ext' => 'html'
));
When you click that link you will get url in browser something like this
http://admin.example.com/pages/index.html
Do you really need this? CakePHP is automatically render view files from View folder
You can create (if its PagesController and index methond) index.ctp in app/View/Pages folder and it will be automatically render.
You can use file_get_contents function to read files. Something like this:
// in controller
function index() {
$content = file_get_contents('path/to/file.html');
echo $content;
die();
}

CakePHP Plugin - Error "Controller could not be found"

I'm currently using CakePHP 2.5.2
I want to integrate a plugin to manage Users.
I tested it in a first time as a single CakePHP Application (controllers in app/controller, models in app/model, views in app/view/Users): was ok.
I'm trying now to convert it as a plugin:
I've created a folder UserManager in app/plugin.
When I try to go to the url of one of my controllers, I get the message Missing Controller.
All plugin are loaded in Bootstrap.php (CakePlugin::loadAll();).
I tried to find similar problems vs solutions but no one was relevant with my problem (I tried some proposed solutions but root causes were different.
When I look at DebugKit in Include section, I can observe that my DebugKit plugin is loaded but not my other plugin...
Could some one suggest me a solution ?
Thanks in advance.
(Please find bellow a description of the code)
I added controllers, models and views as follows (skeleton generated by Bake and checked: ok):
1) Models in app/plugin/model
UserManagerAppModel.php
<?php
App::uses('AppModel', 'Model');
class UserManagerAppModel extends AppModel {
}
?>
User.php
<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends UserManagerAppModel {
...
}
?>
2) Controllers in app/plugin/controller
UserManagerAppModel.php:
<?php
App::uses('AppController', 'Controller');
class UserManagerAppController extends AppController {
}
?>
UserController.php:
<?php
class UsersController extends UserManagerAppController {
public $uses = array('UserManager.User');
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('*');
}
public function login() {
}
...
?>
3)Views in app/plugin/view/Users
Nothing special.
I think it is an issue with your path names: They have to include the plugin name. Plus the folder names have to start with a capital letter by convention. For example, UserManagerAppModel has to be in the following file: app/Plugin/UserManager/Model/UserManagerAppModel.php.
See also http://book.cakephp.org/2.0/en/plugins.html#creating-your-own-plugins
Since I believe has included AuthComponent settings in your AppController loginAction note the call and check the name of your plugin. In my case the plugin name is Barracuda, the error does not occur stopped until the call was made ​​for barracuda, with the first letter in lower case.
'loginAction' => array(
'controller' => 'users',
'action' => 'login',
'plugin' => 'Barracuda'
),
for
'loginAction' => array(
'controller' => 'users',
'action' => 'login',
'plugin' => 'barracuda'
),

CakePdf - Engine not loaded

I have installed CakePdf plugin for cakephp as outlined in the readme file on GitHub. I am getting an error saying the engine iisnt loaded. I have tried all 3 engines that come with the plugin. Anyone else have this issue and find a solution? Rhanks
http://www.slideshare.net/jellehenkens/building-php-documents-with-cakepdf-cakefest-2012
Here is a slideshow how to install the plugin,
To load the engine use this in bootstrap.php
Configure::write('CakePdf', array(
'engine' => 'CakePdf.DomPdf',
'pageSize'=>'A4',
'orientation' => 'landscape',
));
Go to your controller en use in your public function view or index this:
$this -> pdfConfig = array (
'orientation' => 'landscape',
'download' => true,
'filename' => 'Client_' . $id
);
i hope this will help you,

Cakephp User management plugin implementation

I had downloaded the plugin from link
https://github.com/CakeDC/users
followed the steps given in the page. I have created the tables 'users' and 'details'. I have also registered the user and verfied the user, but while accessing the link www.mydomain/users/users/login this page is getting redirected to www.mydomain/users/login
which shows missing controller. I am new to cake and for me it is difficult to debug. I would be thank if some one help me.
Thank you for the response.
Yes, I have added the code given in the "cake\libs\controller\app_controller.php" file. In order to test this I have freshly downloaded the core files and setup the files in my local system. I have placed the plugins 'utils', 'search' and 'users' to my app/plugins folder and created the tables.
Now also I am able to register the user but not able to see the login page. ie. "while accessing the link www.mydomain/users/users/login this page is getting redirected to www.mydomain/users/login which shows missing controller".
Please let me know if I am missing anything or I am wrong.
Thank you.
This looks like a problem in the login redirection.
Did you add the beforeFilter() configuration to your app_controller?
if not you may need to add it.
Here is an example of how your app_controller should look like:
<?php
class AppController extends Controller {
var $components = array('RequestHandler', 'Session', 'Auth');
function beforeFilter(){
$this->Auth->fields = array('username' => 'email', 'password' => 'passwd');
$this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => false);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->authError = __('Sorry, but you need to login to access this location.', true);
$this->Auth->loginError = __('Invalid e-mail / password combination. Please try again', true);
$this->Auth->autoRedirect = false;
$this->Auth->userModel = 'Users.User';
$this->Auth->userScope = array('User.active' => 1);
}
}
?>
Remember that the $this->Auth->loginAction MOST contain the 'plugin'=>'users', without it it will go to www.mydomain/users/login instead of www.mydomain/users/users/login

Resources