Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
80% | Total: 652 | All time: 4,924 This week: 45 |
Version | License | PHP version | Categories | |||
php-curl-component 0.14.10 | GNU Lesser Genera... | 5.3 | HTTP, PHP 5 |
Description | Author | |
This package can compose and execute HTTP requests with Curl. |
Link Checker
Find broken links in a Web site
#!/usr/bin/env php |
This project aims to deliver an easy to use and free as in freedom object oriented php curl command component.
The build status of the current master branch is tracked by Travis CI:
Take a look on openhub.net.
The current change log can be found here.
This component is not developed to replace guzzle.
//it is always good to ship the component with a factory to easy up usage
use Net\Bazzline\Component\Curl\BuilderFactory;
use Net\Bazzline\Component\Curl\Option\Timeout;
$factory = new BuilderFactory();
$builder = $factory->create();
$url = 'http://www.foo.bar';
$timeout = new Timeout(10); //set the timeout to 10 seconds
/
* you can also use:
* //assuming that $dispatcher is an instance of DispatcherInterface
* //assuming that $requestFactory is an instance of RequestFactory
* $builder->overwriteDispatcher($dispatcher);
* $builder->overwriteRequestFactory($requestFactory);
*/
$response = $builder->usePost()
->onTheUrl($url)
->withTheData($data)
->withTheParameters(array('descendingOrderBy' => 'id'))
->withTheOption($timeout)
->andFetchTheResponse();
/
* you can also use:
* $builder->withTheHeaderLine($headLine) //add the headline you want
* $builder->withResponseModifier($modifier) //add the response modifier you want
*/
echo 'content: ' . $response->content() . PHP_EOL;
echo 'content type: ' . $response->contentType() . PHP_EOL;
echo 'error:' . $response->error() . PHP_EOL;
echo 'error code:' . $response->errorCode() . PHP_EOL;
echo 'head lines: ' . var_export($response->headerLines(), true) . PHP_EOL;
echo 'status code: ' . $response->statusCode() . PHP_EOL;
//it is always good to ship the component with a factory to easy up usage
$factory = new Net\Bazzline\Component\Curl\RequestFactory();
$request = $factory->create();
$url = 'http://www.foo.bar';
$response = $request->get($url);
echo 'content: ' . $response->content() . PHP_EOL;
echo 'content type: ' . $response->contentType() . PHP_EOL;
echo 'error:' . $response->error() . PHP_EOL;
echo 'error code:' . $response->errorCode() . PHP_EOL;
echo 'head lines: ' . var_export($response->headerLines(), true) . PHP_EOL;
echo 'status code: ' . $response->statusCode() . PHP_EOL;
//begin of runtime environments
$factory = new BuilderFactory();
$builder = $factory->create();
$data = array(
'there' => 'is',
'no' => 'foo',
'without' => 'a bar'
);
$password = '<super secret password>';
$username = 'foo@bar.ru';
$url = 'https://foo.bar.ru/api/my/rest/endpoint/v1';
//end of runtime environments
//begin building the request
$builder->asJson();
$builder->onTheUrl($url);
$builder->withTheData($data);
$builder->withTheOption(new SetBasicAuthentication());
$builder->withTheOption(new SetUsernameAndPassword($username, $password));
$builder->usePost();
//end building the request
$request = $builder->andFetchTheResponse();
echo PHP_EOL . 'dumping the request' . PHP_EOL;
var_dump($request);
In general, the php version is limiting the available curl options. Furthermore, some options are not implemented because of their hardcoded usage in the Response or the Dispatcher (you can set it but they would be overwritten).
This options are:
If you want to change this, you either have to extend the existing Request or Dispatcher object.
mkdir -p vendor/net_bazzline/php_component_curl
cd vendor/net_bazzline/php_component_curl
git clone https://github.com/bazzline/php_component_curl .
composer require net_bazzline/php_component_curl:dev-master
Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-].
Files (143) |
File | Role | Description | ||
---|---|---|---|---|
example (5 files) | ||||
source (1 file, 7 directories) | ||||
test (2 files, 4 directories) | ||||
.gitignore | Data | Auxiliary data | ||
.scrutinizer.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License | ||
phpunit.xml.dist | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (143) | / | example |
File | Role | Description |
---|---|---|
make_a_delete_request | Example | Example |
make_a_get_request | Example | Example script |
make_a_patch_request | Example | Example script |
make_a_post_request | Example | Example script |
make_a_put_request | Example | Example script |
Files (143) | / | source |
File | Role | Description | ||
---|---|---|---|---|
Builder (2 files) | ||||
Dispatcher (3 files) | ||||
HeaderLine (9 files) | ||||
Option (11 files, 8 directories) | ||||
Request (2 files) | ||||
Response (1 file) | ||||
ResponseBehaviour (3 files) | ||||
FactoryInterface.php | Class | Class source |
Files (143) | / | source | / | Builder |
File | Role | Description |
---|---|---|
Builder.php | Class | Class source |
BuilderFactory.php | Class | Class source |
Files (143) | / | source | / | Dispatcher |
File | Role | Description |
---|---|---|
Dispatcher.php | Class | Class source |
DispatcherInterface.php | Class | Class source |
LoggingDispatcher.php | Class | Class source |
Files (143) | / | source | / | HeaderLine |
File | Role | Description |
---|---|---|
AbstractContentType.php | Class | Class source |
AbstractHeaderLine.php | Class | Class source |
AcceptEncoding.php | Class | Class source |
AcceptLanguage.php | Class | Class source |
ContentTypeIsUtf8Form.php | Class | Class source |
ContentTypeIsUtf8Html.php | Class | Class source |
ContentTypeIsUtf8Json.php | Class | Class source |
Custom.php | Class | Class source |
HeaderLineInterface.php | Class | Class source |
Files (143) | / | source | / | Option |
File | Role | Description | ||
---|---|---|---|---|
Authentication (4 files) | ||||
Authorization (1 file) | ||||
Behaviour (25 files) | ||||
Callback (4 files) | ||||
Cookie (4 files) | ||||
Ftp (10 files) | ||||
Security (15 files) | ||||
Transfer (28 files) | ||||
AbstractAuthentication.php | Class | Class source | ||
AbstractSetOptionArrayValue.php | Class | Class source | ||
AbstractSetOptionClosureValue.php | Class | Class source | ||
AbstractSetOptionIntValue.php | Class | Class source | ||
AbstractSetOptionMixedValue.php | Class | Class source | ||
AbstractSetOptionStreamValue.php | Class | Class source | ||
AbstractSetOptionStringValue.php | Class | Class source | ||
AbstractSetOptionToFalse.php | Class | Class source | ||
AbstractSetOptionToTrue.php | Class | Class source | ||
OptionInterface.php | Class | Class source | ||
SetOption.php | Class | Class source |
Files (143) | / | source | / | Option | / | Authentication |
File | Role | Description |
---|---|---|
EnableUnrestrictedAuth.php | Class | Class source |
SetBasicAuthentication.php | Class | Class source |
SetKeyPassword.php | Class | Class source |
SetUsernameAndPassword.php | Class | Class source |
Files (143) | / | source | / | Option | / | Authorization |
File | Role | Description |
---|---|---|
EnableNetrc.php | Class | Class source |
Files (143) | / | source | / | Option | / | Behaviour |
File | Role | Description |
---|---|---|
DisableBody.php | Class | Class source |
DisableProgress.php | Class | Class source |
DisableSignal.php | Class | Class source |
EnableAutoReferer.php | Class | Class source |
EnableFailOnError.php | Class | Class source |
EnableFollowAllocation.php | Class | Class source |
EnableForbidReuse.php | Class | Class source |
EnableFreshConnect.php | Class | Class source |
EnableMute.php | Class | Class source |
EnableVerbose.php | Class | Class source |
SetConnectTimeOutInMilliSeconds.php | Class | Class source |
SetConnectTimeOutInSeconds.php | Class | Class source |
SetDnsCacheTimeout.php | Class | Class source |
SetHttp200Aliases.php | Class | Class source |
SetLowSpeedLimit.php | Class | Class source |
SetMaxConnects.php | Class | Class source |
SetMaxRedirs.php | Class | Class source |
SetRange.php | Class | Class source |
SetRedirProtocols.php | Class | Class source |
SetResumeFrom.php | Example | Example script |
SetStderr.php | Class | Class source |
SetTcpNoDelay.php | Class | Class source |
SetTimeCondition.php | Class | Class source |
SetTimeOutInMilliSeconds.php | Class | Class source |
SetTimeOutInSeconds.php | Class | Class source |
Files (143) | / | source | / | Option | / | Callback |
File | Role | Description |
---|---|---|
SetCallbackForPassWordFunction.php | Class | Class source |
SetCallbackForProgressFunction.php | Class | Class source |
SetCallbackForReadFunction.php | Class | Class source |
SetCallbackForWriteFunction.php | Class | Class source |
Files (143) | / | source | / | Option | / | Cookie |
File | Role | Description |
---|---|---|
EnableCookieSession.php | Class | Class source |
SetCookie.php | Class | Class source |
SetCookieFile.php | Class | Class source |
SetCookieJar.php | Class | Class source |
Files (143) | / | source | / | Option | / | Ftp |
File | Role | Description |
---|---|---|
EnableFtpAppend.php | Class | Class source |
EnableFtpAscii.php | Class | Class source |
EnableFtpCreateMissingDirs.php | Class | Class source |
EnableFtpListOnly.php | Class | Class source |
EnableFtpUseEprt.php | Class | Class source |
EnableFtpUseEpsv.php | Class | Class source |
SetFtpPort.php | Class | Class source |
SetFtpSslAuth.php | Class | Class source |
SetPostQuote.php | Class | Class source |
SetQuote.php | Class | Class source |
Files (143) | / | source | / | Option | / | Security |
File | Role | Description |
---|---|---|
DisableSslVerifyHost.php | Class | Class source |
DisableSslVerifyPeer.php | Class | Class source |
EnableCertInfo.php | Class | Class source |
SetCaInfo.php | Class | Class source |
SetCaPath.php | Class | Class source |
SetSslCert.php | Class | Class source |
SetSslCertPasswd.php | Class | Class source |
SetSslCertType.php | Class | Class source |
SetSslCipherList.php | Class | Class source |
SetSslEngine.php | Class | Class source |
SetSslEngineDefault.php | Class | Class source |
SetSslKey.php | Class | Class source |
SetSslKeyPasswd.php | Class | Class source |
SetSslKeyType.php | Class | Class source |
SetSslVersion.php | Class | Class source |
Files (143) | / | source | / | Option | / | Transfer |
File | Role | Description |
---|---|---|
DisableDnsUseGlobalCache.php | Class | Class source |
EnableBinaryTransfer.php | Class | Class source |
EnableCrlf.php | Class | Class source |
EnableFileTime.php | Class | Class source |
EnableHeader.php | Class | Class source |
EnableHttpProxyTunnel.php | Class | Class source |
EnableSafeUpload.php | Class | Class source |
EnableTransferText.php | Class | Class source |
EnableUpload.php | Class | Class source |
SetBufferSize.php | Class | Class source |
SetEgdSocket.php | Class | Class source |
SetEncoding.php | Class | Class source |
SetFile.php | Class | Class source |
SetHttpVersion.php | Class | Class source |
SetInFile.php | Class | Class source |
SetInFileSize.php | Class | Class source |
SetInterface.php | Class | Class source |
SetPort.php | Class | Class source |
SetProxy.php | Class | Class source |
SetProxyAuth.php | Class | Class source |
SetProxyPort.php | Class | Class source |
SetProxyType.php | Class | Class source |
SetProxyUserPwd.php | Class | Class source |
SetRandomFile.php | Class | Class source |
SetReferer.php | Class | Class source |
SetTimeValue.php | Class | Class source |
SetUserAgent.php | Class | Class source |
SetWriteHeader.php | Class | Class source |
Files (143) | / | source | / | Request |
File | Role | Description |
---|---|---|
Request.php | Class | Class source |
RequestFactory.php | Class | Class source |
Files (143) | / | source | / | ResponseBehaviour |
File | Role | Description |
---|---|---|
ConvertJsonToArrayBehaviour.php | Class | Class source |
ResponseBehaviourInterface.php | Class | Class source |
ThrowRuntimeExcept...eLimitBehaviour.php | Class | Class source |
Files (143) | / | test |
File | Role | Description | ||
---|---|---|---|---|
Builder (1 file) | ||||
Request (1 file) | ||||
Response (1 file) | ||||
ResponseBehaviour (2 files) | ||||
AbstractTestCase.php | Test | Unit test script | ||
bootstrap.php | Test | Unit test script |
Files (143) | / | test | / | ResponseBehaviour |
File | Role | Description |
---|---|---|
ConvertJsonToArrayBehaviourTest.php | Test | Unit test script |
ThrowRuntimeExcept...itBehaviourTest.php | Test | Unit test script |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
php-curl-component-2018-11-21.zip 72KB | |
php-curl-component-2018-11-21.tar.gz 25KB | |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.