CakePHP 3.0.2 installation

I ran into trouble setting up authentication with CakePHP 2.6.2. Given the choice between two branches, I usually choose the newer one. I decided it would be a good time to install CakePHP 3.0.2. There are some issues to keep in mind.

The composer file that was present at the end of April 2015 does not give a complete install. It chokes at the composer file for cakephp/migrations. For some reason, it can’t read what looks like a valid constraint string: “>=0.4.2 < 1.0”. The string looks fine, but I still decided to download the zipped version of the installer and move the vendor folder over to the original installed location by hand.

I then connected the install to my git application. I noticed that it connects to the original masters run by the CakePHP group. I need to remember not to push my changes to them, but to my own repository.

I opened the default CakePHP 3 page, in this case, bookmarker/index.php and saw a blank page. I forgot that I needed to set up a config/app.php page, which I did.

I saw a page with what I’m guessing is the CakePHP default style, with error messages about an inability to write to log files. I remembered that I had to allow write permissions to the tmp folder, so I did that. For OS X 10.9, try “sudo chgrp -R _www tmp; sudo chmod -R g=rwx tmp” inside the directory holding the Cake 3 files.

The default page appears, with more messages. I needed to add a salt value to config/app.php. (Done.) CakePHP could not connect to the database. I created the databases needed for the bookmarker tutorial applications and added that info to config/app.php. Once that new file was read, I finally saw the default page with no errors.

I ran through the basic tutorial and followed through to the authentication section. Authentication and authorization seem to be working, finally. This is good.

CakePHP 2.6.2 installation

I went ahead and installed CakePHP 2.6.2. (It bumped up one to 2.6.3 after I left for vacation. Sheesh.) I did not get a chance to try it out until I returned from my days off. I finally ran it, but I did got PHP warnings and failures.

After some investigation, it looks like I have a permission problem. I put the pages into the expected web root, but I also noticed that the group ownership looked wrong. I had similar problems with a Bootstrap installation in the same web root that were not solved until I fixed group ownership. I’ll try that fix first

> sudo chgrp -R wheel CakePHP

> sudo chmod -R g+w CakePHP

I still saw the same errors. A google search on one of the first error messages showed that I was correct in a general sense, but solved the issue in the wrong way. I needed to make sure the /app/tmp folder was writeable by the web server group, which is _www in this case

> sudo chgrp -R _www /app/tmp

> sudo chmod -R g=rwx /app/tmp

Now it works and I see more items I still have to fix.

hg vs git? Why not both?

For my projects, I prefer Mercurial over Git as the DVCS. Mostly, it’s a personal preference. Four years ago, when I was investigating what to use instead of Subversion, Mercurial seemed easier, so I stuck with it. Bitbucket, which at one time only hosted Mercurial repos, is free for personal projects, while Github charges at least $7/month to hold projects. SourceTree (Atlassian’s desktop app for DVCS) first handled Mercurial repos, then eventually handled Git repos. These people feel that git is good for distributed projects, while Mercurial is good for personal repositories.

SourceTree makes Git really easy to use. Eventually, I’ll get used to the command line instructions for git. I do know that more and more projects are saved in github and provide git instructions to download the files. I’ve used Heroku for a class on web applications and it made deployment very simple, as long as the project was stored it a Git repo. So … for now, I’ll run them both.

Usually, I start personal projects in Mercurial and get it set up and backed up to Bitbucket using SourceTree. I’ve realized that I need to set SourceTree/Mercurial to ignore the git files needed. Before setting up Git, I find the hgignore file and add ‘.git’ to the glob section. It’s much easier to set up hg to ignore files before they are committed into the hg repository. I’ve forgotten in the past and have found myself trying to run ‘hg remove’ (I think) on all the extra files that I can then ignore in hgignore. Too much efforts, when I can start the process on the right foot with the correct command.

I then set up git to watch the project directory with a simple ‘git init’ command. Before I add or commit anything to the Git repo, I update the gitignore file to ignore all the Hg files by adding ‘.hg/‘. I can then safely run ‘git add .’ and ‘git commit -m “first message” ‘ without worrying about all the HG files. It seems to work, so why not both.