Are there Libraries which are in every present PHP installation?
An Example:
I'm using cURL in a PHP Script, does it run on every PHP installation?
Libraries like cURL aren't in a default PHP installation. Though most hosts do carry a default set of extensions which have been widely used, which usually include cURL.
PHP has a page on which it's built-in functions which will most likely explain this further: http://nl3.php.net/manual/en/functions.internal.php
There's also a page with function references to find the most used libraries that can be installed using PEAR: http://nl3.php.net/manual/en/funcref.php
Related
Is there a way I can find out what modules are being used by my php application without going through thousands of lines of code?
I can get the whole list of PHP modules on current server via php -m, but I want to know if there is any way to find out modules required by my app in particular.
There is a PEAR package called PHP_CompatInfo that does something like that:
Find out the minimum version and the extensions required for a piece of code to run
It's marked as no longer maintained, so there might be some problems using it with recent versions of PHP
You should look into using get_loaded_extensions() or extension_loaded().
I searched over the Internet several documentation about how to create PHP extensions, but unfortunately, there is nothing about linking to another extensions (and making a requirement for having that extension loaded prior to the new it is being created).
I guess I could simply #include necessary header files into my source code, but not sure about linking.
As an example, and to play with extension creation, the first I want to create is a solution I implemented to allow namespaces in memcached github but wanted to know how to use other extensions' code from my custom extension one for other usages as well.
I'm not sure how to reply to the thread with StormByte, but it sounds like you need to do some load balancing or caching, not extending PHP.
If you really want to do this at the code level, you could use exec() to call a Python script, which gets compiled into byte code automatically.
I'm trying to create a very small php binary for a specific use. I don't need many of the functions and classes included in commong php. How can I do this?
Thanks.
Checkout php source form svn or download source dist on php.net and build it using manual. It is better to do it on nix systems or compile PHP with cygwin on Win. You can easy configure php extensions when building it and exclude some of it using configure script. If you need more specific configurations you should know how Autotools works couse php uses it.
I am building php from source on a new CentOS box and as usual I have to wrangle up all the various configuration options I might need. This gets tricky because there are various extensions that I want and certain options that I always for get to put in the .configure script. Not only that but PHP 5.3 has has different defaults for various options.
Is there an interactive or annotated version of the configure script somewhere or a good set of defaults to reference?
Thanks!
Grab the existing PHP SRPM, update the spec with the new version, release, and tarball, and rebuild.
I want to use CURL library but I don't want to install it in a hard way
I just want to do something like this
require_once('curl.php');
I am not sure if this possible or not? and where can I found this CURL class?
thanks
PHP requires that its built with the cURL library, see:
http://www.php.net/manual/en/curl.installation.php
So you would install libcurl-devel for your system and then compile PHP with
--with-curl
And maybe
--with-curl=/path/to
If you installed it in a non-standard location.
You're copy of PHP is either going to have to have been built with Curl, or dynamically load it in (because Curl is not originally written in PHP, it's a C library).
Create a simple script that calls phpinfo(). If curl was built in, it should show up on this page.
phpinfo();
There is a Pure PHP Curl implementation called libCurlEmu
Just bear in mind: you should only use this kind of stuff as a last resort if you can't get the extensions to work.
There is also a standalone version called "MyCurl", that you can include without installation:
http://www.phpclasses.org/package/3588-PHP-Pure-PHP-implementation-of-the-cURL-library.html
i used it in my project and it worked fine with http-requests.
This class provides an alternative implementation of the cURL extension functions in pure PHP.
It automatically detects whether the cURL library is available. If it is not available, it defines several functions with the same names of the cURL extension that use the class to emulate part the original functionality.
Currently it implements the functions: curl_init, curl_exec, curl_setopt and curl_close. Several of the most important options can be set with the curl_setopt function.
although it has some small bugs, it works aftre fixing this:
the example doesent work out of the box, cause the domain lazywebmastertools.com is not reacheable
there is an # needed if the requested domain doesent end with "/":
return "/".#$tmp[1];
if you dont use a proxy, you have to set
if (isset($this->proxy) and $this->proxy["host"])...
if (isset( $this->headers["location"]) and $this->headers["location"] > "") {...
the drawback is, that this class doesent support https. there you would need the Snoopy Class:
https://stackoverflow.com/a/1154247/1069083