Class usage, manuals and howtos
Compatibility span (Supported PHP versions)
This library should be compatible with at least PHP 5.3 up to PHP 7.2. However, running this module in older versions of PHP makes it more unreliable as PHP is continuosly developed. There are no guarantees that the module is fully functional from obsolete releases (like PHP 5.3 and most of the PHP 5.x-series is).
Requirements and dependencies
Some kind of a supported driver is needed. NetCURL was built for curl so it could be a great idea to have curl available in your system. The goal with the module is however to pick up the best available driver in your system.
- soap (SoapClient with XML)
Future plans for independence:
Dependencies and installation
As netcurl is built to be independently running dependencies is not necessesary required. To reach full functionality the list below might be good to have available.
- Installation: Composer. NetCURL can be bundled/manually downloaded, but the best practice is to install via composer. Otherwise you're a bit on your own.
- SSL (OpenSSL): Not having SSL available means that you won't be able to speak https
- SOAP: To make use of the SOAP components in NetCurl, XML libraries and SoapClient needs to be there. SoapClient uses Streams to fetch wsdl.
XML, CURL, SOAP
In apt-based systems, extra libraries can be installed with commands such as:
apt-get install php-curl php-xml php-soap
The module installation itself
This is the recommended way (and only officially supported) of installing the package.
- By PHP serialized content (serialize/unserialize)
- XML (Starting with SimpleXMLElements, the PEAR/PECL modules such as XmlSerializer/XMLUnserializer are also supported)
- DOMDocument (Converts html documents into DOMDocument arrays, by three methods: nodes, closest tags and element ids)
NetCurl extra features
The name NetCurl was born from the fact that there are more than one module in this class file. A network module also resides in the single file, which is the primary reason why it is called NetCurl. NetCurl takes care of different network based features, like resolving hosts, making sure that ip-addresses is really ip-addresses, extracts proxy addresses from server variables, encodes base64-strings into URL-compatible strings, reads CIDR-formatted netmasks properly, etc, etc, etc. This part of the documentation has documentation of all those modules.
|curl||Curl must be installed|
NetCurl primarily supports curl, as the name reveals. However, if you run wordpress or Guzzle, there is a small driver switch in NetCurl that makes it possible to survive without curl. Below, the supported drivers are listed and what they may provide for you.
|curl and streams||WP must be present||On SOAP, SoapClient makes fallback to internal class|
|curl and streams|
Add to composer.json:
On SOAP, SoapClient makes fallback to internal class
Overriding the default drivers can be done by running for example.
The best available driver could also be autodetected via the method setDriverAuto().
NetCurl contains a bunch of classes in a single file that in the beginning was supposed to make the library independent. The namespace is TorneLIB.
|MODULE_NETWORK||Handler of any networking related actions||Link|
|MODULE_CURL||The magic class that does the work for you in all http-related actions||Link|
|Exceptions related to the library||Link|
|NETCURL_AUTH_TYPES||Available authentication types for use with password protected sites||Link|
|NETCURL_POST_METHODS||List of methods available in this library (Like GET, POST, PUT, DELETE)||Link|
|NETCURL_POST_DATATYPES||Prepared formatting for POST-content in this library (Also available from for example PUT)|
Examples: json, xml, etc
|NETCURL_RESOLVER||Resolver methods that is available when trying to connect (ipv4/ipv6 based selectors).|
This defines whether the resolver should prioritize ipv4 or ipv6 first.
|Available http driver handlers - Internal (default), WordPress, Guzzle, etc||Link|
|Used for testing (deprecated)||Link|
|NETCURL_RESPONSETYPE||Responsetypes (how they are returned - as arrays or objects)|
Normally not used
|If you need to get the responses out as objects, this is the predefined object||Link|
|Address Types class (ipv4/ipv6)|
This defined wheter the connector should prioritize ipv4 or ipv6 first
|Bitmasking handler (will probably be moved out of this library soon)||Link|
NetCurl responses (Unchained)
The list below shows the response content that are returned from a GET/POST/etc. You necessarily do not need to fetch the keys yourself; you can also use NetCurl internal methods to get each data key from the response. As of v6.0.18, NetCurl is chained by default. This means that chained (PHP 5.4+) commands can be used (like $LIB->doGet()->getParsed()). Chaining can be disabled with $LIB->setChain(false); - however, chaining is automatically disabled if PHP 5.3 or lower are detected. The table below shows how the raw data content looks "unchained".