Posts Tagged project

Mar 7 2009

Starting with Zend Framework – Configuration File and Database Connection

On the first article about the Zend Framework series, i have covered out the Setup of the Development Environment, on this article i will cover the Zend Framework configuration files and the database connection.

I will try to guide you on a brief and short path to start using the database in your Zend Framework project.

First Task – The configuration file

Our first task for today is to create the configurations file, i prefer to use php .ini files to save configuration settings, due to it’s clean and functional organization.

On your /public/config/ folder, create a file named configurations.ini with the following content.

database.adapter			=	pdo_mysql		=	localhost
database.params.username	=	root
database.params.password	=	xpto
database.params.dbname		=	restaurant
[development : production ]	=
database.params.username=	root
database.params.password=	ypto

I am defining my database settings to use PDO_Mysql driver and all the database needed settings, as you can see i am using two sections, the first one named [production] and the second one named [development:production] the : separation means that we are inheriting our development section from um previous production, and we will override some of the definitions. You can read more about this on the Zend Framework Config instructions.

Second Task: Load the configuration settings on your bootstrap file

Now that you have created the configuration file, you need to give some use tho it, lets go to the previously created bootstrap file, on your path /public/bootstrap.php, after the line that contains “Zend_Loader::registerAutoload();“, add the following content:

 * Loading configuration from ini file
$configuration = new Zend_Config_Ini(

We are reading the configuration file into a Zend_Config Object, to access the object you could by example do:

echo $config->database->params->host;


Third Task: Creating the database handler

Now that we have the configurations needed on a Zend_Config object we are ready to create the database connection. In order to do that, just after the previous code on bootstrap.php file, add the content.

 * Creating the database handler from the loaded ini file
$dbAdapter = Zend_Db::factory($configuration->database);
 * Lets define the newly created handler as our default database handler
We are creating the database handler and defining the newly created database handler as the default for my front controller.

 Fourth Task: Using the Zend Registry to save the values

Now that we have our application using the database handler, and we are connected to the database, i will save the $configurations values and the $dbAdapter on the Registry for further usage.

 * Lets add the configurations and the database handler to Registry
 * to use in future
$registry = Zend_Registry::getInstance();
$registry->configuration = $configuration;
$registry->dbAdapter     = $dbAdapter;
 * Now that we have the values on the Registry, lets cleanuo the variables
 * from the script scope
unset($dbAdapter, $registry,$configuration);

You can read more about Zend Registry on the framework manual.

On this article, i have approached the Zend Config, Zend_Db and Zend_Registry usage, i are now able to deal with each one of this components, on my next article on this series, i will help you to create a Model extending the Zend_Db_Table.

Jul 11 2008

Once a freelancer always a freelancer

Most of freelancers, have gone from a full time job, to a freelancer way of living.

What makes a freelancer ?

The blood that runs under his vain, you born a freelancer, you don’t choose to be a freelancer, it’s on your spirit. You even could foolish yourself, and convincing yourself that a full time job is the right for you, but you know that you’ll never be happy doing a full time job, because you are a freelancer!


What could make a freelancer get a full time job ?

Responsibilities – When you get responsibilities, and start to get worried about family and fixed bills, there is a tendency to start getting questions. With a full time job seems easier to have commodity, on the financial field. But this means that you don’t have control of you life, and way of living.

Empty clients pipeline – When the clients/project pipeline gets empty, means that you got no income, that is one of the biggest freelancer worries about, but you know what, you should always aim for maintenance clients that get’s you a steady income.

Surely there are more reasons to get a full-time job, for me , this two are the dark shadow of any freelancer, and the devil’s temptation!

Laura Spencer, gives her point of view at, and i completely agree with her.

The principal point, that every freelance should think, is that none of
the areas will be easy, a full time job isn’t more safe than a
freelance spirit, it’s a mater of organization and approach to the
freelance way of living.

My personal experience

I have been a freelancer for some years, than i became drunk with a project and a moved to a full time position, after that full time position another great project was offered to me, and i got drunk again, with another full time position, and the story goes on an on. But everything on life is temporal, just keep the blood running and you’ll get back again.

This is the danger i am talking about, if you want/need to be a frelance, don’t get drunk with projects.

Jan 1 1970

Habari Linkedin Plugin 0.5 Released

I am happy to announce a new version of the Habari LinkedIn Plugin.

After some time without updates, i just re-vamped the plug-in, making it compatible with Habari 0.5 versions, and added a new functionality, “Share on Linkedin” button.

I created a Google Code Project for the plugin, so that we can have Issue Tracker, Wiki and SVN access, all detailed information about the plug-in will be placed on the page.

Habari LinkedIn Plug In

What’s new on this version ?

The plugin status management was added into the plugin configuration area, you can set the LinkedIn badge as Visible/Invisible from the administration, without need to remove the template code.

Added new functionality, integrated the “Share on LinkedIn” widget. More info about the widget, on LinkedIn Developers Page.

The plugin will allow the visitors of you blog to share your content with his LinkedIn Connections and groups.


You can see and example of the “Share” functionality, bellow this post you will find a link with label “Share on LinkedIn”.