Basic sendmail configuration on XAMPP Windows using an Office 365 account

sendmail.ini

smtp_server=smtp.office365.com
smtp_port=587
auth_username=your-username@your-domain.com
auth_password=your-password
force_sender=your-username@your-domain.com

php.ini

SMTP=smtp.office365.com
smtp_port=587
sendmail_from = your-username@your-domain.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

Source: How to configure XAMPP to send mail from localhost?

Zend Framework quickstart – Part 1

Here are the links that I followed while getting started with the Zend Framework:

So far, Zend Framework looks pretty much like CodeIgniter in a way that I can use loosely-coupled component libraries at will and I have a lot of control over the architecture. It also provides an MVC implementation similar to CodeIgniter.

When I was reading the links above, I noticed that some of the details were missing in order to successfully complete a small project using Zend Framework without pulling my hair a couple of times. So I wrote my own so I can just look this post up if ever I forget some of the important details and perhaps some other ZF n00b out there can benefit from this post as well. Here it is…

Get a copy of the Zend Framework

I downloaded the latest version of Zend Framework from the Latest Release of ZF page instead of installing Zend Server (which contains Zend Framework with a complete PHP stack) on my development machine since I don’t have a production server where I can install the Zend Server, because Zend Server will replace your Linux distro’s PHP that may cause conflict between RPM packages. I’d rather setup my development environment similar to the setup of the servers that I have right now so don’t have to worry much about package incompatibilities during deployment.

In the Latest Release of ZF page, choose the full framework which doesn’t require registration. In my case, I downloaded Zend Framework 1.10.8 Full (released 2010-08-25). Extract the contents of the archive. In my (Fedora) Linux machine, I extracted it under /home/randell/ZendFramework-1.10.8. In Windows, I extracted it under C:/ZendFramework-1.10.8.

Setup the zf command line tool

We’ll be using the zf command line tool to create our new project. For that, we need to properly setup our environment variables for both PHP and the zf tool. The zf command line tools (zf.bat for Windows and zf.sh for Unix-based OSes) are located in the /bin directory of your Zend Framework installation.

Create the project

After setting-up the command line tool, we can now create our project. From the command line, navigate to the directory where we will create your project. In my Linux machine, I created it under /var/www/html/. In Windows, I created it under C:/xampp-1.7.1/htdocs. Both directories is where I run all my other PHP projects. To create the project, execute the following command:

zf create project quickstart

Running this command will create your basic site structure, including your initial controllers and views. Both in Windows and in Linux, you could get a message similar to this after executing the command:

Note: This command created a web project, for more information setting up your VHOST, please see docs/README

The tree structure of the generated project looks something like this:

quickstart
|-- application
|    |-- configs
|    |    `-- application.ini
|    |-- controllers
|    |    |-- ErrorController.php
|    |    `-- IndexController.php
|    |-- models
|    |-- views
|    |    |-- helpers
|    |    |-- scripts
|    |         |-- error
|    |         |    `-- error.phtml
|    |         |-- index
|    |              `-- index.phtml
|    `-- Bootstrap.php
|-- docs
|    `-- README.txt
|-- library
|-- public
|    |-- .htaccess
|    `-- index.php
|-- tests
|    |-- application
|    |    `-- bootstrap.php
|    |-- library
|    |    `-- bootstrap.php
|    `-- phpunit.xml
`-- .zfproject.xml

Don’t worry about the contents of those files yet because I will try to explain the important ones as detailed as possible in my next post. For now, let’s just get the basic setup up and running.

Next step is to copy the Zend library (library/Zend)from our extracted Zend Framework archive to the library directory of our project. We’re doing this so that our project has a copy of the Zend Framework whenever we decide to deploy it on a different server.

Create a virtual host

Let’s modify our httpd.conf and hosts files using any text editor.

Append the following lines at the end of httpd.conf file (/etc/httpd/conf/httpd.conf and /etc/hosts in Fedora):

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName quickstart.local
    DocumentRoot /var/www/html/quickstart/public

    SetEnv APPLICATION_ENV "development"

    <Directory /var/www/html/quickstart/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
<VirtualHost>

DocumentRoot specifies the public subdirectory of our project (only files under that directory can ever be served directly by the server). Take note of the public. Most people tend to forget that part, especially when coming from other frameworks where the index.php doesn’t reside on a directory other than the root. The SetEnv directive sets an environment variable for our virtual host and will be picked up by index.php (in the public directory) and set the APPLICATION_ENV constant for our application.

Append the following to the hosts file (/etc/hosts in Fedora and C:/WINDOWS/system32/drivers/etc/hosts in Windows XP):

127.0.0.1 quickstart.local

Then restart our server. We can now access our application from http://quickstart.local and see something like this from our browser:

Welcome to the Zend Framework

Welcome to the Zend Framework

Got questions or suggestions about this post? Feel free to post a comment or drop me an email.