CakePHP DebugKit / Plugins webroot not being found - php

I've installed CakePHP's debug kit but it's not loading correctly on my pages, its just a mess of text and arrays at the bottom of the page. My browser is saying that it's getting a 404 on:
/debug_kit/css/debug_toolbar.css
/debug_kit/js/jquery.js
/debug_kit/js/js_debug_toolbar.js
/debug_kit/img/cake.icon.png
...so it's not finding the webroots for plugins properly. I have directed my browser to these pages and other combinations i could think of (e.g: /debugkit/css... or /debug_kit/webroot...) but nothing is working.
From my google searches it seems like a problem that a few people have had but I haven't seen a solution yet.
I have removed the 'sql_dump' element from the bottom of the layout page and still nothing.
Any ideas?
Thanks

To anyone else having this problem:
It's not a direct solution, but sort of a little hack
copy the contents of app/Plugin/DebugKit/webroot
to a new folder app/webroot/debug_kit
The problem is that CakePHP is not seeing the Plugins webroot, but this will bypass this problem.

Firstly have you got the right version of DebugKit for the version of CakePHP that you are using?
Secondly have you included it in your $components (usually in the App Controller) ?
public $components = array(
'Session',
'Cookie',
'DebugKit.Toolbar'
);
Are you loading it in bootstrap? i.e. CakePlugin::load('DebugKit');
Lastly have you got Configure::write('debug', 2); in core.php?
When working it will appear as an icon top right of the screen.

Related

PHP CodeIgniter URL navigation issue

I am new to CodeIgniter and also have average PHP knowledge. Just started learning CodeIgniter last week and having a basic problem which i can't overcome. my development environment is (OS,PHPStorm,MAMP,APACHE). CI project root is http://localhost:63342/CodeIgniter/ and this address loads my 'default_controller' (login.php in Controllers folder). this controller redirect me to my view "$this->load->view('login_view');". in my view i have a form with this line: which supposed to take me to my form.php in Controller upon the form being submitted but it does not! when i submit i am taken to a url : http://127.0.0.1/CodeIgniter/form with error message "connection attempt to 127.0.0.1 was rejected.".
Also when i try to type a url (i.e. BASE_URL()./index.php/form) or amy other URL in fact, i get errors too. i was under impression that navigating through pages in CI is as simple as typing the name of the file and the method in it in my Controller folder. what am i missing here? any attempt to navigation through URL i get "404 Not Found" error. i am sure i am missing something very simple here but i can't figure out what. i have read the documentations and search the web and no answer is found. i have changed the .htdaccess in root, tried the enable mode in Apache, done all the necessary changes in Config.php , routes.php etc. i would appreciated it if you can tell what am i doing wrong here. i wasn't expecting getting started with CI to be this hard :s
cheers
It seems you "loose" the port (63342) when you redirect. What is the action of your form? If this is an url like "http://localhost/CodeIgniter/form", you should add the port : http://localhost:63342/CodeIgniter/form
You can output set your login form's action by using the URL helper.
site_url('form')
http://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=site_url#site_url

Drupal hook_url_inbound_alter not altering my url

