1

I started a project where the previous developer was using CakePHP and they've sent me their files (core and app folders and files). I'm trying to set this project up locally using MAMP to make changes.

I'm also saving my files in dropbox, I don't have any experience with CakePHP but have some knowledge with PHP mostly through WordPress. Not sure where to start.

Thanks!

@summea

Router::parseExtensions('csv');
Router::connect('/', array(
    'controller' => 'pages',
    'action' => 'view',
    'home'
));  

/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array(
    'controller' => 'pages',
    'action' => 'display'
));
Router::connect('/' . Configure::read('Routing.admin') , array(
    'controller' => 'statistics',
    'action' => 'index',
    'prefix' => Configure::read('Routing.admin') ,
    'admin' => true
));
Router::connect('/img/*', array(
    'controller' => 'attachments',
    'action' => 'view'
) , array(
    'size' => '(?:[a-zA-Z_]*)*'
));
Router::connect('/files/*', array(
    'controller' => 'attachments',
    'action' => 'view',
    'size' => 'original'
));
Router::connect('/img/*', array(
    'controller' => 'attachments',
    'action' => 'view',
    'size' => 'original'
));
Router::connect('/terms', array(
    'controller' => 'pages',
    'action' => 'display',
    'terms'
));

Router::connect('/new-idea', array(
    'controller' => 'ideas',
    'action' => 'add'    
));
Emma Harris
  • 65
  • 1
  • 8

1 Answers1

3

While this sort of question may not be a good fit for StackOverflow (possibly too broad,) the need to set up an existing CakePHP installation can be very real.

Depending on what version of CakePHP you are using, checking out the CakePHP book (version 1.3 / version 2.0) would probably be a great place to start (as @Shankar has noted in the comments.) For installation in particular, the "Beginning With CakePHP" or "Installation" sections of those respective CakePHP Book editions may be good starting points.

Note: you may be able to find the version of CakePHP in the cake/VERSION.txt file of the project folder.

Common Issues with Getting Started

  1. Getting existing database data into your local database
  2. Making sure your app/config/database.php is set up to match your database
  3. Making sure that your app/tmp folder is "writeable"

