Installing CakePHP

I started out at http://cakephp.org with reading the cookbook. After skimming the intro, I went to the install instructions as recommended.

First thing, I needed to install was Composer. Although easy, I’ve never used Composer. So, it took me a while to figure out what I was doing (and why). In the end, I opted for the easy route by installing Composer directly into the public html folder:

curl -s https://getcomposer.org/installer | php

Next, I installed CakePHP by using composer to create a new project for the bookmarks tutorial in the html folder, like so:

composer create-project --prefer-dist cakephp/app bookmarker

This is where I ran into my first glitch. The installation wouldn’t complete properly because my Php installation did not include the ‘intl’ or ‘mbstring’ modules. The (simple) solution was to install these modules like so:

 apt-get install php-intl

 apt-get install php-mbstring

… Then reload the server:

service apache2 reload

… And then confirm the installation succeeded:

php -m

Once the needed modules were installed, the previous ‘create-project’ instruction worked perfectly and Composer successfully set up the tutorial project as promised.

FYI, I let Composer set permissions automatically

Well, almost as promised. The default home page showed up in my browser, but the CSS files couldn’t be found.

It turns out that ‘URL rewriting’ wasn’t properly configured on my server. As a result, the server was looking for the ‘/css’ folder in the project’s root directory, instead of the ‘/webroot’ folder.

At this point, I switched to the manual installation instructions on the CakePHP site for more precise guidance. It turns out that I had two issues to resolve.

The first issue related to allowing .htaccess files to overwrite the server’s default configuration settings. The fix for this was easy enough:

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
<Directory /var/www />
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

The second issue was that mod_rewrite was turned off in apache by default, so the .htaccess files were not being read. The fix was easy too:

a2enmod rewrite

service apache2 restart

With these fixes behind me, everything showed up in my browser just as promised, including a message to tell me the app couldn’t connect to the database (as expected).

I now went back to the quick start guide and followed the instructions to create a database and add some tables for the tutorial by copying and pasting the code provided. Then I modified the installation’s config/app.php file by setting the user, password, and database name defaults so the app could make the connection.

Another browser refresh and, WooHoo, the oven is hot!