Today I joined the #bash IRC channel on freenode and asked if anyone knew the whereabouts of my .bashrc file on OS X. I noticed that if I set up a .bash_profile file then my old .profile file wouldn't be excecuted anymore. Thankfully 'lhunath' gave me this useful tip: "I'd recommend you just have a .profile in POSIX sh syntax and this at the end: "
[ "$BASH_VERSION" -a -z "$POSIXLY_CORRECT" ] && . "$HOME/.bashrc"
$action =
$this->getContext()->getActionStack()
->getLastEntry()->getActionInstance();
$action->redirect(''); // etc
I have created this simple three step approach for a Symfony project to switch application contexts while respecting the desire to have a global project-wide config file, vhost and default mod_rewrite configuration.
1. /config.php:
define('URI_ROOT', '/project/web/');
define('MY_ENV', 'dev');
define('MY_DEBUG', true);
$apps = array(
'default' => 'frontend',
'admin' => 'backend'
);
Read More...
I had a gut-feeling using slots to quickly switch between different versions of PHP in Gentoo would be straightforward and it was. The only piece of the puzzle that eluded me for a while, in the end, was working out how to tell portage to install a specific version. This is acheieved with an equals sign. As such: (Assuming in this instance 5.2 is already installed.)
# emerge \=dev-lang/php-5.3.3-r3
Then to switch versions:
# eselect php set apache2 X
# /etc/init.d/apache2 restart
Note: To display available versions when 'eselecting' use:
# eselect php list apache2
I've learnt that detaching a PHP script from the shell and allowing it run as a daemon on Ubuntu is not as simple as I first thought. I couldn't simply add an ampersand like this:
$ php ./script &
I had to use parenthesis because I assume otherwise bash now gets confused. This is what works:
$ ((php ./script) &)&
It's been a long time since I figured this out and I can't remember what resource I used to help me. Anyway to get PHP Mode working with the native emacs bundled with Mac OS X do the following:
$ mkdir elisp; cd elisp
$ wget http://bit.ly/cLqD47
Then edit/create the file '~/.emacs and put in the following:
(add-to-list 'load-path "~/elisp")
(load "php-mode")
(add-to-list 'auto-mode-alist
'("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))
Et voila, you will now have lovely syntax highlighting and auto indenting when editing your PHP files. (NB: The bit.ly link points to the php-mode.el script hosted on Sourceforge.)
I've been using Yii framework a fair bit recently and it seems very nice so far. However I couldn't easily find out how to get hold of these often essential pieces of information from a Yii view. Useful in situations where you want to build a navigation user interface element etc. This is all you need to know...
// Module
if(isset($this->module)): echo $this->module->getName(); endif;
// Controller
echo $this->ID;
// Action
echo $this->action->id;
| 01/01/2010, 19:35
MVC
Welcome to the first live site to use the latest version of my own MVC (for use with Smarty) that is now successfully running on top of PHP 5.3. Recent work on it has been a fun ride, driven mostly out of a desire to have controller classes whose names do not clash with those of auto-generated classes from PHP Doctrine. i.e. they would potentially still clash if it wasn't for namespaces :0]
Admittedly this wouldn't be such a large issue if the MVC supprorted internal URL re-routing but it doesn't. This is due to a semi-conscious awareness that controllers should be thin, refactoring them never a big deal and because mod_rewrite is your friend. Anyway I'm hoping to finally get a release candidate for version 1 of the code up on GitHub over the next few weeks. Pretty nervous about any response I might get.
As a developer, one of the great things I love about Gentoo (Linux distribution with BSD 'ports-like' package management) is the feeling it gives you that eveything you do to your system has an undo button. (For the record, I have at least come to my senses about this need in a production situation.) A great example of this is layman, which I think is fair to say is a slightly more intuitive version of managing an apt sources file. Today I realised there is a portage overlay (for use with layman) that I have been missing out on and perhaps it's because it's a fairly recent addition but it comes just in time for me to try and get more serious about hacking in Perl.
With the perl-experimental overlay I anticipated the knock-on effect might be that I am no longer tempted to write a script for keeping my /etc/portage/package.keywords file sorted alphabetically automatically. I was half-right (thanks to a useful awk command from the Gentoo wiki) but in the end this need paled in significance compared to the delights of coming across a more up-to-date utility for handling cpan builds and then ending up with a system for reliably predicting where generated ebuilds from this utility will land in the filesystem. Not that it matters that much, I suppose.
Read More...
I'm going to be ordering 'XMPP: The Definitive Guide' today (ISBN 059652126X). I have a project coming up which, fingers crossed, will be an ideal opportunity to become versed in this technology. I remember a few years ago, when I came across the Jabber project, I was really excited about it and started using the Exodus IM client all time. I even got my girlfriend (at the time) to register an account. I also remember going to stpeter's website and taking pointers for creating a decent personal websites (which wasn't a blog). I remember thinking this was eventually going to be *huge* and I'm kind of kicking myself now that it never occured to me, that like a lot exciting open source technology, people will eventually be adopting it without even know they're doing it, or at least not realising the significance of its openness. Exciting times. Anyway enough with the jibber-jabber, apparently I have a 'decent read' to get through and this one isn't a Hermann Hesse novel.
Step 1 - Install Symfony into your PHP library path:
# cd /usr/share/php
# wget http://www.symfony-project.org/get/symfony-stable.tgz
# gunzip symfony-stable.tgz ; tar -xvf symfony-stable.tar
# ln -s symfony-X/lib symfony
# mkdir data
# ln -s ../symfony-X/data data/symfony
# rm syfony-stable.tar
Step 2 - Within your Symfony app, edit the main 'settings.yml' file, create a symlink to 'sf' and ensure the cache directory is writable:
$ cd /var/www/localhost/htdocs/sf_app
$ echo "all:" >> config/settings.yml
$ echo " .settings" >> config/settings.yml
$ echo " relative_url_root: /sf_app/web" >> config/settings.yml
$ ln -s /usr/share/php/data/symfony/web/sf .
$ chmod -R 777 cache
And you're done.