3 Common Problems When Getting Started with the Zend Framework and Xampp

3 Common Problems When Getting Started with the Zend Framework and Xampp
http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/digg_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/reddit_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/dzone_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/stumbleupon_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/delicious_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/blogmarks_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/newsvine_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/google_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/myspace_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/facebook_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/yahoobuzz_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/sphinn_16.png http://www.nurelm.com/themanual/wp-content/plugins/sociofluid/images/twitter_16.png

Many of you likely know that Xampp is one of the easiest ways to get the standard “Apache + PHP + MySQL” installation up and running quickly on Windows. Using the Xampp package can save you lots of time and potential headache — that is, until you want to use Zend Framework.  The framework documentation and code are always changing so it’s possible, perhaps likely, that these issues may not be around for long; however, they are present if you were to download the latest version of Xampp (1.7.2) and the Zend Framework (1.9.2).

I’ve just began digging into Zend myself recently and these are the problems I have come across and expect others to run into as well, at least in the near future while these problems exist in the most recent versions of Xampp and the Zend Framework.

1. When creating your framework project: ‘”php.exe”‘ is not recognized as an internal or external command, operable program or batch file.

This is a well-documented problem that can occur in a large number of PHP applications. The fix can generally be discovered with a quick Google search but it’s such a common issue when starting a Zend Framework project that we will cover it here also. So, you start with the QuickStart tutorial on Zend Framework website and shortly into the lesson, you’re asked to type “zf.bat create project quickstart” which is immediately followed by the above error message. This error is basically just saying that the zf.bat file needs to use the PHP interpreter to run the script that will set up your framework project directory but is unable to find it.

To fix this issue, you can edit your system’s Environment Variables (Go to System Properties and it’s a button on the Advanced tab). You want to find the “PATH” variable in the bottom (System variables) pane and edit it to add the location of your php.exe file. For example, my path is “C:\xampp\php” but make sure you place a semicolon between the previous path and the one you just added. You can then save your changes by closing the system variable windows but you will need to re-open the console you were using to create your framework project in order for it to read your newly added PHP path.

2. When creating your controller in a new project: A project profile was not found.

This can actually be a number of things and I suspect it’s the reason most of you are reading this. First off, make sure you are following the QuickStart guide exactly as it says — your working directory (where you run the command from) should be that of your Zend Framework project and not the bin folder that contains the zf.bat file. You also should have added the path to the Zend Framework library folder to your php.ini’s include_path attribute.

If you have done all of this and still receive the same problem, check your framework version. There was a problem in the Zend Framework v1.9.0 that broke the creation of some file paths in Windows — this bug was resolved in v1.9.1. So, first thing’s first… make sure you’re using the latest version of the framework (v1.9.2 at the time of this writing) or more importantly, make sure you are not using v1.9.0.

Now that we’re clear on the version numbers, take a look after you try running the “create controller” command. You should receive the “project profile not found” error followed by a line that tells you the “Zend Framework Command Line Console Tool” version. If you have downloaded v1.9.1+ and it is reporting that you have v1.9.0 in the console, continue reading. There’s a significant problem that occurs here when using Zend v1.9.1+ and Xampp 1.7.2 (and likely others). The Xampp installer actually includes a version of the framework files located in \xampp\php\PEAR\. The reason this matters is because the default settings for your include_path variable from the Xampp install was:

include_path = “.;C:\xampp\php\PEAR”

Most people will simply add the library path to the end of this:

include_path = “.;C:\xampp\php\PEAR;C:\xampp\htdocs\zend\library”

The problem here is that this makes the system check the PEAR directory before our framework library folder. Now, guess what version Xampp comes with. That’s right, the broken v1.9.0! Simply switch around the order of these so that it reads:

include_path = “.;C:\xampp\htdocs\zend\library;C:\xampp\php\PEAR”

3. You have an existing v1.9.0 project but receive the same error after using the guide above: A project profile was not found.

Whether you just followed the guide for the second problem or you just updated an older version of the framework, you may run into this issue. First off, make sure your console is outputting the correct framework version number below this error (as described above). If so, the likely issue is a recent change in the name of the project profile file. In v1.9.0 (and perhaps earlier) it was named zfproject.xml — as of v1.9.2, this file is now called .zfproject.xml (notice the leading period). No other files have changed between these versions that concern controller creation so you can simply rename the project profile file  to include the leading period and it should work just fine.

About the Author

Author Profile: