I'm new to cakephp and I'm having some problems with setting up a local development server. I have my cake install located at http://localhost/dropbox/my_site/. However, when I try to visit that url, it tells me the dropbox controller isn't set up. How do I tell CakePHP to start in my_site rather than /localhost/?

I've tried adding connect(/localhost/dropbox/*) to the routes, but it seems like it still looks for models in the wrong location.

I tried editing index.php in app/webroot but all the examples show how to write the directory in linux format rather than windows, so I'm not sure how to structure 'ROOT'

up vote 5 down vote accepted

CakePHP will work happily in a subdirectory - I have several Cake sites running at http://localhost/{appname} on my dev machine.

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', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);

Since it's taking ROOT from dirname(__FILE__), it will always point to that file's location.

I suspect you have problems in your routing file. Did you create any custom routing rules to account for being located in a subdirectory? If you did, your cake install may be trying to access http://localhost/dropbox/my_site/dropbox/... and that's why you're getting that error.

  • Router::connect('/', array('controller' => 'cars', 'action' => 'index')); That's the only thing I edited in my routes. – Stewie Feb 28 '12 at 16:58
  • @Stewie and you get this error when you directly navigate to your site? Or only after clicking a link on your site...? – Farray Feb 28 '12 at 17:03
  • When I go to localhost/dropbox/my_site it tells me dropbox controller doesn't exist. The cakephp installation is in my_site folder. -the second is case-sensitive When I go to localhost/Dropbox/My_Site I get: Call to a member function find() on a non-object in C:\wamp\www\Dropbox\My_Site\app\Controller\CarsController.php on line 10 – Stewie Feb 28 '12 at 18:34
  • Yep, that was it. When I go to localhost/dropbox/my_site it tells me dropbox controller doesn't exist, but as it seems, the url is case sensitive. When I go to localhost/Dropbox/My_Site I get another error, but that's just from some naming conventions. I'm up and running. Thanks! – Stewie Feb 28 '12 at 18:46

This likely doesn't have so much to do with CakePHP as it does with your web server.

If dropbox is your document root, it should be mapped accordingly in your web server configuration. For example using DocumentRoot in Apache.

  • I don't have a separate site set up for this development site in my web server. Maybe that's what I'm doing wrong. I'm using wamp and I just placed my dropbox folder inside, with a folder for my application inside my dropbox folder. – Stewie Feb 28 '12 at 17:03

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.