I'm trying to understand the options and terminology relating to "installing" PHP libraries on a system (Linux/OSX)
Here are some specific points I'm trying to cover:
Thanks- and sorry for the multi-part...
A couple points...
PHP has no native "import" infrastructure, like python, java, or .net. There are several ways that libraries can be used in PHP.
compile them into the PHP binary. This is the most advanced way, and not usually desirable unless you have very special needs.
Install them as PHP modules on the server, and include them in PHP.ini. From the point of view of the PHP programmer, these extensions are part of PHP -- always available. It's just easier to add and remove them without having to rebuild PHP itself.
Install PHP code on the server somewhere, and include() it into your PHP script.
Save a copy of a library into your project, and include it into your PHP script.
--
At a basic level, code is either part of the interpreter (static or dynamic), or it is plain old PHP code that is include()ed into your project.
For your purposes, I can only suggest that you stick with an industry standard PHP distribution (pick a good linux OS, and use it's PHP). Then almost all the libraries you will need at the interpreter level are available as add-on packages, and the complexity of that is left up to those who do it every day.
On RedHat/Centos, you might run:
yum install php php-memcached php-gd php-pecl
--
Regarding all the other kinds of libraries that you might want to use, it's most likely best to adopt a good PHP framework which takes care of all that for you.
Some examples are:
(not in any order, just ones that came to mind)
Provided that you have taken the standard approach of using RPM's or similar to manage the compiled in aspects of PHP and extensions, then a good solid framework will take care of the inclusion of all your additional PHP library code you need.
What the end result is, is that you focus on delivering a product, and not on all the infrastructure that you would otherwise have to learn and invent.
--
php.ini is parsed and run when PHP starts (each time for command line, once per server start in apache). It defines a lot of settings, includes a lot of modules, configures those modules, etc...
You can actually override some settings in php.ini with the ini_set() function in PHP. However, this is only effective for some settings. Others need to be set before your script starts.
When running under apache, you can add lines to .htaccess
and <VirtualHost>
directives which totally override PHP.ini for that directory/virtual host.
(please correct my syntax and remove this note if it is wrong)
<VirtualHost *>
ServerName www.example.com
DocumentRoot /home/joe/site/docroot
php_value include_path "/home/joe/site/php-code"
</VirtualHost>
--
In response to your #6 question about your own library and the best way to package it, I suggest you first evaluate the need of the library. And if you really are on to something, then find out the most common way people are doing it. If it is a simple library, then a .php file with a nice website would be sufficient.
--
Maybe a bit rambling, but I hope this points you in the right direction.