1

I am just starting to work with CakePHP3.0 and while following the 'Quick Start Guide' I came across a step that has me stuck.

The section labeled DATABASE CONFIGURATION has me create some MySQL tables (I copy pasted from the site) and then run the commands: bin/cake bake all bookmarks, bin/cake bake all users, and bin/cake bake all tags.

After running those three commands several files have been generated; the Models and Controllers associated with the tables I just created. However, the Views have not been created...By the way I am using Ubuntu 12.04

As suggested by the tutorial I checked my apache2/mods-enabled directory for the rewrite.load and it is there.

Has any else experienced this issue? It is likely that I am making a simple mistake

This is the output when I ran bin/cake bake all bookmarks the first time: enter image description here enter image description here

As the tutorial suggested, if I receive a 404 page not found error I should make sure that mod_rewrite is enabled for apache2, also I noticed that it says to use http://localhost:8765/bookmarks since my web server is configured on port 80 I have been ignoring the port # suggested by the tutorial.

Here is a screenshot of my apache2/mods_enabled/: (rewrite.load is present) enter image description here

Lastly, here is the data source that I have configured in /config/App.php: enter image description here

It is beginning to appear that the problem is with my Apache configuration and the rewrite rules. I will investigate into this further.

9
  • Are you sure that you aren't mixing up Views and View Templates?
    – ndm
    Aug 18, 2015 at 1:16
  • @ndm The tutorial says that after using those commands I should be able to visit localhost/bookmarks , however I get a 404 Aug 18, 2015 at 1:31
  • Well, that wasn't the question. Anyhow, "I get a 404" isn't a very detailed problem description. Does the request really hit the app? What exactly is being shown? What do the logs say? And to go back a few steps, what does the CLI show when running the mentioned commands?
    – ndm
    Aug 18, 2015 at 1:40
  • 1
    the Views have not been created - the template files are in the bake output. You've given a lot of detail, but not much that is relevant to your actual problem.
    – AD7six
    Aug 18, 2015 at 6:27
  • 1
    Please check the content of the subfolders in /homeSite/src/Template/ -there should be some *.ctp files. These are the view files generated by Cake Bake. To get more information about your 404 please check the error log file in the tmp log folder of your Cake installation. If there is no entry in the logfile the problem can be outside of CakePHP with your server configuration... If you have an entry in the CakePHP error log file you should enable debug mode in your core.php configuration file and try to access the page again, a detailed error message should be shown than in your browser...
    – Oops D'oh
    Aug 18, 2015 at 15:43

1 Answer 1

0

Turns out that I was initially confused about what CakePHP3 was supposed to create and realize now that it was running as expected (see question above for output). One the proper DocumentRoot is set, if rewrite is not set up properly navigating to you page may begin a download of the file you mean to view instead.

The real problem was with my Apache configuration. These are the steps I followed to configure Apache 2.4 (after reinstalling Apache):


  1. Add the new DocumentRoot in /etc/apache2/sites-available/000-default.conf and in /etc/apache2/sites-enabled/000-default.conf

  2. Enable mod_rewrite: a2enmod rewrite

  3. Restart Apache: service apache2 restart


After enabling rewrite your /etc/apache2/mods-enabled/ may look like this(notice rewrite highlighted): rewrite_enabled Problem has been resolved. Thanks to this post!

@user1843159 - Thanks for pointing me toward the direction of Apache Configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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