Getting started with CakePHP 3

I mentioned back in my blog post for “Yet another change” that I was looking to use CakePHP for a project I had in my head that I wanted to start on.  Today I had some time free so I thought I would get set up with CakePHP V3.0, and follow their user guide.  I went through the various steps within the tutorial, and when I came to load the page, I was presented with a blank screen.  Completely blank, no error message, no indication of what might be wrong, and not even any mark-up.  Nothing in the logs folder to guide me.  After a while of trying, I decided to use the terminal to see if it could help, so I did the following:

wget http://url.for.project

It was nice enough to return a 500 internal server error, so I knew (from experience) that it was a fatal PHP error kicking off somewhere.  I added the following lines to the top of the webroot/index.php file:

error_reporting(E_ALL);
ini_set("display_errors", "on");

Once saved, I tried to access the page again.  Thankfully I was presented with a fatal error message from PHP that vendor/autoload.php could not be found for a require_once.  Something didn’t seem right, as I’d followed what was in the installation instructions so composer should have pulled everything down, so I thought.

After a while of digging around and when I was about to give up on CakePHP 3.0, I decided to look at their github page in order to clone that code and work with that as a base.  I then found the following line in their readme.md file:

composer require cakephp/cakephp:"~3.0"

Something I had yet to try…possibly this could work.

I navigated to the project folder in the terminal and installed composer to that folder using:

curl -sS http://getcomposer.org/install | php

Once that was completed I then ran the command from the Cake readme.md file:

composer require cakephp/cakephp:"~3.0"

Loads of stuff downloaded at that stage.  Once that was completed, I tried to access my application again.  Fatal error, no app.php config file in the config folder.  I copied the app.default.php and renamed it app.php, tried once again to load the project and we suddenly had a working framework.  All that was left to do was remove the error reporting code from webroot/index.php and then write this post!

I’d like to think that after 7 years of development, I am classed as experienced, but the whole process of going from nothing to a working framework was painful with Cake, and I think the project should have a simple source code archive to download for people just to load into their environment and start with.

I’ll keep going with Cake on this occasion, but there’s other things I want to do project wise at the same time, so for those I might stick to CodeIgniter.  Less hassle on the installation front.