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
Related
I have an app in folder /var/www/test
Also there is an "sub-app" in folder /var/www/test/subapp (There is another index.php inside
If user will type test.com the index.php of test should trigger but when user type test.com/triggersubapp the index,php from /var/www/test/subapp shall run.
I failed to create correct statements and RewriteRules and I haven't got much time left. So have any one of You know how to do this easiest way or maybe have a correct definition?
I would greatly appreciate it !!!
EDIT
The main index.php and .htaccess are in /var/www/test/public/. :(
Put this in your .htaccess in root directory:
RewriteEngine On
RewriteRule ^triggersubapp/?$ subapp/index.php
This will rewrite triggersubapp to subapp/index.php which means if user enters test.com/triggersubapp he/she will see result for test.com/subapp/index.php
This question is similar to this other one, but I am using full-URL, no mod_rewrite, see cakephp WITHOUT mod_rewrite or this "sibling question".
I have a CakePHP folder that works well, at /var/www/mycake (localhost/mycake). Now I need change to /var/www/test/mycake (localhost/test/mycake)... HOW TO DO THIS CHANGE with minimal PHP code changes?
I add a controller as Cake message recomended:
TestMyCakeController.php ... nothing
TestController.php OK (!), but other error arrises
Cake defines its ROOT directory in the root index.php file. If you look inside you'll see the following lines:
define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'mycake');
define('WWW_ROOT', ROOT . '/' . 'test' . '/'. WEBROOT_DIR . '/');
You can easily move a CakePHP application to another directory under your web root. The top level index.php contains the line:
define('ROOT', dirname(__FILE__));
This will set the root directory to the current location of the main index.
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.
I'm using AssetCompress v0.5 from the 1.3 branch and the dynamic built is not working. I've done the following so far:
Downloaded and copied the asset_compress folder into my app/plugins folder
Copied the config.ini and renamed it to app/config/asset_compress.ini
Created 2 CSS and JS bundles named public and logged (so 4 in total)
Added AssetCompress.AssetCompress in my $helpers array in my AppController
Changed my default.ctp layout file to: echo $this->AssetCompress->css('public'); echo $this->AssetCompress->css('logged'); (same for ->script())
The output error is:
Error: The requested address '/asset_compress/assets/get/public.css' was not found on this server.
What am I missing?
Ok, I figured it out.
It was because I was using the CssMin filter and I did not download it and put it into the vendor folder. As the plugin seems to be turning the debug level to 0, I did not see the error, until I put a Configure::write('debug', 2); into the beforeFilter().
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?