Hello Every One ! i started to learn CakePHP, i have installed it and working fine, now i need to learn how to run my applications and where i want to save my php files and how to run it?? Normally we run PHP files localhost/folder/index.php or something else, But how to do that in CakePHP, Any Help Much Appreciated

Dani AI

Generated

Practical, version-aware steps to get a CakePHP app running locally (for ; thanks to for pointing to the manual).

The web-accessible entry point is the index.php inside the framework's webroot. For CakePHP 2.x that is project/app/webroot; for CakePHP 3.x+ it is project/webroot. Point the webserver DocumentRoot at that webroot folder and browse to http://localhost/yourapp/ (URL rewriting will hide index.php).

Two easy ways to run locally:

  • Put the whole project under the webserver (XAMPP/WAMP/MAMP) or create a VirtualHost that sets DocumentRoot to the app's webroot.
  • Use PHP's built-in server (PHP 5.4+), which is handy for quick testing:
# CakePHP 2.x
php -S localhost:8000 -t app/webroot

# CakePHP 3.x+
php -S localhost:8000 -t webroot

Example Apache VirtualHost (adjust path for Cake 2 vs 3+):

<VirtualHost *:80>
    ServerName myapp.local
    DocumentRoot "/path/to/project/app/webroot"   # or "/path/to/project/webroot"
    <Directory "/path/to/project/app/webroot">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Where to save code: follow MVC — controllers, models and views live in the framework folders (Cake 2: app/Controller, app/Model, app/View; Cake 3+: under src/), and put CSS/JS/images in the webroot. Avoid dumping ad-hoc PHP files in webroot; create controllers/actions and views so Cake's routing works.

Quick troubleshooting: enable Apache mod_rewrite and AllowOverride All so Cake's .htaccess works; make tmp (or app/tmp) and logs writable; turn on debug to see errors; clear the cache if routing changes don't take effect. As noted, the official manual has full installation and server-setup details.

Recommended Answers

All 2 Replies

CakePHP Manual is a good place to start. It really is easy, i suggest using Codeigniter its a much better MVC and is well documented and easier to understand.

Hi marases, Thank you for your reply.. Am trying your suggestion..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.