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
Related
I have a problem when try to code something with CodeIgniter.
Always appear in the title of the tab "Error", and in the body of the page appear:
<h1>Error</h1>
unable to load the requested file:
Then appear all the things I had programed correctly.
.php
And this is the structure of all my pages... The controllers works OK, the models works OK, and the views are as I want... except this error...
So I think I change something in the configuration or other place... but I cannot find the mistake...
Any ideas?
Could be a path error. Look carefully and check that you are using this pattern
$this->load->view('path'); // please note the " ' " that I used.
And this if you want to pass parameters to your view:
$data['something']=$something;
$this->load->view('content', $data);
I'm pretty sure you're not passing your data correctly to the view.
Yo have to consider that default root path of view function is application/view, so construct the path consistently.
If that does not work a bit of your coding may be useful.
Hope this help.
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.
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.
When i try to reach /controllername/action1
It finds and runs it, when i add some code into action1, browser shows the old action's results.
It seems like function is cached.
But in my app/tmp/cache folder there is no file with action's or controller's name.
I tried Cache::clear() - But the result is the same.
My debug level is 2.
How can I fix this problem ?
I found out that the problem is with my network card.
I solved issue. Thanks.
I was following a tutorial I found on how to create a simple login using sessions and a database. I followed it to the T (with the exception of tidying up all of the code because theirs was a mess and I'm OCD like that).
I get no errors at all on the page, it just comes up with a blank screen and I can't work out for the life of me why it's doing. I've been trying to get it working for the best part of about 3 hours.
There are 4 files:
index.php - Contains the form for the login script
login.php - Where the form data is processed, which is "require_once"'d into the index.php page at the very start.
config.php - Database connection info
cpanel.php - Where I want the user to be sent once they logged in
And here are those 4 files in action (although I guess they're not in action since they don't actually work!):
index.php
login.php
config.php
cpanel.php
And here's the tutorial I used.
Lastly here's a link to the original (non-source) index.php file
Hope you guys can help, it's driving me crazy now.
Just change
if($jackin) {
to
if(isset($jackin)) {
in login.php file
Also put ini_set('short_open_tag',1)
in your cpanel.php file if short_open_tag is disabled in php.ini
You should try error_reporting(E_ALL); for additional Error output. Check all POST Variables with an echo() / var_dump(), Check the Ifs also with echo() and make sure thats everything is OK.
The echo for $error is doubled.
Additional you should not use the Location Element on the Header with an relative Path.