Core files
Let’s unzip CakePHP and get this show on the road.
Find the latest build file from CakePHP (cake v1.2 6311) and double click it to unzip it. Winzip asks for a folder to unzip into – I’m using c:\apache224\htdocs. Winzip does it thing, extracting and expanding a whole heap of files, creating a folder below \htdocs named \cake_1.2.0.6311-beta, complete with a few standard Cake sub-folders underneath.
Rename the top folder to \cake12 - it is far easier to refer to this rather than the mouthfull \cake_1.2.0.6311-beta.
Project files
Next I’m going to get the files I need for my project into their own folder.
CakePHP has this neat area called the Console and what it can do has been beefed up in v1.2. The file that starts the console lives at \htdocs\cake12\cake\console/cake.bat.
A path to the console is required to be set. Alter the path system variable at Control Panel/System/Advanced/Environment Variables/System Variables/Path to include c:\apache224\htdocs\cake12\cake\console. This way cake.bat can be called from anywhere at the MS Windows command prompt.
Get into the MS Windows command prompt (Start/Run/cmd) .
Change directory to c:\apache224\htdocs.
Type in cake bake -app aa01. Press Enter on your keyboard.
Cake flogs through a series of questions, noting that it is to copy from a skeleton folder deep under \cake12 to your project folder \aa01. When you’re happy, action the copy. I usually flag the operation for verbose output, so I can see where things go.
At this stage we now have the CakePHP core files in the \cake12 folder and our project files in the separate \aa01 folder. Easy, wasn’t it?
I used \aa01 because it sits near the top of listings. Leave the \app folder under the \cake12 folder alone, you will not be using it.
Your directory tree could now look something like this:
/
...
apache224 - this is the folder that contains
my local Apache webserver
for development and testing
(v224 by the looks of it)
...
htdocs - this is the folder http://localhost lists
when entered into a browser
and also the folder I grab for backups
of all my web work
...
aa01 - a folder to hold my project
(a baked project from skeleton files under \cake12)
config
controllers
locale
models
plugins
tests
tmp
vendors
views
webroot
...
cake12 - renamed from cake_1.2.0.6311-beta
app
cake
logs
vendors
...
...
.htaccess files
Next, there’s a few files we get rid of and a few we change.
On my local Apache webserver I use for development I don’t make the webserver folders secure, so I ditch the .htaccess files. Yes, just delete them. Be aware that some webservers like IIS may need these files to secure the folders and stop unwanted / unauthorised raw access through the direct typing of a URL.
On the public website, I rely on the host stopping all unauthorised access outside of the loaded folders, particularly above \htdocs. Most hosts control webservers carefully, your hosted site security is intricately intertwined with their overall security. Be aware that if you are using (and configuring) your own webserver for Joe Public to use, folder security is a big issue. This area is one for the experts., it is too easy to get wrong.
Folder security on public webservers (and networks) requires very careful consideration. I definitely take the view ‘All users are evil’. By that, I mean if you leave an opening, some sod will exploit it at the worst possible time. Users should never gain access to any file without proven authentication (except maybe the Login User or Register User views) and never be given more rights than that required to action the job in hand. Sure, they do complain that they need admin rights or whatever, just ignore it.
Onto the changes needed in some files. Because I want my project folder separated from the main Cake folder, the project application needs to know where the main Cake application is located. Also we need to tell the application how to connect to the MySQL database. See the next post.