We do need more blogging. Tweets are fine for their intended purpose, but there is only so much idea one can squeeze into so little space.
I like blogs because of what I learn from them; they encourage me to stay current, they expose me to new thoughts and they help me stay connected with the community.
I like blogs precisely because they aren't real-time. They are the result of observation and reflection. I get to read someone's more fully-developed thoughts, communicated in full sentences, with examples, and even paragraphs! Blogging forces one to crystallize one's thoughts, and teaches us how to communicate more effectively. True written communication is not dead. Blogs make me think; I not only like that, I need it.
I like being able to go back to a blog post I've bookmarked as a reference, finding again something I needed once, and need again from time to time. In addition, I get to see how the concept develops over time, as commentors contribute their thoughts and opinions on the subject.
Blogs also inspire me to contribute some of what I may have learned along the way. This is where I've fallen down, terribly, often believing that I really didn't have much to say that would be of use to others.
I see otherwise now. I've been teaching novice programmers PHP and Zend Framework with Zend Technologies since autumn 2008. I get asked a lot of questions about programming, code design, object-oriented development, and testing. Most of my colleagues are advanced developers, and they often blog about advanced techniques, and although those techniques help make a developer's life easier, some of the people I encounter daily aren't quite ready to take advantage of particularly advanced development practices.
I pledge to blog more often, and help flatten out the learning curve for the newbies. We were all newbies, once, and if we're committed to lifelong learning, and to keeping our skills current, we remain newbies, in at least one area, all the time.
See you briefly on Twitter with a #ideasofmarch tweet.
Thursday, March 31, 2011
Zend Framework Autoloading - Finding Your Library Classes
Attention Zend Framework beginners. Since today is the final day for me to get around to contributing - in some small way - to The Ideas of March, which encourages people to blog more often, I offer up the following.
If you find yourself using require_once statements in your Zend Framework applications in order for ZF to find your library classes, in spite of using Zend_Application - which you know establishes autoloading by default - then there is one simple thing you need to add to your application's config file, typically configs/application.ini, to fix the problem. End your frustration, and read on.
Assuming a directory structure something like this (my "vendor prefix" of EAI stands for Everetts Associates, Inc.):
application/
data/
docs/
library/
EAI/
Mail.php
public/
scripts/
temp/
tests/
and a class named EAI_Mail in the Mail.php file, and assuming your library is on your include_path, all that is needed is a line like this in application.ini:
autoloaderNamespaces[] = "EAI_"
Zend Framework's autoloader is already configured to match class prefixes Zend_ and ZendX_. What you're doing by adding the above line to the application's config file is register your library prefix/namespace with the autoloader. The include_path was not your problem, the problem was that ZF wasn't acknowledging your class prefix.
Now you can strip out those require_once statements for a bit of a performance boost.
Happy coding.
If you find yourself using require_once statements in your Zend Framework applications in order for ZF to find your library classes, in spite of using Zend_Application - which you know establishes autoloading by default - then there is one simple thing you need to add to your application's config file, typically configs/application.ini, to fix the problem. End your frustration, and read on.
Assuming a directory structure something like this (my "vendor prefix" of EAI stands for Everetts Associates, Inc.):
application/
data/
docs/
library/
EAI/
Mail.php
public/
scripts/
temp/
tests/
and a class named EAI_Mail in the Mail.php file, and assuming your library is on your include_path, all that is needed is a line like this in application.ini:
autoloaderNamespaces[] = "EAI_"
Zend Framework's autoloader is already configured to match class prefixes Zend_ and ZendX_. What you're doing by adding the above line to the application's config file is register your library prefix/namespace with the autoloader. The include_path was not your problem, the problem was that ZF wasn't acknowledging your class prefix.
Now you can strip out those require_once statements for a bit of a performance boost.
Happy coding.
Wednesday, December 15, 2010
An old idea slowly becoming reality
Sunglasses that blot out just the sun:
"... each lens is an LCD that creates a dark box over the sun, blotting out the biggest source of glare and allowing the rest of the glasses to remain rather less tinted. ..."
I had a similar idea nearly 20 years ago for a car windshield/windows that would do the same thing, and prevent overly-bright oncoming headlights from blinding you. My imaginary version had a dial on the dashboard, so you could adjust the tint level, and it even had a lock-out feature so that law enforcement could disable it when approaching a stopped vehicle.
I knew this kind of device would eventually exist in some form, but never became involved in any way as a part of making it happen.
Ideas are worthless. Execution is everything.
"... each lens is an LCD that creates a dark box over the sun, blotting out the biggest source of glare and allowing the rest of the glasses to remain rather less tinted. ..."
I had a similar idea nearly 20 years ago for a car windshield/windows that would do the same thing, and prevent overly-bright oncoming headlights from blinding you. My imaginary version had a dial on the dashboard, so you could adjust the tint level, and it even had a lock-out feature so that law enforcement could disable it when approaching a stopped vehicle.
I knew this kind of device would eventually exist in some form, but never became involved in any way as a part of making it happen.
Ideas are worthless. Execution is everything.
Tuesday, December 14, 2010
Zend Framework Local Deployment Script
Here is a deployment script I wrote to install Zend Framework on my local development computer. I use Gnu/Linux, so converting this for use on Windows is, at least for the time being, left as an exercise to the reader. Use it, improve it, throw it away, ignore it. Whatever you do with it, enjoy!
#! /bin/sh
# deploy latest ZF to LOCAL development machine
# run using sudo (make executable with chmod u+x deploy-zf-latest-to-local.sh)
# TARFILE_LOCATION is where the ZF tarball you downloaded resides
# TARGET_LOCATION is where ZF is to be deployed (and is my PHP include_path)
# PHP_BIN_DIR is where zf command line tool is to be deployed
# A symlink in ~/bin like this is useful: zf -> /usr/local/bin/zf.sh
# See http://framework.zend.com/manual/en/zend.tool.framework.clitool.html
ZF_BASENAME=ZendFramework-1.11.1
TARFILE_LOCATION=/home/clark/deploy/archives
TARGET_LOCATION=/usr/share/php
PHP_BIN_DIR=/usr/local/bin
if test `whoami` != root
then
echo Please run using \"sudo\".
exit
fi
# extract ZF from tarball
cd ${TARFILE_LOCATION}
tar -xzf ${ZF_BASENAME}.tar.gz
# remove prior version of ZF from the system; put the current version in place
cd ${TARGET_LOCATION}
rm -rf Zend
cp -r ${TARFILE_LOCATION}/${ZF_BASENAME}/library/Zend .
cp ${TARFILE_LOCATION}/${ZF_BASENAME}/bin/zf.sh ${TARFILE_LOCATION}/${ZF_BASENAME}/bin/zf.php ${PHP_BIN_DIR}/
# autoloading is always used, so remove require_once statements for performance
find ${TARGET_LOCATION}/Zend -name '*.php' -not -name 'Application.php' -not -wholename '*/Loader/Autoloader.php' -print0 | xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
# set up autoloading for zf.php command line tool
sed --regexp-extended --in-place "s/^(if \(!getenv\('ZF_NO_MAIN)/require_once 'Zend\/Loader\/Autoloader\.php'\; Zend_Loader_Autoloader::getInstance\(\)\;\n\1/g" ${PHP_BIN_DIR}/zf.php
# set file permissions, clean up extraction area, indicate what version we're running
chown -R root:root ${TARGET_LOCATION}/Zend/
rm -rf ${TARFILE_LOCATION}/${ZF_BASENAME}
# next line should reference PHP_BIN_DIR instead of hardcoding the directory
php -r 'include "/usr/share/php/Zend/Version.php"; echo "Running Version " . Zend_Version::VERSION . "\n";'
#! /bin/sh
# deploy latest ZF to LOCAL development machine
# run using sudo (make executable with chmod u+x deploy-zf-latest-to-local.sh)
# TARFILE_LOCATION is where the ZF tarball you downloaded resides
# TARGET_LOCATION is where ZF is to be deployed (and is my PHP include_path)
# PHP_BIN_DIR is where zf command line tool is to be deployed
# A symlink in ~/bin like this is useful: zf -> /usr/local/bin/zf.sh
# See http://framework.zend.com/manual/en/zend.tool.framework.clitool.html
ZF_BASENAME=ZendFramework-1.11.1
TARFILE_LOCATION=/home/clark/deploy/archives
TARGET_LOCATION=/usr/share/php
PHP_BIN_DIR=/usr/local/bin
if test `whoami` != root
then
echo Please run using \"sudo\".
exit
fi
# extract ZF from tarball
cd ${TARFILE_LOCATION}
tar -xzf ${ZF_BASENAME}.tar.gz
# remove prior version of ZF from the system; put the current version in place
cd ${TARGET_LOCATION}
rm -rf Zend
cp -r ${TARFILE_LOCATION}/${ZF_BASENAME}/library/Zend .
cp ${TARFILE_LOCATION}/${ZF_BASENAME}/bin/zf.sh ${TARFILE_LOCATION}/${ZF_BASENAME}/bin/zf.php ${PHP_BIN_DIR}/
# autoloading is always used, so remove require_once statements for performance
find ${TARGET_LOCATION}/Zend -name '*.php' -not -name 'Application.php' -not -wholename '*/Loader/Autoloader.php' -print0 | xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
# set up autoloading for zf.php command line tool
sed --regexp-extended --in-place "s/^(if \(!getenv\('ZF_NO_MAIN)/require_once 'Zend\/Loader\/Autoloader\.php'\; Zend_Loader_Autoloader::getInstance\(\)\;\n\1/g" ${PHP_BIN_DIR}/zf.php
# set file permissions, clean up extraction area, indicate what version we're running
chown -R root:root ${TARGET_LOCATION}/Zend/
rm -rf ${TARFILE_LOCATION}/${ZF_BASENAME}
# next line should reference PHP_BIN_DIR instead of hardcoding the directory
php -r 'include "/usr/share/php/Zend/Version.php"; echo "Running Version " . Zend_Version::VERSION . "\n";'
Sunday, December 12, 2010
IndieConf, and an OOTNO
Almost a month ago, an eternity on the Intertubes, I attended IndieConf, the conference for independent web professionals, held in Raleigh, NC, organized by my friend Michael Kimsal, web developer, publisher, and "web radio dude" based in NC. He pulled together a cast of experienced individuals, credible speakers from a broad range of disciplines, to speak on a variety of topics of vital importance to the independent/freelance software developer.
He provided a great experience to everyone, speakers and attendees alike, from the speakers' dinner on Friday evening, to the conference sessions, to the afterparty Saturday evening. Wanting to give everyone a great experience, providing value through practical sessions - that's what makes him an OOTNO, One Of The Nice Ones*.
Whether you're already an independent web provider, or thinking about embracing the freelance "workstyle", don't be a NOOTNO (Not One Of The Nice Ones), and skip IndieConf next year. Check it out. Make some connections. Learn some stuff. Have some fun.
Guess its about time I filled out the conference survey form, and give him some happy feedback data...
*From an article in a 70's science fiction magazine, the name of which escapes me, else I'd give full credit to the author.
He provided a great experience to everyone, speakers and attendees alike, from the speakers' dinner on Friday evening, to the conference sessions, to the afterparty Saturday evening. Wanting to give everyone a great experience, providing value through practical sessions - that's what makes him an OOTNO, One Of The Nice Ones*.
Whether you're already an independent web provider, or thinking about embracing the freelance "workstyle", don't be a NOOTNO (Not One Of The Nice Ones), and skip IndieConf next year. Check it out. Make some connections. Learn some stuff. Have some fun.
Guess its about time I filled out the conference survey form, and give him some happy feedback data...
*From an article in a 70's science fiction magazine, the name of which escapes me, else I'd give full credit to the author.
Saturday, December 11, 2010
Sometimes I Just Wanna READ
Instead of talking about PHP or software development, I'm going to rant about the prevalence of video for just a bit. Video is great, except when I don't want video. I was reading about the Google CR-48 Chrome OS Notebook, and followed a link to a description of Chrome features.
This is the Overview page, which briefly discusses Chrome's cloud-based, always-connected, instant web nature. Great. I click on the Speed link to read about that.
Oh. A video. Pressed for time, I'd rather quickly read a description than sit through a video, so I click on the Sync link to see what that's about.
Hmm. Another video. Connectivity? Video. Security? Video. Updates, Apps, Guided Tour? Argh - all videos. No text.
I kind of expect to see video - or at least screenshots - on a page titled "Guided Tour," but what's wrong with good, old-fashioned text and images for the others, with a link to a video if I want to see one? Surely the vids were scripted, so why can't I simply read some content drawn from those scripts?
I don't mind videos, really, especially when they communicate information more easily demonstrated than described.
The use of video over text content on the web seems to be increasing. I guess videos are supposed to give us an "experience" intended to hold our interest longer than mere dull, dry words. And we certainly are bombarded with text. I see every day in my email inbox the misunderstandings resulting from people's skimming, rather than reading, that flood of written communication.
Is a viewer's comprehension and retention greater than a reader's? I don't know.
I appreciate the efforts people and organizations go through to produce high-quality videos. I'd just like the option to choose whether to read or watch.
Hmm. Blew my first blog post on a rant. Oh, well: nowhere to go but up?
This is the Overview page, which briefly discusses Chrome's cloud-based, always-connected, instant web nature. Great. I click on the Speed link to read about that.
Oh. A video. Pressed for time, I'd rather quickly read a description than sit through a video, so I click on the Sync link to see what that's about.
Hmm. Another video. Connectivity? Video. Security? Video. Updates, Apps, Guided Tour? Argh - all videos. No text.
I kind of expect to see video - or at least screenshots - on a page titled "Guided Tour," but what's wrong with good, old-fashioned text and images for the others, with a link to a video if I want to see one? Surely the vids were scripted, so why can't I simply read some content drawn from those scripts?
I don't mind videos, really, especially when they communicate information more easily demonstrated than described.
The use of video over text content on the web seems to be increasing. I guess videos are supposed to give us an "experience" intended to hold our interest longer than mere dull, dry words. And we certainly are bombarded with text. I see every day in my email inbox the misunderstandings resulting from people's skimming, rather than reading, that flood of written communication.
Is a viewer's comprehension and retention greater than a reader's? I don't know.
I appreciate the efforts people and organizations go through to produce high-quality videos. I'd just like the option to choose whether to read or watch.
Hmm. Blew my first blog post on a rant. Oh, well: nowhere to go but up?
Subscribe to:
Posts (Atom)