Get started with CakePHP
Overview
The CakePHP framework is installed in the frameworks/cakephp directory of the installation directory. This folder includes an example application. Application files are in the app/ directory and public files, such as HTML pages, CSS and JavaScript files, images and other media assets are stored in the app/webroot directory.
Activation and Testing
To enable the example application, edit the Apache configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf and uncomment the following line
Include "/opt/bitnami/frameworks/cakephp/conf/httpd-prefix.conf"
Then, restart the Apache server.
$ sudo /opt/bitnami/ctlscript.sh restart apache
You can now verify that the example application is working by visiting its URL using your browser at http://SERVER-IP/cakephp.
Here is an example of what you might see:
Configuration
Before using the example application, here are a few important points to consider:
To secure your application, modify the encryption keys in the app/Config/core.php file. Ideally, use a key that’s 32 characters or longer in length.
Configure::write('Security.salt', ''); Configure::write('Security.cipherSeed', '');
On Linux, you can use a command like pwgen 32 to generate a 32-character random key. On Windows, you can use a tool like PWGen.
If your application will use a database, edit the database settings at app/Config/database.php.
public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'port' => '3306', 'login' => 'user', 'password' => 'password', 'database' => 'database_name', 'prefix' => '', //'unix_socket' => '/opt/bitnami/mysql/tmp/mysql.sock', //'encoding' => 'utf8', );
NOTE: If you are using an operating system that supports sockets, such as Linux or Mac OS X, you can optionally specify the unix_socket parameter in the above configuration array instead of the host and port parameters.
MySQL support is already available by default. If you plan to use PostgreSQL, enable the php_pdo_pgsql extension in the /opt/bitnami/php/etc/php.ini file.
extension=php_pdo_pgsql
To move the CakePHP example application such that it is available at the root URL of the server (without the /cakephp URL suffix), follow these steps:
Edit the /opt/bitnami/frameworks/cakephp/conf/httpd-prefix.conf file so that it looks like this:
DocumentRoot "/opt/bitnami/frameworks/cakephp/app/webroot/" #Alias /cakephp/ "/opt/bitnami/frameworks/cakephp/app/webroot/" #Alias /cakephp "/opt/bitnami/frameworks/cakephp/app/webroot" Include "/opt/bitnami/frameworks/cakephp/conf/httpd-app.conf"
Edit the /opt/bitnami/frameworks/cakephp/app/webroot/.htaccess file so that the RewriteBase directive is set to the root URL:
RewriteBase /
Restart the Apache server:
$ sudo /opt/bitnami/ctlscript.sh restart apache
You should now be able to access the example application at the root URL of your server.
Upgrading to CakePHP 3.x
If your Bitnami stack currently uses CakePHP 2.x and you would like to upgrade to CakePHP 3.x, follow these steps:
NOTE: The steps below assume that you have already activated the CakePHP framework and example application.
Log in to your server console.
Back up the current version of CakePHP:
$ cd /opt/bitnami/frameworks $ sudo mv cakephp cakephp.old
Download and install the latest version of CakePHP (3.0.10 at the time of writing):
$ cd /opt/bitnami/frameworks $ sudo wget https://github.com/cakephp/cakephp/archive/3.0.10.tar.gz $ sudo tar -xzvf 3.0.10.tar.gz $ sudo mv cakephp-3.0.10 cakephp
Create a demo application:
$ cd /opt/bitnami/frameworks/cakephp $ sudo composer self-update $ sudo composer create-project --prefer-dist cakephp/app app
Copy the necessary configuration files from the previous CakePHP installation:
$ sudo cp -R /opt/bitnami/frameworks/cakephp.old/conf /opt/bitnami/frameworks/cakephp/ $ sudo cp /opt/bitnami/frameworks/cakephp.old/app/webroot/.htaccess /opt/bitnami/frameworks/cakephp/app/webroot/
Change file ownerships of the CakePHP directory:
$ cd /opt/bitnami/frameworks/ $ sudo chown -R bitnami:root cakephp
You should now be able to access the example application and verify that it is using CakePHP 3.x, as shown below:
More Information
Learn more about developing applications with CakePHP at http://book.cakephp.org/.