cakephp WebTechNick paypal plugin(missing controller) - cakephp

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?

Related

Cakephp RESTful routing with Plugin

Using Cake 2.x I am trying to route RESTful traffic to my Users controller to my UserManagement plugin.
My routes are as follows:
// re-redirect root traffic to login
Router::connect('/', array('plugin'=>'UserManagement','controller' => 'Users', 'action' => 'login'));
CakePlugin::routes();
Router::mapResources(['users']);
Router::parseExtensions();
I also tried:
Router::mapResources(['UserManagement']);
When I call the resful url I get the following error:
users/1.json
{
"code": 404,
"name": "Action UsersController::51() could not be found.",
"message": "Action UsersController::51() could not be found.",
"url": "\/users\/51.json"
}
Thanks in advance.
Following CakePHPs convention over configuration approach, you specify plugins like you do anywhere else, using the plugin syntax, ie prepend the plugin name and separate it with a dot from the controller name
Router::mapResources('UserManagement.Users');
This will of course also require you to use the plugin name in the request URL, ie
/user_management/users/51.json
instead of only
/users/51.json
If you'd wanted to use the latter, but still connect to the plugin, then you could try the prefix option trick, that is, supply the default value of /, which stops the router from using the plugin name as the prefix (not to be confused with actual prefix routing).
Router::mapResources('UserManagement.Users', array(
'prefix' => '/'
));
See also
Cookbook > Plugins > Using a Plugin
Cookbook > Appendencies > Glossary > Plugin Syntax

An internal error has occured

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.

Using Fat-Free PHP for Backbone.js routing with external Model.php files

I'm very new to Fat-Free and Backbone.js. I've been searching and reading articles and searching and reading articles trying to find a way to route to individual PHP files containing the database communications. The code below works, and I can use it, but it seems hackish. Is there a way to call an external PHP file (in the server/models/ directory) and a specific method from the $f3-route(...) line?
<?php
// File: /index.php
define("PATH",1);
$f3 = require('server/fatfree/lib/base.php');
$uri = explode('/', $_SERVER["REQUEST_URI"]);
require_once "server/models/{$uri[PATH]}.php";
$f3->route('GET /hello/#file', 'HelloModel->doSomething');
$f3->route('GET /project/#file', 'ProjectModel->doSomething');
$f3->route('GET /book/#file', 'BookModel->doSomething');
$f3->run();
?>
Thanks a lot for your advice.
You should add the server/models directory to the autoloader of F3 using the autoloader feature.
$f3->set('AUTOLOAD','server/models/');
That way, the required source files of your classes will be loaded on demand. However, note that the files must be named the same as your class, i.e. class Foo has to be defined in foo.php or Foo.php. The case of the filename does not matter.

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 2.1 new install Missing Controller Error

I am completely new to CakePHP and installed 2.1. I am getting this error:
Missing Controller
Error: Index.phpController could not be found.
Error: Create the class Index.phpController below in file: app\Controller\Index.phpController.php
<?php
class Index.phpController extends AppController {
}
Notice: If you want to customize this error message, create app\View\Errors\missing_controller.ctp
Stack Trace
APP\webroot\index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
ROOT\index.php line 40 → require(string)
I followed their guide at http://book.cakephp.org/2.0/en/installation/advanced-installation.html and tried everything it stated:
I enabled mod_rewrites (they were already enabled from something else)
I have all the .htaccess files in the directories
I have cake installed under my document root so I access it at localhost/cakephp/index.php
I do not know where to proceed from here. Thanks for any help you can give me.
Update: I just re-read your question and realized you're loading http://localhost/cakephp/index.php. Don't do that. Since you appended "index.php", it is trying to load a controller called "index.php" and the action "index" for that controller. Resulting mapped path to the "index.php controller" is app\Controller\Index.phpController.php.
Since you have the rewrites enabled, browse to http://localhost/cakephp without appending any filename.
Original answer:
Assuming you're using Apache, double-check the .htaccess in your /app/webroot directory. It should include the following:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Based on your error, it doesn't look like it's properly appending the path after your index.php file.
If you are using cakephp 2.0 or greater than rename the controller file name as the class name.
ie TaskController.php
class TasksController extends AppController {
--Your code inside class
}
I hope this will help you
the easiest solution is to stick to the "live environment" as close as possible.
this means using vhosts to use a "domain" and correctly root down to your webroot dir:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
this leaves almost no room for error and also helps with other potential problems like "absolutely linked asset files" etc

Resources