sidebar
This article tells how to set up the include_path to include Zend framework 2 in your project.
Zend Server running on all supported OS versions.
Zend Framework 2 and other libraries are collections of PHP scripts. They can be included in your application using the PHP directive include_path. This can be set globally in the php.ini file to make the library available to every script running on your site, can be set for a directory to be available to every script in that directory, or can be set within a script using the ini_set() directive.
Globally
The first method is to set it globally. You will want to set it globally if every script on your site needs access to Framework 2. Otherwise, use one of the other methods to include Framework 2, so that scripts that do not need it will not search for it. To set it globally, you can go into the Zend Server UI, and navigate to Configurations -> PHP -> Paths and Directories. Find the include_path directive, add a colon to the end, and then add the path after that. For example, you could change this:
to this:
Per directory
The second method is to set up a directory so that every script in that directory can use the Framework 2 library. You can create a file called .user.ini in that directory. (Notice the file name starts with a period. You might read that as dot-user-dot-ini.) In that file you can specify the include path:
If you don't need all that other stuff in your include path, you might do it simpler:
Per script
The final method is to use ini_set() to set your include_path in your script. To append ZF 2 to your existing path:
Or if you don't need all the others in your include_path:
Per script with zend_deployment_library_path()
If Zend Deployment is managing your Zend Framework 2 library, there is a function zend_deployment_library_path() that can be used to specify the path. Deployment can manage multiple versions of a library, with one version being the default. The zend_deployment_library_path() function allows you to specify which version of the library you would like to use. You can specify a particular version for testing a new version of the library, or perhaps if you have an application that is only compatible with a prior version. There is a discussion of the zend_deployment_library_path() function usage in the online documentation:
Here is a short script that demonstrates how this function might be used. The line highlighted with a red font shows how to append the Zend Framework 2 path to the current path.
Here is the output from this script, running on Zend Server with Zend Framework 2 version 2.3.0 deployed as the default and version 2.2.5 deployed as an earlier version.
Globally
The first method is to set it globally. You will want to set it globally if every script on your site needs access to Framework 2. Otherwise, use one of the other methods to include Framework 2, so that scripts that do not need it will not search for it. To set it globally, you can go into the Zend Server UI, and navigate to Configurations -> PHP -> Paths and Directories. Find the include_path directive, add a colon to the end, and then add the path after that. For example, you could change this:
to this:
Per directory
The second method is to set up a directory so that every script in that directory can use the Framework 2 library. You can create a file called .user.ini in that directory. (Notice the file name starts with a period. You might read that as dot-user-dot-ini.) In that file you can specify the include path:
If you don't need all that other stuff in your include path, you might do it simpler:
Per script
The final method is to use ini_set() to set your include_path in your script. To append ZF 2 to your existing path:
Or if you don't need all the others in your include_path:
Per script with zend_deployment_library_path()
If Zend Deployment is managing your Zend Framework 2 library, there is a function zend_deployment_library_path() that can be used to specify the path. Deployment can manage multiple versions of a library, with one version being the default. The zend_deployment_library_path() function allows you to specify which version of the library you would like to use. You can specify a particular version for testing a new version of the library, or perhaps if you have an application that is only compatible with a prior version. There is a discussion of the zend_deployment_library_path() function usage in the online documentation:
Here is a short script that demonstrates how this function might be used. The line highlighted with a red font shows how to append the Zend Framework 2 path to the current path.
Here is the output from this script, running on Zend Server with Zend Framework 2 version 2.3.0 deployed as the default and version 2.2.5 deployed as an earlier version.