Date: Fri, 29 Mar 2024 02:31:10 +0000 (UTC) Message-ID: <1353425597.436.1711679470994@library.aws.roguewave.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_435_1909133389.1711679470992" ------=_Part_435_1909133389.1711679470992 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This article tells how to set up the include_path to include Zend framew= ork 2 in your project.
Zend Server running on all supported OS versions.
Zend Framework 2 and other libraries are collections of PHP scripts. The= y 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 ava= ilable to every script in that directory, or can be set within a script usi= ng 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 o= ne 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 Ze= nd Server UI, and navigate to Configurations -> PHP -> Paths and Dire= ctories. Find the include_path directive, add a colon to the end, and then = add the path after that. For example, you could change this:
.:/usr/local/zendphp74/var/libraries/Zend_Framework_1/default/library:= /usr/local/zendphp74/share/pear:/usr/local/zendphp74/var/libraries/PHP_Tool= kit_for_IBMI_i/default/library:/usr/local/zendphp74/share/ToolkitApi
to this:
.:/usr/local/zendphp74/var/libraries/Zend_Framework_1/default/library:= /usr/local/zendphp74/share/pear:/usr/local/zendphp74/var/libraries/PHP_Tool= kit_for_IBMI_i/default/library:/usr/local/zendphp74/share/ToolkitApi:/usr/l= ocal/zendphp74/share/ZendFramework2/library
= 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 .us= er.ini in that directory. (Notice the file name starts with a period. You m= ight read that as dot-user-dot-ini.) In that file you can specify the inclu= de path:
include_path =3D '.:/usr/local/zendphp74/var/libraries/Zend_Framework_= 1/default/library:/usr/local/zendphp74/share/pear:/usr/local/zendphp74/var/= libraries/PHP_Toolkit_for_IBMI_i/default/library:/usr/local/zendphp74/share= /ToolkitApi:/usr/local/zendphp74/share/ZendFramework2/library'
If yo= u don't need all that other stuff in your include path, you might do it sim= pler:
include_path =3D '.:/usr/local/zendphp74/share/ZendFramework2/library'=
= Per script
The final method is to use ini_set() to set your include_path in your sc= ript. To append ZF 2 to your existing path:
ini_set('include_path',ini_get('include_path').':/usr/local/zendphp74/= share/ZendFramework2/library');
Or if you don't need all the other= s in your include_path:
ini_set('include_path', '/usr/local/zendphp74/share/ZendFramework2/lib= rary');
= 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 pa= th. Deployment can manage multiple versions of a library, with one ve= rsion being the default. The zend_deployment_library_path() function = allows you to specify which version of the library you would like to use.&n= bsp; 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_librar= y_path() function usage in the online documentation:
Here is a short script that demons= trates how this function might be used. The line highlighted with a r= ed font shows how to append the Zend Framework 2 path to the current path.<= /span>
<?php
// Demonstrate usage for zend_deployment_library_path with= Zend Framework 2
echo "<pre>"; // I like a monospaced font for st= uff like this
// Store the current path
$initial_path =3D ini_get= (include_path);
echo "The current path is:<br>$initial_path<br&= gt;<br>";
// Test for existence of the Framework 2 default pat= h
$zf2Path =3D zend_deployment_library_path('Zend Framework 2');
= if (!$zf2Path) {
echo "Zend Framework 2 default path = not found.<br><br>";
die; //nothing more = to do if ZF2 is not deployed
} else {
echo "The de= fault path for Zend Framework 2 is:<br>$zf2Path<br><br>";=
// Here is one method to appe= nd the ZF2 path to the initial path, using the functions
&nb= sp; ini_se= t(include_path, ini_get(include_path) . ':' . zend_deployment_library_path(= 'Zend Framework 2'));
echo "The new path with = the Zend Framework 2 default path appended is:<br>" . ini_get(include= _path) . "<br><br>";
&nbs= p; // We could also just use the variables we have already loaded. ini_set(include_path, $initial_path . ':' . $zf2Path);=
echo "The new path with the Zend Framework 2 default= path appended is still:<br>" . ini_get(include_path) . "<br>&l= t;br>";
}
// Demonstrate that spelling must be exact
$zf2Pa= th =3D zend_deployment_library_path('Zned Framewark 2');
if (!$zf2Pa= th) {
echo "Zned Framewark 2 path not found. Ch= eck your spelling.<br><br>";
}
// Get the path fo= r version 2.2.5
$zf2Path =3D zend_deployment_library_path('Zend Framewor= k 2', '2.2.5');
if (!$zf2Path) {
echo "Zend Fr= amework 2 Version 2.2.5 path not found.<br><br><br><br= >";
} else {
echo "The path for Zend Framework = 2 Version 2.2.5 is:<br>$zf2Path";
}
?>
Here is the output from this scrip= t, running on Zend Server with Zend Framework 2 version 2.3.0 deployed as t= he default and version 2.2.5 deployed as an earlier version.
The current path is:
.:/usr/local/zendphp74/share/ZendFramework/lib= rary:/usr/local/zendphp7/share/pear:/usr/local/zendphp7/share/ToolkitApi
The default path for Zend Framework 2 is:
/usr/local/zendphp74/var/= libraries/Zend_Framework_2/2.3.0/library
The new path with the Zend = Framework 2 default path appended is:
.:/usr/local/zendphp74/share/ZendF= ramework/library:/usr/local/zendphp74/share/pear:/usr/local/zendphp74/share= /ToolkitApi:/usr/local/zendphp74/var/libraries/Zend_Framework_2/2.3.0/libra= ry
The new path with the Zend Framework 2 default path appended is s= till:
.:/usr/local/zendphp7/share/ZendFramework/library:/usr/local/zendp= hp74/share/pear:/usr/local/zendphp74/share/ToolkitApi:/usr/local/zendphp74/= var/libraries/Zend_Framework_2/2.3.0/library
Zned Framewark 2 path n= ot found. Check your spelling.
The path for Zend Framework 2 Versio= n 2.2.5 is:
/usr/local/zendphp74/var/libraries/Zend_Framework_2/2.2.5/li= brary
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 o= ne 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 Ze= nd Server UI, and navigate to Configurations -> PHP -> Paths and Dire= ctories. Find the include_path directive, add a colon to the end, and then = add the path after that. For example, you could change this:
.:/usr/local/zendphp7/var/libraries/Zend_Framework_1/default/library:/= usr/local/zendphp7/share/pear:/usr/local/zendphp7/var/libraries/PHP_Toolkit= _for_IBMI_i/default/library:/usr/local/zendphp7/share/ToolkitApi
to this:
.:/usr/local/zendphp7/var/libraries/Zend_Framework_1/default/library:/= usr/local/zendphp7/share/pear:/usr/local/zendphp7/var/libraries/PHP_Toolkit= _for_IBMI_i/default/library:/usr/local/zendphp7/share/ToolkitApi:/usr/local= /zendphp7/share/ZendFramework2/library
= 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 .us= er.ini in that directory. (Notice the file name starts with a period. You m= ight read that as dot-user-dot-ini.) In that file you can specify the inclu= de path:
include_path =3D '.:/usr/local/zendphp7/var/libraries/Zend_Framework_1= /default/library:/usr/local/zendphp7/share/pear:/usr/local/zendphp7/var/lib= raries/PHP_Toolkit_for_IBMI_i/default/library:/usr/local/zendphp7/share/Too= lkitApi:/usr/local/zendphp7/share/ZendFramework2/library'
If yo= u don't need all that other stuff in your include path, you might do it sim= pler:
include_path =3D '.:/usr/local/zendphp7/share/ZendFramework2/library'<= /pre>
= Per script
The final method is to use ini_set() to set your include_path in your sc= ript. To append ZF 2 to your existing path:
ini_set('include_path',ini_get('include_path').':/usr/local/zendphp7/s= hare/ZendFramework2/library');
Or if you don't need all the other= s in your include_path:
ini_set('include_path', '/usr/local/zendphp7/share/ZendFramework2/libr= ary');
= 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 pa= th. Deployment can manage multiple versions of a library, with one ve= rsion being the default. The zend_deployment_library_path() function = allows you to specify which version of the library you would like to use.&n= bsp; 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_librar= y_path() function usage in the online documentation:
Here is a short script that demons= trates how this function might be used. The line highlighted with a r= ed font shows how to append the Zend Framework 2 path to the current path.<= /span>
<?php
// Demonstrate usage for zend_deployment_library_path with= Zend Framework 2
echo "<pre>"; // I like a monospaced font for st= uff like this
// Store the current path
$initial_path =3D ini_get= (include_path);
echo "The current path is:<br>$initial_path<br&= gt;<br>";
// Test for existence of the Framework 2 default pat= h
$zf2Path =3D zend_deployment_library_path('Zend Framework 2');
= if (!$zf2Path) {
echo "Zend Framework 2 default path = not found.<br><br>";
die; //nothing more = to do if ZF2 is not deployed
} else {
echo "The de= fault path for Zend Framework 2 is:<br>$zf2Path<br><br>";=
// Here is one method to appe= nd the ZF2 path to the initial path, using the functions
&nb= sp; ini_se= t(include_path, ini_get(include_path) . ':' . zend_deployment_library_path(= 'Zend Framework 2'));
echo "The new path with = the Zend Framework 2 default path appended is:<br>" . ini_get(include= _path) . "<br><br>";
&nbs= p; // We could also just use the variables we have already loaded. ini_set(include_path, $initial_path . ':' . $zf2Path);=
echo "The new path with the Zend Framework 2 default= path appended is still:<br>" . ini_get(include_path) . "<br>&l= t;br>";
}
// Demonstrate that spelling must be exact
$zf2Pa= th =3D zend_deployment_library_path('Zned Framewark 2');
if (!$zf2Pa= th) {
echo "Zned Framewark 2 path not found. Ch= eck your spelling.<br><br>";
}
// Get the path fo= r version 2.2.5
$zf2Path =3D zend_deployment_library_path('Zend Framewor= k 2', '2.2.5');
if (!$zf2Path) {
echo "Zend Fr= amework 2 Version 2.2.5 path not found.<br><br><br><br= >";
} else {
echo "The path for Zend Framework = 2 Version 2.2.5 is:<br>$zf2Path";
}
?>
Here is the output from this scrip= t, running on Zend Server with Zend Framework 2 version 2.3.0 deployed as t= he default and version 2.2.5 deployed as an earlier version.
The current path is:
.:/usr/local/zendphp7/share/ZendFramework/libr= ary:/usr/local/zendphp7/share/pear:/usr/local/zendphp7/share/ToolkitApi
=
The default path for Zend Framework 2 is:
/usr/local/zendphp7/var/li= braries/Zend_Framework_2/2.3.0/library
The new path with the Zend Fr= amework 2 default path appended is:
.:/usr/local/zendphp7/share/ZendFram= ework/library:/usr/local/zendphp7/share/pear:/usr/local/zendphp7/share/Tool= kitApi:/usr/local/zendphp7/var/libraries/Zend_Framework_2/2.3.0/library
=
The new path with the Zend Framework 2 default path appended is still:<= br>.:/usr/local/zendphp7/share/ZendFramework/library:/usr/local/zendphp7/sh= are/pear:/usr/local/zendphp7/share/ToolkitApi:/usr/local/zendphp7/var/libra= ries/Zend_Framework_2/2.3.0/library
Zned Framewark 2 path not found.= Check your spelling.
The path for Zend Framework 2 Version 2.2.5 i= s:
/usr/local/zendphp7/var/libraries/Zend_Framework_2/2.2.5/library
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 o= ne 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 Ze= nd Server UI, and navigate to Configurations -> PHP -> Paths and Dire= ctories. Find the include_path directive, add a colon to the end, and then = add the path after that. For example, you could change this:
.:/usr/local/zendsvr6/var/libraries/Zend_Framework_1/default/library:/= usr/local/zendsvr6/share/pear:/usr/local/zendsvr6/var/libraries/PHP_Toolkit= _for_IBMI_i/default/library:/usr/local/zendsvr6/share/ToolkitApi
to this:
.:/usr/local/zendsvr6/var/libraries/Zend_Framework_1/default/library:/= usr/local/zendsvr6/share/pear:/usr/local/zendsvr6/var/libraries/PHP_Toolkit= _for_IBMI_i/default/library:/usr/local/zendsvr6/share/ToolkitApi:/usr/local= /zendsvr6/share/ZendFramework2/library
= 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 .us= er.ini in that directory. (Notice the file name starts with a period. You m= ight read that as dot-user-dot-ini.) In that file you can specify the inclu= de path:
include_path =3D '.:/usr/local/zendsvr6/var/libraries/Zend_Framework_1= /default/library:/usr/local/zendsvr6/share/pear:/usr/local/zendsvr6/var/lib= raries/PHP_Toolkit_for_IBMI_i/default/library:/usr/local/zendsvr6/share/Too= lkitApi:/usr/local/zendsvr6/share/ZendFramework2/library'
If yo= u don't need all that other stuff in your include path, you might do it sim= pler:
include_path =3D '.:/usr/local/zendsvr6/share/ZendFramework2/library'<= /pre>
= Per script
The final method is to use ini_set() to set your include_path in your sc= ript. To append ZF 2 to your existing path:
ini_set('include_path',ini_get('include_path').':/usr/local/zendsvr6/s= hare/ZendFramework2/library');
Or if you don't need all the other= s in your include_path:
ini_set('include_path', '/usr/local/zendsvr6/share/ZendFramework2/libr= ary');
= 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 pa= th. Deployment can manage multiple versions of a library, with one ve= rsion being the default. The zend_deployment_library_path() function = allows you to specify which version of the library you would like to use.&n= bsp; 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_librar= y_path() function usage in the online documentation:
Here is a short script that demons= trates how this function might be used. The line highlighted with a r= ed font shows how to append the Zend Framework 2 path to the current path.<= /span>
<?php
// Demonstrate usage for zend_deployment_library_path with= Zend Framework 2
echo "<pre>"; // I like a monospaced font for st= uff like this
// Store the current path
$initial_path =3D ini_get= (include_path);
echo "The current path is:<br>$initial_path<br&= gt;<br>";
// Test for existence of the Framework 2 default pat= h
$zf2Path =3D zend_deployment_library_path('Zend Framework 2');
= if (!$zf2Path) {
echo "Zend Framework 2 default path = not found.<br><br>";
die; //nothing more = to do if ZF2 is not deployed
} else {
echo "The de= fault path for Zend Framework 2 is:<br>$zf2Path<br><br>";=
// Here is one method to appe= nd the ZF2 path to the initial path, using the functions
&nb= sp; ini_se= t(include_path, ini_get(include_path) . ':' . zend_deployment_library_path(= 'Zend Framework 2'));
echo "The new path with = the Zend Framework 2 default path appended is:<br>" . ini_get(include= _path) . "<br><br>";
&nbs= p; // We could also just use the variables we have already loaded. ini_set(include_path, $initial_path . ':' . $zf2Path);=
echo "The new path with the Zend Framework 2 default= path appended is still:<br>" . ini_get(include_path) . "<br>&l= t;br>";
}
// Demonstrate that spelling must be exact
$zf2Pa= th =3D zend_deployment_library_path('Zned Framewark 2');
if (!$zf2Pa= th) {
echo "Zned Framewark 2 path not found. Ch= eck your spelling.<br><br>";
}
// Get the path fo= r version 2.2.5
$zf2Path =3D zend_deployment_library_path('Zend Framewor= k 2', '2.2.5');
if (!$zf2Path) {
echo "Zend Fr= amework 2 Version 2.2.5 path not found.<br><br><br><br= >";
} else {
echo "The path for Zend Framework = 2 Version 2.2.5 is:<br>$zf2Path";
}
?>
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 ea= rlier version.
The current path is:
.:/usr/local/zendsvr6/share/ZendFramework/libr= ary:/usr/local/zendsvr6/share/pear:/usr/local/zendsvr6/share/ToolkitApi
=
The default path for Zend Framework 2 is:
/usr/local/zendsvr6/var/li= braries/Zend_Framework_2/2.3.0/library
The new path with the Zend Fr= amework 2 default path appended is:
.:/usr/local/zendsvr6/share/ZendFram= ework/library:/usr/local/zendsvr6/share/pear:/usr/local/zendsvr6/share/Tool= kitApi:/usr/local/zendsvr6/var/libraries/Zend_Framework_2/2.3.0/library
=
The new path with the Zend Framework 2 default path appended is still:<= br>.:/usr/local/zendsvr6/share/ZendFramework/library:/usr/local/zendsvr6/sh= are/pear:/usr/local/zendsvr6/share/ToolkitApi:/usr/local/zendsvr6/var/libra= ries/Zend_Framework_2/2.3.0/library
Zned Framewark 2 path not found.= Check your spelling.
The path for Zend Framework 2 Version 2.2.5 i= s:
/usr/local/zendsvr6/var/libraries/Zend_Framework_2/2.2.5/library