How to connect library

How to connect library

Quite often programmers are interested in a question – how to increase the number of ready libraries of the standard PHP distribution kit, having added to a collection the alternative external libraries which are required for development of different projects.


1. To connect an alternative library, it is necessary to know that each library is a set of PHP scripts, so, them it is possible, as well as other scripts to connect include and require operators, having copied in the folder with the necessary project, at the same time maintaining structure of directories of PHP library of a constant.

2. If you prefer that files of library extended together with the project, this way will be convenient for you.

3. Also you can use the same copy of library in several different projects. For this purpose state path of placement of library in the php.ini file, using the include_path parameter – for example if you placed library, having unpacked it from archive, in any folder on disk C: - path of placement will have the following appearance: include_path= "" …; C:library_php; …"

4. Before and after the library stated above specify paths of placement of other libraries. Semicolons before parameters should be removed the original code as with them the code line turns into the comment. Besides, you can use library by means of the require_once parameter.

5. Connect alternative libraries you can be helped by PEAR package consisting of the PHP libraries interconnected with each other. To use PEAR packages for work, install the manager of packages – the program for management of these packages of libraries.

6. By means of the program you can load additional packages from the Internet and install them the pear_install parameter <name of a package>. The command of installation will be the same if you install a package from the computer, but not from network. Files of libraries will be in the PEAR folder which will arise in the PHP folder after installation.

Author: «MirrorInfo» Dream Team