Tag Archives: zend framework 2

Zend Framework 2 – Create New Project From Scratch

I’ve noticed many users are still incapable of getting Zend Framework 2 going on there local machine. I’m going to run a very thorough explanation of how I got it working.

Information and tools used throughout this tutorial:
Zend Framework 2 online tutorial
Windows 7 (64 bit)
EasyPHP DevServer 13.1 (everything that comes with it)

Let’s begin.

Step 1: Download and install EasyPHP DevServer 13.1

(If you installed PHP and MySQL some other way then just follow the instructions and make sure all your settings are identical to get Zend Framework 2 working)

Step 2: Make sure your PHP variable is working correctly. To do so, open Terminal by clicking Start, type “cmd“, click on “cmd.exe“. Once the terminal is open, type “php -v” and press Enter. If setup correctly, you will see PHP version and some other information, if not you will get an error along the lines of “php is not a recognizable command …“.

If PHP variable is working correctly then skip directly to Step 3, otherwise read on.

(EasyPHP should setup this correctly on install, if you used something else to install PHP then perform the following procedures:
– Find and the copy your full path to php.exe, (ex. C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\binaries\php\php_runningversion)
– Open Environment variables settings (Right-click “Computer” icon, click Properties, then click “Advanced System Settings” on the left side panel, then click “Environment Variables” button at the very bottom.)
– In the bottom list, find PATH in the first column and click Edit button.
– Place the pointer to the beginning of the line and paste the previously copied full path to PHP.exe.
– Add a semi-colon “;” after the path)

Step 3: Download Zend Framework 2 skeleton application from here.

Step 4: Inside your working directory (where you keep all your PHP projects, ex. “www”) create a folder “zf2-tutorial” and unzip the contents of Zend Framework 2 downloaded file in there.

In my case (because I’m using EasyPHP), the local working directory is “C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\projects“, so I placed my “zf2-tutorial” folder inside the “projects” folder.

End path where “zf2-tutorial” is placed is: C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\projects\zf2-tutorial

Step 5: Now onto the fun stuff with Zend Framework 2. Open the Terminal again, type the following command to switch inside “zf2-tutorial” folder:

In your case, you place the path to your “zf2-tutorial” folder.

Step 6: Type the following command and press Enter:

Let the process complete.

Step 7: Type the following command and press Enter:

Let this process complete before you proceed. It may take a while. (I got an error here because EasyPHP comes with OpenSSL is disabled and I couldn’t proceed. If you did too, just open php.ini file and un-comment openssl extension.

Step 8: Now let’s add virtual hosts to httpd.conf file. Open httpd.conf file and find (commented out) example of Virtual Hosts setup. Now paste the following below the example but don’t comment it out like the examples:

The only 2 things you have to change is the path to your zf2-tutorial project. First is on the DocumentRoot line and second is inside the first Directory tag. If you are using EasyPHP then just replicate the path to the example I provided.

Step 9: Modify your hosts file. (You won’t be able to save your hosts’ file changes unless you open it in Notepad (or other editor) as Administrator).

Before:

After:

I kind of wish I had a step 10 but I don’t. Your Zend Framework 2 setup should be working flawlessly right now. Let me know if you have any questions and I’ll do my best to try and assist you in your setup.

Cheers.

Zend Framework 2 – How to Create A New Project

Update: Try the new tutorial here.

There has been lots of confusion with new Zend Framework 2 lately. The manual on Zend Framework‘s website is horrible (in terms of beginner manual and documentation) and is designed for advanced user’s with Zend Framework 1 extensive experience.

Many user’s are still unable to create a first basic folder structure to begin using Zend Framework 2 library. The initial example is provided here. I’m going to break it down for you  guys.

(Note: This instruction guide assumes you have successfully installed Zend Framework 2 and its library. Also, this instruction guide uses EasyPHP 5.4.6)

Step 1: Download the Zend Framework Skeleton Application from here. Secondly, extract the files into your root (www) localhost folder and rename the folder to anything you want. I will call it “zend_project1”.
This file provides you with all the necessary files to create your basic folder structure.

Step 2: Open your Terminal. (In Windows 7, click Start and in the search box type “cmd” (no quotes),  and click cmd.exe.

Step 3: Once opened, use the “cd” command to navigate to the folder where you extracted   your zip file you downloaded in step 1. My command looks like this “cd C:\Program Files (x86)\easy_php\www\zend_project1”. You should be inside the folder now and your line in Terminal should resemble this “C:\Program Files (x86)\easy_php\www\zend_project1”

Step 4: Now type this command, “php composer.phar self-update” and press Enter.

Step 5: Type another command, “php composer.phar install”. This will create your directories for basic skeleton application.

That’s all. Now, open your browser and navigate to your localhost and zend_project1/public folder (mine looks like this: http://127.0.0.1:8080/zend_project1/public/). You should see this website. If you do, then every step has been successfully completed.