I have in my module named 'categorie' a implementation of:
function categorie_url_inbound_alter(&$result, $path, $path_language) {
if ($path == 'e') {
$result = 'user';
}
}
I'm planning to do something a bit more advanced but I can't even seem to get the basic one working.
With this implementation I expect that if a user goes to mysite.com/e , he gets the user page. But I'm getting a 404.
In this topic:Using module: url_alter and it's hook: hook_url_outbound_alter() they also suggested you need to implement the hook_boot() with nothing in it. However I did implement this hook and this didn't change the behavior.
UPDATE:
I have the "Path" module installed from core and I declared some url aliases in the clean url section. (Maybe this gives a conflict?)
UPDATE2: cleaning the cache didn't do the trick either.
UPDATE3:
I also tries doing the url rewriting in the htaccess file. But when the url was rewritten it destroyed the theming. (https://drupal.stackexchange.com/questions/76475/drupal-does-rewrite-url-but-cant-load-css-themes/76493?noredirect=1#76493). So that's why I'm now trying to do it with the custom module.
What cache did you clear ? It probably not sufficient
to just clear the page cache. You can try a call to
drupal_lookup_path('wipe');
To clear the alias cache. This fixes many problems with the alias system.
Other things to check are the alias database table to be sure that the alias are being
set in the first place.
I'm not 100% sure, cause i'm also very new to drupal. But i think you need to implement hook_url_outbound_alter as well. Good luck. If i find a better answer i'll post it.
Cheers

CakePHP cannot find UsersController

I have been following the blog tutorial on cakephp.org and I had adding and editing the posts table working fine. I wanted to add a user login but I am having trouble when following the tutorial. When I run my application now I keep getting the error:
Error: UsersController could not be found.
Error: Create the class UsersController below in file: app/Controller/UsersController.php
I know the controller is definitely there, I followed naming conventions, and I can't find any errors in the code for UsersController.php or anything else. Does anyone have any idea why this may be happening?
EDIT: clearing caches don't seem to be the problem. All that is there is an empty text file.
Thanks,
Jon
Check file permissions, it should be readable by everyone.
Clear your cache in /app/tmp/cache/models, /app/tmp/cache/persistent
you have problem in your cache
delete all rep in your /app/tmp/cache/models
If you copy those examples from a tutorials page, make sure you copy the php tags at the beginning of your file
<?php
Make sure your debug mode is ON .
Configure::write('debug', 2);
Go in config/core.php file
ensure there is no white space between the start of the page and the php opening tags

Problems reading data from Codeigniter Template Partials, and with controller redirection

I have two unrelated Codeigniter problems:
(a) I am trying to redirect a user to the dashboard after logging in successfully. i.e. from controller "auth" to controller "dashboard". For some odd reason, it keeps redirecting to auth/dashboard (404 error since it does not exist).
This is what I did:
//Within the auth controller
if ($this->auth->login($username, $password)) //Auth->login returns boolean
{
redirect('/dashboard', 'refresh');
# redirect('/dashboard', 'location'); // I tried this too
# redirect('/dashboard/index', 'refresh'); // I also tried this!
}
What am I doing wrong, please? It just keeps redirecting to auth/dashboard
(b) I am using Phil Sturgeon's brilliant Codeigniter Template library (without a Parser) and I am unable to receive data sent into a partials file. This data is ONLY needed by the partials file. I have been over the (unfortunately sparse) library documentation, S/O posts on the topic, and also the CI forums to no avail, there seems to be no clear-cut example showing how a partial receives data that a controller assigns to it.
This is how I have been doing it. Please tell me what I must be doing wrong.
// In the controller page
$this->data['user'] = array('info' => 'username', 'value' => 'Cogicero');
$this->data['prefs'] = array('foo' => 'bar');
$this->template
->set_partial('header', 'partials/header', $this->data)
->set_layout('blog')
->build('foobar_view');
And
//In the header partials page
<?php
/* snip */
print_r($data);
print_r($prefs);
print_r($user);
echo $user["info"];
echo $prefs["foo"];
?>
All the above produce "array does not exist" or "undefined variable" errors! How am I meant to be receiving data within the partials view file?
Thanks
EDIT:
Working on a tight deadline so with no solution in sight, I had to abandon Phil Sturgeon's template library and pick up Jens Segers' instead. http://www.jenssegers.be/blog/25/Codeigniter-template-library
It is a little similar to Phil's but for some reason the partials are receiving and rendering my data properly. Also, Sergers' template library is very well documented. All is fine now, so I'll accept my own answer to problem (a). Thanks everyone.
(a) So after a lot of fiddling around I have solved the first problem i.e. the redirects.
In the config file, we have
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url']=
Apparently, I didn't set a base URL because I'm still on a development local server, I was going to set it to the www address when I upload to the test server. Codeigniter had been guessing all along, but the guess didn't work for my authentication redirects. I set the base url and all redirects were fine.
(b) Now, to see why the partial views are not receiving data. Any help please? :(

CakePHP showing blank page

I have a website that is finished and uploaded, at first it works fine but after a while it stops working.
By stops working I mean whatever page I go to just shows a blank page, empty source.
In Chrome though, I get HTTP Error 500 (Internal Server Error)
To fix this all I need to do is change debug to 2, refresh and then change it back to 0.
I do not know what triggers this to happen, I have tried clearing the cache folders.
There are no log entries in /app/tmp/logs/error from the last week.
Any ideas would be great. Thanks.
In the end it was APC cache conflicts between multiple Cakes on the same server.
All I had to do was change $prefix in config.php and it worked.
Cakephp can show also blank page, if you have some component included in your controller and it contains error, and if for some reason debug does not work(though debug level in core.php is 2 or 3 ) in your component , it just shows blank page.
this post is getting old, but today I upload a new website to a server and get the blank page so I share my experience. I have no access to server logs so I was stuck. I was very confused because that server has running another sites with cakephp so I think the problem was mod_rewrite. After several ours of testing the problem was that the server's php version was too old to run cake 2.8.3. so I use an older version of cake and everything works fine. Hope this help someone.
Happened to me when I had a constant defined, did not notice this and defined another one with the same name.
const VISIBLE = 1;
const DELETED = 0;
const VISIBLE = 1;
A few years later I will add a comment here:
This would mean there was a syntax error, make sure u display these.
It might be due to white space in end of file
Please check your all files if white space is there after ‘?>’ tag it redirects it to blank page
or you can remove ‘?>’(closing php tag) to remove this problem.
In my case i had
public function appError($error) {}
on AppController which was supposed to redirect to a 404 page and i commented the redirect. this led to me having blank page.
In my case the problem was not the cache.
Enabling CakePHP debug should be useful. Change the value to
Configure::write('debug', 0);
to
Configure::write('debug', 1);
in app/cake/core.php
to show the real errors.
I had the exact same problem, it was the folder app/tmp/cache/models that didn't exist. After creating it, no more problem.

Categories