Running with Cake

27 Jan 2008 In: CakePHP, Code

I’ve been developing with PHP for god knows how long and just got involved with Python MVC frameworks like Pylons and Turbogears. I wanted to share with you (and keep a track record for myself) how to setup CakePHP, a PHP MVC framework, with Windows.

It’s really simple…

  1. Get EasyPHP 2.0 - this packages PHP, Apache, and a MySQL DB all together. Download and install.
    • I created a new folder to put all my dev work in, so I installed to C:\webdev\EasyPHP
  2. Get CakePHP 1.2 - Download and install
    • I created a dir called ‘C:\webdev\projects\cake_1.2′ (all of my projects will go in the /projects folder)
    • Move the ‘cake’, ‘vendors’ , .htaccess, index.php into this folder
  3. Get cygwin if you don’t already have it
  4. Add some paths to your env
    • Go to Control Panel > System > Advanced > Env Vars and add the following:
    • C:/webdev/EasyPHP2.0b1/php5/;
    • C:/webdev/EasyPHP2.0b1/php5/ext/;
    • C:/webdev/EasyPHP2.0b1/mysql/bin;
    • C:/webdev/projects/cake_1.2/cake/console;
  5. Add folders for the other projects you will be working on
    • I created ‘C:\webdev\projects\proj1′ and ‘C:\webdev\projects\proj2′
    • Within the projX directory I have ‘projX\trunk\app’ which is where all the code will go
    • I will keep proj docs in ‘projX\docs’, so everything is kept together
  6. Edit your config files
    • php.ini
      • EasyPHP does this for you, but you can tweak as you’d like
    • httpd.conf (Apache)
      • change DocumentRoot “${path}/www” to DocumentRoot “C:\webdev\projects”
      • change <Directory “${path}/www”> to <Directory “C:\webdev\projects”>
      • Make sure the AllowOverride is set to All for the correct Directory
      • Make sure this line is uncommented
        LoadModule rewrite_module mod_rewrite.so
      • if you want to be able to setup virtual hosts (so you can do http://projX/ instead of http://localhost/blahblah/blah/projx then uncomment the following line:Include conf/extra/httpd-vhosts.conf
  7. Add a virtual host for each project you will work on (if you followed the last step)
    • Open C:\webdev\EasyPHP2.0b1\apache\conf\extra\httpd-vhosts.conf
      Add something like this:<VirtualHost *:80>
      DocumentRoot /webdev/projects/projX/trunk/app/webroot
      ServerName
      projX:80
      ErrorLog logs/
      projX_error.log
      CustomLog logs/
      projX_access.log common
      </VirtualHost>
    • Edit C:\WINDOWS\system32\drivers\etc\hosts so your comp knows what the IP for the project is. For example:
      127.0.0.1 localhost
      127.0.0.1 proj1
      127.0.0.1 proj2
  8. Allow the command line to find mysql
    • I was stuck on this for a long ass time. I kept getting Fatal error: Call to undefined function mysql_connect() .. here’s how to solve that:
    • Copy C:\webdev\EasyPHP2.0b1\php5\php.ini-dist to C:\webdev\EasyPHP2.0b1\php5\php.ini
    • Uncomment this line:
      extension=php_mysql.dll
    • Copy the following files to ‘C:\WINDOWS\system32′ from your php5 dir (not sure if this made a difference, if you can’t bake a projet because you get a undefined function error then do this)
      php5apache2.dll
      php5ts.dll
      php_mysql.dll
      libmysql.dll
      libmysqli.dll
  9. Modify cygwin (optional)
    • I downloaded tcsh first
    • Add necessary alias’
  10. Bake your first project
    • Open up cygwin
    • cd to /webdev/projects/projX/trunk/app
    • Type ‘cake bake’ in the CLI (command line)
    • All your initial files will be created and copied over from the cake_1.2 dir we setup earlier
    • Edit your database user/pass in the ‘/webdev/projects/projX/trunk/app/config/database file
    • Now you can start to bake your controller, models, etc. Just type cake bake and go!
  11. Done!

Wait one sec!

27 Jan 2008 In: Code

Okay, I just put up this blog and didn’t realize that people would actually read it. Please give me a week or so to get acquainted with WP and do a little CSS remodeling. I would do it now, but I’m at my other job and have a project I’m working on that’s needs to be finished by end of week.

Incase you are wondering, this blog is going to be a place for me to talk about interesting design patterns, development issues that I found and worked out (or found and borrowed from others..), my love of travel, and frankly anything else I see fit (although it will focus on travel and code).

Jungles of Borneo and summiting Mt. Kinabalu

31 Mar 2007 In: Asia, Travel

19 March - 31 March, 2007

I haven’t had time to record notes from my journal yet, but I’m anxious to show everything what I did was at Borneo. Without further ado…

[http://www.youtube.com/watch?v=YnirPmuXKFg]

About Me

Code. Design. Explore. is the blog of John Brennan, a web developer/designer, entrepreneur, and avid world traveler. I currently live in Brooklyn, NY.

I am the Co-Founder of OpenAction and lead Product Development. We are a open platform social enterprise that helps organizations engage with donors, share knowledge with other non profits and empower the community to get involved to create positive impact on our planet.

This blog will mostly be around building cool things, although I will surely include my travel experiences when I am abroad. Feel free to subscribe to a specific category if that is only what interests you. And please connect with me. I always enjoy meeting new, interesting people!