Showing posts with label cakephp. Show all posts
Showing posts with label cakephp. Show all posts

Monday, September 19, 2011

Multiple Applications, One Cake (or more)

With running multiple CakePHP applications, keeping them all up to date with the latest security fixes can be an issue. Instead of having to update each one individually, having a shared cake installation can be beneficial.

While there are many different methods of doing this, I couldn't get any of the ones I tried to work. So I deconstructed the process and made it VERY simple and functional. Obviously since we are using symlinks this is applicable only on Linux.

Step 1: Extract CakePHP to where you want your application to reside. e.g. /var/www/html/myApp/
Step 2: Extract CakePHP to where you want your Cake to reside. For ease in updating, I named mine the same as the version number. e.g. /var/www/cakephp-1.3.11
Step 3: While unnecessary, I found it convenient to create a symlink to the cake directory named 'cake', otherwise you have to either name your cake folder the same every update, or update all your application symlinks
$ ln -s /var/www/cakephp-1.3.11 /var/www/cake
Step 4: Delete the cake directory in your application.
$ rm -fr /var/www/html/myApp/cake
Step 5: Create a symlink in the application folder to the shared cake folder.
$ ln -s /var/www/cake/cake /var/www/html/myApp/cake
Now any application that has that symlink in it instead of the cake folder will use the shared folder. Update the shared folder once, all applications that are sharing it get updated.
Step 1: Extract new version of cake to same directory as old version of cake. e.g. /var/www/cakephp-1.3.12
Step 2: Update your shared simple symlink to the new directory
$ ln -f -s /var/www/cakephp-1.3.12 /var/www/cake
That easy.

If you want to have an application use an older version of Cake, just install it in the application itself as normal, OR install it next to the other version and change the symlink in the app folder to match the different version of cake.
Step 1: Extract different version of cake for sharing. e.g. /var/www/cakephp-2.0.0-RC2
Step 2: Update your application's symlink to the new directory
$ ln -f -s /var/www/cakephp-2.0.0-RC2/cake /var/www/html/my2.0App/cake

Wednesday, November 3, 2010

Dreamweaver and CakePHP (.ctp) Files

Dreamweaver does not recognize .ctp files by default, so to get them to color code as PHP files, make some small changes in the configuration files.

Edit C:\Documents and Settings\user\Application Data\Adobe\Dreamweaver 9\Configuration\Extensions.txt Add CTP to the All Documents and PHP Files lines.

Edit C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\Extensions.txt Add CTP to the All Documents and PHP Files lines.

Edit C:\Documents and Settings\user\Application Data\Adobe\Dreamweaver 9\Configuration\DocumentTypes\MMDocumentTypes.xml Add ctp to the documenttype id="PHP MySQL"

Edit C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\DocumentTypes\MMDocumentTypes.xml Add ctp to the documenttype id="PHP MySQL"

Restart Dreamweaver

CakePHP: Configuration

CakePHP uses the /app/tmp directory for a number of different operations. Model descriptions, cached views, and session information are just a few examples.

Make sure the /app/tmp directory and all subdirectories in the Cake installation are writable by the web server user (apache).
chown -R apache /app/tmp
The Security seeds need to be set for uniqueness. Edit /app/config/core.php Comment out the following lines, duplicate them and change their values:
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
Configure::write('Security.cipherSeed', '76859309657453542496749683645');
Upload file.

Create site database in MySQL.

Copy /app/config/database.php.default to /app/config/database.php

Edit /app/config/database.php Change values for 'host', 'login', 'password', and 'database' to match your database configuration.

Save and upload the file and test by browsing to the root page.

CakePHP: Installation

Go to http://www.cakephp.org/ and download the latest version of CakePHP (currently 1.3.11)

Extract to web root folder, upload and browse to the root page to test installation.

For shared hosting, the /.htaccess file and the /app/webroot/.htaccess file will need some modification for CakePHP to work.

Edit /.htaccess and within the <IfModule> block add RewiteBase / after RewriteEngine on. Repeat for /app/webroot/.htaccess

For 1and1.com shared hosting php4 is default unless you add the following line to the top of your .htaccess file:
AddType x-mapp-php5 .php
Save and upload the file.

About: Drug-ed

This blog is my step-by-step process of learning CakePHP, and designing and building Drug Education, a drug education and compliance assistance website.

I'm posting it both as a record of my path for myself, as well as to help any other aspiring web developers who want to work with CakePHP.

The idea of Drug-ed is to assist in drug compliance and education. A study from 1977 (Improved Patient Compliance through Use of a Daily Drug Reminder Chart) showed a 23-26% increase in drug compliance when a reminder was given. In this digital age an SMS message sent to a cell phone would work for me and may work just as well for others.