24
Mar
2008
Author: John Brennan
In: Startup
27
Jan
2008
Author: John Brennan
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…
- 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
- 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
- Get cygwin if you don’t already have it
- 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;
- 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
- 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
- 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
- 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
- Modify cygwin (optional)
- I downloaded tcsh first
- Add necessary alias’
- 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!
- Done!
27
Jan
2008
Author: John Brennan
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).