= Overview =
24 July 2006
How to install Symfony on OSX into a directory structure of your own choosing, with external instances of prerequisites (creole, phing, propel, pake) without using PEAR (well, mostly, anyway ...), AND get the CLI working.
I'm not trying here to explain the function of any part of symfony, or its dependencies. Rather just to document/share the steps to 'make it work'.
= The Environment =
My operating environment is OSX + "everything else" built from source:
OSX 10.4.7
{{{
System => Darwin devbox 8.7.0 Darwin Kernel Version 8.7.0: Fri May 26 15:20:53 PDT 2006; root:xnu-792.6.76.obj~1/RELEASE_PPC Power Macintosh
Build Date => Jul 10 2006 06:31:18
}}}
Apache 2.2.x svn/trunk
{{{
Server version: Apache/2.2.4-dev
Server built: Aug 6 2006 23:15:30
Server's Module Magic Number: 20051115:3
Server loaded: APR 1.2.8-dev, APR-Util 1.2.8-dev
Compiled using: APR 1.2.8-dev, APR-Util 1.2.8-dev
Architecture: 32-bit
Server MPM: Worker
threaded: yes (fixed thread count)
forked: yes (variable process count)
}}}
PHP 5.2 cvs/trunk w/ eAccelerator v0.9.6-dev & Xdebug v2.0.0rc1-dev
{{{
PHP Version => 5.2.0RC3-dev
PHP API => 20041225
PHP Extension => 20060613
Zend Extension => 220060519
Debug Build => no
Thread Safety => enabled
Zend Memory Manager => enabled
...
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
with Xdebug v2.0.0rc1-dev, Copyright (c) 2002, 2003, 2004, 2005, 2006, by Derick Rethans
with eAccelerator v0.9.6-dev, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
...
}}}
PEAR is installed
{{{
...
PEAR executables directory bin_dir /usr/local/php5/bin
PHP extension directory ext_dir /usr/local/php_libs/extensions
PEAR directory php_dir /usr/local/pear/php
PEAR data directory data_dir /usr/local/pear/data
PHP CLI/CGI binary php_bin /usr/local/php5/bin/php
...
}}}
php.ini
{{{
...
magic_quotes_gpc = Off
register_globals = Off
include_path="./:../:/usr/local/php_libs:/usr/local/pear/php:/System/Library/PHP"
zend_extension_ts="/usr/local/php_libs/extensions/no-debug-zts-20060613/eaccelerator.so"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.filter=""
eaccelerator.compress="1"
eaccelerator.compress_level="5"
...
}}}
my executables are @:
{{{
% which apachectl
/usr/local/apache2/sbin/apachectl
% which php
/usr/local/php5/bin/php
% which svn
/usr/local/subversion13x/bin/svn
}}}
and are all in my $PATH.
my dev ENV includes (in my "~/.cshrc"; i typically use TCSH as my shell ...):
{{{
## PHING
setenv PHP_COMMAND "/usr/local/php5/bin/php"
setenv PHING_HOME "/webapps/tools/phing"
setenv PATH "${PATH}:${PHING_HOME}/bin"
setenv PHP_CLASSPATH "${PHING_HOME}/classes:${PHP_CLASSPATH}"
## CREOLE
setenv CREOLE_HOME "/webapps/tools/creole"
setenv PHP_CLASSPATH "${CREOLE_HOME}/classes/creole:${CREOLE_HOME}/classes/jargon:${PHP_CLASSPATH}"
## PROPEL
setenv PROPEL_HOME "/webapps/tools/propel"
setenv PHP_CLASSPATH "${PROPEL_HOME}/runtime/classes:${PHP_CLASSPATH}"
## SYMFONY
setenv SYMFONY_HOME "/webapps/tools/symfony"
setenv PHP_CLASSPATH "${SYMFONY_HOME}/lib:${SYMFONY_HOME}:${PHP_CLASSPATH}"
}}}
= Directories =
for the sake of this discussion:
libraries, frameworks, etc for use in my webapps go in:
{{{
/webapps/tools
}}}
webapp code for my sites goes in:
{{{
/webapps/sites/
}}}
= Cleaning House =
just in case, remove any pre-existing cruft:
{{{
% cd /webapps/tools
% pear uninstall symfony/pake
% pear uninstall symfony
% rm -rf /webapps/tools/propel
% rm -rf /webapps/tools/creole
% rm -rf /webapps/tools/phing
% rm -rf /webapps/tools/symfony
}}}
= Download the "Pieces" =
{{{
% cd /webapps/tools
% svn up /webapps/tools/propel
% svn up /webapps/tools/creole
% svn up /webapps/tools/phing
% svn up /webapps/tools/symfony
% chown -R www:www propel
% chown -R www:www creole
% chown -R www:www phing
% chown -R www:www symfony
}}}
where, "www:www" is my Apache user:group spec'n.
as of this writing, the Revisions co'd are:
{{{
propel -> r431
creole -> r28
phing -> r111
symfony -> r1847
}}}
# NOTE: pake is now bundled with thhe symfony src tree ... so no more need to use pear to get it!
= Create & Configure symfony CLI scripts =
these are configured the way we need them, and are located to be insulated from any symfony src tree changes/upgrades/etc.
{{{
% mkdir -p /webapps/tools/scripts/
}}}
/webapps/tools/scripts/symfony:
{{{
#!/bin/bash
myPHP="/usr/local/php5/bin/php"
symPHP="/webapps/tools/symfony/data/bin/symfony.php"
$myPHP -d html_errors=off -qC $symPHP $*
}}}
Re-set perms:
{{{
% cd /webapps/tools
% chmod 775 scripts symfony
% chown -R www:www /webapps/tools/scripts
}}}
A convenient link:
{{{
% rm /usr/local/bin/symfony
% sudo ln -sf /webapps/tools/scripts/symfony /usr/local/bin/symfony
}}}
= CHECK your install =
{{{
% symfony -T
}}}
you should see @ console:
{{{
available pake tasks:
clear-cache > clear cached information
clear-controllers > clear controllers
disable > disables an application in a given environment
...
task aliases:
app = pake init-app
batch = pake init-batch
cc = pake clear-cache
controller = pake init-controller
module = pake init-module
new = pake init-project
}}}
= Create/Initialize a Symfony PROJECT: "myproject" =
{{{
% setenv SYM_PROJ "/webapps/sites/myproject"
% mkdir -p ${SYM_PROJ}
% cd ${SYM_PROJ}
% sudo -u www symfony init-project myproject
}}}
Check to make sure you see:
{{{
% ls -ald lib/symfony data/symfony
lrwxrwx--- 1 www www 52 2006-07-21 07:11 data/symfony -> /webapps/tools/symfony/data/
lrwxrwx--- 1 www www 51 2006-07-21 07:11 lib/symfony -> /webapps/tools/symfony/lib/
% ls -1
SYMFONY
apps/
batch/
build/
cache/
config/
data/
doc/
lib/
log/
test/
web/
}}}
= Create/Initialize an APP: "myapp" =
{{{
sudo -u www symfony init-app myapp
}}}
= Setup & Configure Webserver =
There are different ways to do this. I've chosen to set up a VHOST:
httpd.conf:
{{{
...
AllowOverride All
Deny from all
Allow from localhost 127.0.0.1 10.0.0.6/255.255.255.248
...
ServerName mydomain.com
DocumentRoot /webapps/sites/myproject/web
DirectoryIndex index.php
Alias /sf /webapps/tools/symfony/data/web/sf
AllowOverride All
Order Deny,Allow
Deny from all
Allow from localhost 127.0.0.1 10.0.0.6/255.255.255.248
Order Deny,Allow
Deny from all
Allow from localhost 127.0.0.1 10.0.0.6/255.255.255.248
LogLevel debug
ErrorLog /var/log/apache2/error.log
RewriteLogLevel 9
RewriteLog /var/log/apache2/modrewrite.log
...
}}}
= Setup/Adjust front controller's settings =
/webapps/sites//myproject/web/index.php:
{{{
getController()->dispatch();
...
}}}
= Test your PROJECT Install =
Restart apache
{{{
% apachectl restart
}}}
In your browser, nav to:
http://mydomain.com
you should see:
{{{
Congratulations!
If you see this page, it means that the creation of your symfony
project on this system was successful.
You can now create your model and customize default templates.
© 2004-2005 symfony project
}}}
= Initialize a MODULE: "mymodule" =
{{{
% cd ${SYM_PROJ}
% sudo -u www symfony init-module myproject mymodule
% chown -R www:www /webapps/sites/myproject
}}}
In your browser, nav to:
http://mydomain.com/index.php/mymodule
you should see:
{{{
Module mymodule
Congratulations!
}}}
= And ... We're off & running! =