Dealing with the Issues

  1. If you have an .sql file of the previous (production) database, you can then create a new database locally (in your MAMP-based database,) and import the production .sql file into your new database. (Note: If you don't have an .sql file of the previous database, you may need to find a way to "dump" the existing/production database so that you can import it into your newly-created, local database. This may involve using something like mysqldump or phpMyAdmin to do the actual "database dump" as the database you need may be on the production server.)

  2. In order to connect to the newly-created local database, however, you'll need to make sure that you have the correct database connection information listed in your app/config/database.php file. (Basically: make sure the host, login, password, database fields match your new, local database information. (Note: sometimes the host is the hardest part out of these setup pieces... for local installations, you may need to use 'host' => '127.0.0.1', instead of 'host' => 'localhost', ... or whatever hostname was used in the original/existing production setup.)

  3. Your app/tmp folder needs to be made "writeable" by the "web server user". Your "web server user" probably depends on your MAMP setup... and may be able to be set in a way similar to the screenshot in this other (non-related) question. (Note: Basically, you are looking for a way to set the w "write permission" to "on" or "enabled"... for the user that is "connected" to your MAMP setup.)

Update

So, from looking at the screenshot you posted from the comments below, there are a few errors here that might help:

  1. URL rewriting is not properly configured on your server

    • You can either try to find out what advice CakePHP gives you by clicking on the 1) Help me configure it link in the error message (to the right of the above URL rewriting error message,) or you can try looking around online for tips on configuring URL rewriting within a MAMP environment, like in this question (and related answers).

  2. Cake is NOT able to connect to the database

    • Does the app/config/database.php file match your database credentials? (And, as you know, please don't post the database file... unless the connection data is changed to something generic :)

  3. Please change the value of the 'Security.salt' in app/Config/core.php

    • At some point down the road, you'll probably want to change the letters/numbers in the Security.salt in your app/Config/core.php so that the letters/numbers are different from the standard installation salt value. (This could be randomly generated with some tool online... or done manually by hand.)

  4. Please change the value of the 'Security.cipherSeed' in app/Config/core.php

    • This is similar to #3 above... but for the 'Security.cipherSeed' instead of the 'Security.salt' (and it appears to be a string of only numbers... rather than letters/numbers.)

Community
  • 1
  • 1
summea
  • 7,390
  • 4
  • 32
  • 48
  • 1
    Thanks for the help! I was able to import the database from an .sql file and configure the app/config/database.php but I'm still getting a blank screen when I visit my app. The folder structure I was given is different from the default. I have: app/ core/ --lib/ ...instead of: app/ lib/ – Emma Harris Apr 08 '14 at 19:33
  • Ah, so is this CakePHP version 2.0 or higher? Also, there is a way to turn on "debug mode" so that you can hopefully see what errors are happening when you get a blank screen: in the `app/config/core.php` file, set the "Debug Level" to `2`. Then, the next time you reload your app in a web browser, you should see some sort of error lines _(and the listed errors might help narrow down the remaining problems...)_ – summea Apr 08 '14 at 19:45
  • @EmmaHarris Sorry, forgot to tag your username earlier for the last comment above... You could also try deleting the files inside the `app/tmp/cache/models`, `app/tmp/cache/persistent`, and `app/tmp/cache/views` folders to see if that helps toward the current issue. _Note: if you do turn on "debug mode" (from the last comment,) it's probably a good idea to turn it "off" when you're done needing it._ – summea Apr 08 '14 at 20:07
  • 1
    I turned on debug level 2 and cleared all the cache files and still just see a blank screen. I do get this in my error logs though: `[MissingControllerException] Controller class AppsController could not be found.` – Emma Harris Apr 08 '14 at 20:19
  • @EmmaHarris Hmm, well, is there any way you could post the main parts _(the rules)_ of your `app/config/routes.php` file somewhere in your question above? One strange thing about that error is that there normally is an `AppController` but not an `AppsController`... _(unless the app you are working with has some sort of special `AppsController`, of course...)_ – summea Apr 08 '14 at 20:34
  • 1
    I did notice that difference and thought maybe it was a spelling error and might be why things aren't working. Do you mean the main parts (the rules) as in the code, like this? I'll post it in my question above. Thank you! – Emma Harris Apr 08 '14 at 20:59
  • @EmmaHarris Thanks for posting that code! Unfortunately, that code looks alright... Here's another approach that might help narrow down the `AppsController` oddity: since you are using Mac OS X, try opening up the `Terminal` application _(in your Utilities folder on your computer)_ and navigate to your project's folder (by using `cd /Users/yourusername/path/to/project/here`) and then try searching for anything related to the `AppsController` thing like this: `grep -r 'AppsController' *`. You might end up getting a lot of search results... but those files can show why `AppsController` is called – summea Apr 08 '14 at 22:09
  • 1
    Thank you! All I see is `TestsAppsController` and the error logs. This is what I get http://pastebin.com/YcdjD07a – Emma Harris Apr 09 '14 at 18:22
  • @EmmaHarris No problem; just curious about why this would be happening, haha. That's so weird; seeing that some tests were created for something called `AppsController` indicates that `AppsController` did exist at some point... I almost wonder if the original developer forgot to attach the `AppsController` in the files that were sent to you...? But I'm still curious as to how the CakePHP app knows to call that particular controller on "startup". Have you had any chance to try out any other _routes_ (from your web browser,) just to see if other routes are working? – summea Apr 09 '14 at 18:52
  • @EmmaHarris Great screenshot! Please see the `Update` section in the answer above for possible next steps :) – summea Apr 09 '14 at 20:41
  • 1
    This is great, thank you!! And yes, forgot to edit the db file :\ – Emma Harris Apr 10 '14 at 14:17
  • @EmmaHarris No problem; did those steps end up helping at all for your setup? :) – summea Apr 11 '14 at 21:21
  • Thanks for all your help! Busy few days. Unfortunately, it's still not working. – Emma Harris Apr 15 '14 at 13:10
  • @EmmaHarris Oh, are you getting a certain error at the moment? – summea Apr 15 '14 at 16:16
  • 1
    Great news, I got it working last night! What a good feeling. Thanks so much :) – Emma Harris Apr 16 '14 at 17:26
  • @EmmaHarris Hey, nice work! Sometimes it just takes patience and persistence :) Is there anything else you'd like added into the question or answer above in order for it to be accepted? _(If so, it might be good to add for people who have similar questions in the future...)_ Thanks! – summea Apr 16 '14 at 17:39
  • thanks for this message! I'm not sure what else should be added as it seemed to be multiple bugs and incorrect configuration on my part. Learning curve! Thanks again for your help :) – Emma Harris Apr 22 '14 at 17:15