An internal error has occured - cakephp-2.0

I'm Vaijanath. I'm using cakephp installed on lamp. Now i have created a blog application, but when i run this on localhost/cakephpproject/cakephp/ it is showing an error:
"An Internal Error Has Occured".
And i had changed the "routes.php" in "/app/Config/routes.php" from
"Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));"
to
"Router::connect('/', array('controller' => 'posts', 'action' => 'index'));"
This is an internal error and i'm not able to solve it. Could you please help me in this?

Is your project in your user's public_html dir ?
If so, you must update the three .htaccess files, located in <projectBase>/, <projectBase>/app/ and <projectBase>/app/webroot, and add the following code after each RewriteEngine on statement :
RewriteBase /~<yourUserName>/<projectBase>/
Hope that helped.

In your CakePHP app in the ‘config’ folder change the following setting in the ‘core.php’ file
Configure::write(‘debug’, 0);
Change the ’0′ value to a ’2′ and CakePHP will print all debug errors.
It will display all the errors.. and when the functions works then again change it back to 0.

Related

Different routing behaviour according to debug level

I have a cake php site which lives in a subdirectory on my site called secure, so
https://example.com/secure
When the debug level is 1 or 2 then it works fine, but if I change the debug level to 0 (with Configure::write('debug', 0);) and go to that address I get this error:
Error: The requested address '/secure/index.php/secure/' was not found on this server.
I have the following two routes in routes.php
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/secure', array('controller' => 'pages', 'action' => 'display', 'home'));
How can I get it to work with debug set to 0? I could move the whole site into example.com, but I'd like that to be a last resort.
Routing is not being affected by the debug level.
Your problem is that you are pointing the route to the home page, which is only available in debug mode because it reveals possibly sensitive system information, see app/View/Pages/home.ctp
if (!Configure::read('debug')):
throw new NotFoundException();
endif;
Test your routes with a custom page and everything should work fine.

Cakephp Fatal error rendering issue

I'm using Cakephp version 2.2.4 and it is unable to render Fatal error messages (It shows weird characters).
When i remove the line 'handler' => 'ErrorHandler::handleError' from core file, PHP displays the Fatal error correctly.
Here is a link to screenshot of what i see
Here's the content of my core file (Error related):
Configure::write('debug', 2);
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'ExceptionRenderer',
'log' => true
));
Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
'trace' => true
));
Thanks
Update to the recently released CakePHP version 2.2.5, which apparently fixed some problems in ExceptionHandler.
I just checked and found that I was referencing a model I had not loaded. Loading the model (Actually referencing it through the current model) solved the problem for me.

CakePhp Plugin: Problems with routing

Well, I am struggling for 2 hours trying to finding out how this not works.
The problem:
I have a plugin PaypalIpn in the Plugin Folder. The Plugin has a controller InstantPaymentNotificationsController and some actions inside.
If I try to access directly the plugin's controller with /paypal_ipn/instant_payment_notifications Cake says the there is no Paypal Controller.
Well, I added a route:
Router::connect('/paypal_ipn/:action/*', array( 'plugin' => 'paypal_ipn', 'controller' => 'instant_payment_notifications', 'action' => 'index'));
and surprise the webserver freezes and this errors is fired in httpd.log
PHP Fatal error: Allowed memory size of -2147483648 bytes exhausted (tried to allocate 320596 bytes) in libCake2.3/Cake/Error/ErrorHandler.php on line 114
According to plugin's installation notes the route should be:
Router::connect('/paypal_ipn/process',
array('plugin' => 'paypal_ipn',
'controller' => 'instant_payment_notifications',
'action' => 'process'
)
);
This is not what you have.
Also, be sure you have the latest version. The article on Bakery is from 2009 and is about a very old version.

cakephp redirect doesn't work on server

On my PC with WAMP server and php 5.3.9 everything works fine.
When I upload it to server with php 5.2.1.7 all redirects stop working - when the ->redirect(..) is executed script stops working - it acts like there was die; instead of redirect and nothing is printed and redirect doesnt work.
These are redirects I am using:
$this->redirect( array('controller' => 'users', 'action' => 'login') );
$this->redirect( $this->referer() )
Both (in fact all...) stopped working after upload to server...
------ edit
I managed to show E_ALL errors and for example if I write $omg->lol() before redirect the error is reported as
Notice (8): Undefined variable: omg [APP/Controller/LanguagesController.php, line 31]
Fatal error: Call to a member function lol() on a non-object in ...
But still no error message for redirect...
I managed to fix it!
The problem was that few php files had some tabs or whitespaces before <?php tags and after ?> tags - when I deleted them everything works fine - damn PHP is real bitch!!!

cakephp WebTechNick paypal plugin(missing controller)

I have downloaded WebTechNick's PayPal plugin and copied the files
into /app/plugins/paypal_ipn (exactly as per the instructions). I have
amended /app/config/routes.php to include the routes for the plugin
(these are copied straight from the installation instructions).
When I access http//:[mysite]/paypal_ipn I am getting a
missing controller error:
Error: PaypalIpnController could not be found.
Error: Create the class PaypalIpnController below in file: app/
controllers/paypal_ipn_controller.php
I'm baffled as I have followed conventions yet this isn't working. I
have other plugins working as expected.
What am I doing wrong?
thanks
i would not use this route (besides, its optional)
Router::connect('/paypal_ipn/:action/*', array('admin' => 'true', 'plugin' => 'paypal_ipn', 'controller' => 'instant_payment_notifications', 'action' => 'index'));
I want my admin stuff to be in /admin/... not having one rouge plugin doing something else
after removing that you should have the following available
site.com/admin/paypal_ipn/paypal_items (shows index like always)
site.com/admin/paypal_ipn/paypal_items/index
site.com/admin/paypal_ipn/paypal_items/view/$id
site.com/admin/paypal_ipn/paypal_items/add
site.com/admin/paypal_ipn/paypal_items/edit/$id
site.com/admin/paypal_ipn/paypal_items/delete/$id
and
site.com/paypal_ipn/instant_payment_notifications/process (need to post to this one)
and
site.com/admin/paypal_ipn/instant_payment_notifications (shows index like always)
site.com/admin/paypal_ipn/instant_payment_notifications/index
site.com/admin/paypal_ipn/instant_payment_notifications/view/$id
site.com/admin/paypal_ipn/instant_payment_notifications/add
site.com/admin/paypal_ipn/instant_payment_notifications/edit/$id
site.com/admin/paypal_ipn/instant_payment_notifications/delete/$id
This is really old, but the selected answer didn't help solve my problem and this thread is the only one that I was able to find.
The issue is that by default, cakephp (as of 2.5.4) does not enable admin prefixing. If (like me) you're not familiar with routing or prefixing, I suggest reading the below links:
Routing: http://book.cakephp.org/2.0/en/development/routing.html
Prefixing: http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing
But, the quick fix to this (assuming your fine with this plugins admin routing process) is to uncomment the admin prefixing line in your core.php. DO NOT TRY ADDING THIS TO routes.php. It won't work. Rather look around line 152 in /app/Config/core.php and change
//Configure::write('Routing.prefixes', array('admin'));
to
Configure::write('Routing.prefixes', array('admin'));
I assume you have added
var $components = array('PluginName.Example'); (adjust the values)
to your (app_)controller?

Resources