Hugh Harlequin 2 éve
commit
96beb81f45
13 módosított fájl, 564 hozzáadás és 0 törlés
  1. 4 0
      .gitignore
  2. 12 0
      .travis.yml
  3. 76 0
      CHANGELOG.md
  4. 54 0
      CONTRIBUTING.md
  5. 21 0
      LICENSE
  6. 0 0
      README.md
  7. 43 0
      composer.json
  8. 236 0
      composer.lock
  9. 18 0
      phpunit.xml
  10. 31 0
      src/Builder.php
  11. 19 0
      src/Facades/Curl.php
  12. 17 0
      src/MultiCurlService.php
  13. 33 0
      src/MultiCurlServiceProvider.php

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+/vendor
+composer.phar
+.DS_Store
+.idea

+ 12 - 0
.travis.yml

@@ -0,0 +1,12 @@
+language: php
+
+php: 
+  - 5.3
+  - 5.4
+  - 5.5
+
+before_script:
+  - curl -s http://getcomposer.org/installer | php
+  - php composer.phar install --dev
+
+script: phpunit

+ 76 - 0
CHANGELOG.md

@@ -0,0 +1,76 @@
+# Changelog
+
+All Notable changes to `ixudra/curl` will be documented in this file
+## 6.22.2 - 2022-11-09
+### Added
+- Added CURLOPT_ENCODING (by `withEncoding($encode = 'gzip,deflate')`)
+
+## 6.22.1 - 2022-07-31
+### Fixed
+- Use correct default values for http_build_query
+
+## 6.22.0 - 2021-11-14
+### Added
+- Added HEAD request support
+
+## 6.21.0 - 2020-09-22
+### Added
+- withAuthorization utility method
+- withBearer utility method
+
+## 6.20.0 - 2020-08-07
+### Fixed
+- Data is now passed as POST parameters instead of GET for `DELETE` REQUESTS
+
+### Added
+- Additional docblocks
+- GET parameters are added to the URL on file download
+
+## 6.19.0 - 2020-03-03
+### Added
+- Added `withConnectTimeout()` method
+
+## 6.17.0 - 2019-09-13
+### Added
+- Added support for multiple response headers with the same name
+
+## 6.16.0 - 2017-12-07
+### Added
+- Added method to return response headers in the response objects
+
+## 6.15.1 - 2017-11-07
+### Added
+- Bugfix: wrong variable used
+
+## 6.15.0 - 2017-11-06
+### Added
+- Added withProxy method
+
+## 6.14.0 - 2017-10-30
+### Added
+- Laravel auto-discovery
+
+## 6.13.0 - 2017-10-10
+### Added
+- Added content type to responseObject
+
+## 6.12.2 - 2017-08-23
+### Fixed
+- Reverted type hinting in `withData()` method
+
+## 6.12.1 - 2017-08-07
+### Fixed
+- Removed debug code
+- Fixed undefined index bug
+
+## 6.12.0 - 2017-08-06
+### Added
+- File uploads by path
+- `returnResponseArray()` method
+- `enableXDebug()` method for easy xDebug integration
+- CHANGELOG file
+
+### Updated
+- README
+
+

+ 54 - 0
CONTRIBUTING.md

@@ -0,0 +1,54 @@
+# Contributing
+
+Contributions are **welcome** and will be fully **credited**.
+
+Please read and understand the contribution guide before creating an issue or pull request.
+
+
+## Etiquette
+
+This project is open source, and as such, the maintainers give their free time to build and maintain the source code held within. They make the code freely available in the hope that it will be of use to other developers. It would be extremely unfair for them to suffer abuse or anger for their hard work.
+
+Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the world that developers are civilized and selfless people.
+
+
+## Creating issues
+
+### Procedure
+
+Before filing an issue:
+
+- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident
+- Reread the documentation to make sure if the answer the question hasn't already been addressed there
+- Make sure the question wasn't already asked before in this project. Also check the closed issues
+- Check the pull requests tab to make sure that the bug doesn't have a fix in progress
+
+
+## Submitting pull requests
+
+### Viability
+
+When requesting or submitting new features, first consider whether it might be useful to others. Open
+source projects are used by many developers, who may have entirely different needs to your own. Think about
+whether or not your feature is likely to be used by other users of the project.
+
+
+### Procedure
+
+Before submitting a pull request:
+
+- Check the codebase to ensure that your feature doesn't already exist
+- Check the pull requests tab to make sure that the bug doesn't have a feature request in progress
+
+
+### Requirements
+
+If the project maintainer has any additional requirements, you will find them listed here:
+
+- **Respect the project code style** - Your pull request will not be accepted if it changes half of the lines in the files. All of our projects generally adhere to the [PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) with some minor differences
+- **Make sure all tests are updated** - Unit tests are out insurance policy that guarantee that the code functions as intended. Please make sure they function correctly and cover all changes you have made to the code
+- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date
+- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests
+- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting
+
+**Happy coding**!

+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Jan Oris, Hugh Harlequin(Modification)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 0 - 0
README.md


+ 43 - 0
composer.json

@@ -0,0 +1,43 @@
+{
+    "name": "hugh/multi-curl",
+    "description": "Custom PHP Curl library for the Laravel framework when multiple - developed by Hugh",
+    "version": "0.0.1",
+    "keywords": ["Hugh", "Laravel", "Curl"],
+    "homepage": "https://git.hugh2113.com/hugh",
+    "license": "MIT",
+
+    "authors": [
+        {
+            "name": "Hugh Harlequin",
+            "email": "[email protected]"
+        }
+    ],
+    "repositories": [
+        {
+            "type": "vcs",
+            "url": "https://git.hugh2113.com/hugh/curl.git"
+        }
+    ],
+    "require": {
+        "php": ">=5.4.0",
+        "ext-curl": "*",
+        "illuminate/support": ">=4.0",
+        "hugh/curl": ">=6.22.2"
+    },
+
+    "autoload": {
+        "psr-4": {
+            "Hugh\\MultiCurl\\": "src/"
+        }
+    },
+    "extra": {
+        "laravel": {
+            "providers": [
+                "Hugh\\MultiCurl\\MultiCurlServiceProvider"
+            ],
+            "aliases": {
+                "Curl": "Hugh\\MultiCurl\\Facades\\MultiCurl"
+            }
+        }
+    }
+}

+ 236 - 0
composer.lock

@@ -0,0 +1,236 @@
+{
+    "_readme": [
+        "This file locks the dependencies of your project to a known state",
+        "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+        "This file is @generated automatically"
+    ],
+    "hash": "a22bdfa6600e7832d499e2f16f86176c",
+    "packages": [
+        {
+            "name": "danielstjules/stringy",
+            "version": "1.9.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/danielstjules/Stringy.git",
+                "reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
+                "reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
+                "shasum": ""
+            },
+            "require": {
+                "ext-mbstring": "*",
+                "php": ">=5.3.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Stringy\\": "src/"
+                },
+                "files": [
+                    "src/Create.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Daniel St. Jules",
+                    "email": "[email protected]",
+                    "homepage": "http://www.danielstjules.com"
+                }
+            ],
+            "description": "A string manipulation library with multibyte support",
+            "homepage": "https://github.com/danielstjules/Stringy",
+            "keywords": [
+                "UTF",
+                "helpers",
+                "manipulation",
+                "methods",
+                "multibyte",
+                "string",
+                "utf-8",
+                "utility",
+                "utils"
+            ],
+            "time": "2015-02-10 06:19:18"
+        },
+        {
+            "name": "doctrine/inflector",
+            "version": "v1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/doctrine/inflector.git",
+                "reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604",
+                "reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.2"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "4.*"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-0": {
+                    "Doctrine\\Common\\Inflector\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Roman Borschel",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Benjamin Eberlei",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Guilherme Blanco",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Jonathan Wage",
+                    "email": "[email protected]"
+                },
+                {
+                    "name": "Johannes Schmitt",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "Common String Manipulations with regard to casing and singular/plural rules.",
+            "homepage": "http://www.doctrine-project.org",
+            "keywords": [
+                "inflection",
+                "pluralize",
+                "singularize",
+                "string"
+            ],
+            "time": "2014-12-20 21:24:13"
+        },
+        {
+            "name": "illuminate/contracts",
+            "version": "v5.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/illuminate/contracts.git",
+                "reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/illuminate/contracts/zipball/78f1dba092d5fcb6d3a19537662abe31c4d128fd",
+                "reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.4.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "5.0-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Illuminate\\Contracts\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Taylor Otwell",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "The Illuminate Contracts package.",
+            "time": "2015-01-30 16:27:08"
+        },
+        {
+            "name": "illuminate/support",
+            "version": "v5.0.26",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/illuminate/support.git",
+                "reference": "29e8618a45d090572e092abf193a257bf28c48d9"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/illuminate/support/zipball/29e8618a45d090572e092abf193a257bf28c48d9",
+                "reference": "29e8618a45d090572e092abf193a257bf28c48d9",
+                "shasum": ""
+            },
+            "require": {
+                "danielstjules/stringy": "~1.8",
+                "doctrine/inflector": "~1.0",
+                "ext-mbstring": "*",
+                "illuminate/contracts": "5.0.*",
+                "php": ">=5.4.0"
+            },
+            "suggest": {
+                "jeremeamia/superclosure": "Required to be able to serialize closures (~2.0)."
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "5.0-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Illuminate\\Support\\": ""
+                },
+                "files": [
+                    "helpers.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Taylor Otwell",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "The Illuminate Support package.",
+            "homepage": "http://laravel.com",
+            "time": "2015-03-27 14:49:11"
+        }
+    ],
+    "packages-dev": [],
+    "aliases": [],
+    "minimum-stability": "stable",
+    "stability-flags": [],
+    "prefer-stable": false,
+    "prefer-lowest": false,
+    "platform": {
+        "php": ">=5.4.0"
+    },
+    "platform-dev": []
+}

+ 18 - 0
phpunit.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+         backupStaticAttributes="false"
+         bootstrap="vendor/autoload.php"
+         colors="true"
+         convertErrorsToExceptions="true"
+         convertNoticesToExceptions="true"
+         convertWarningsToExceptions="true"
+         processIsolation="false"
+         stopOnFailure="false"
+         syntaxCheck="false"
+>
+    <testsuites>
+        <testsuite name="Package Test Suite">
+            <directory suffix=".php">./tests/</directory>
+        </testsuite>
+    </testsuites>
+</phpunit>

+ 31 - 0
src/Builder.php

@@ -0,0 +1,31 @@
+<?php namespace Hugh\MultiCurl;
+
+use Hugh\Curl\Builder as CurlBuilder;
+
+class Builder {
+    private $mCurl = null;
+    private $curls = [];
+
+    public function __construct() {
+        $this->mCurl = curl_multi_init();
+    }
+    public function add(CurlBuilder $curl) {
+        curl_multi_add_handle($this->mCurl, $curl);
+        $this->curls[] = $curl;
+    }
+    public function go() {
+        do {
+            $status = curl_multi_exec($this->mCurl, $active);
+            if ($active) {
+                curl_multi_select($this->mCurl);
+            }
+        } while ($active && $status == CURLM_OK);
+        curl_multi_close($this->mCurl);
+        $result = [];
+        foreach ($this->curls as $curl) {
+            $result[] = curl_multi_getcontent($curl);
+        }
+        return $result;
+    }
+
+}

+ 19 - 0
src/Facades/Curl.php

@@ -0,0 +1,19 @@
+<?php namespace Hugh\MultiCurl\Facades;
+
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static \Hugh\Curl\Builder to(string $url)
+ */
+class MultiCurl extends Facade {
+
+    /**
+     * @return string
+     */
+    protected static function getFacadeAccessor()
+    {
+        return 'MultiCurl';
+    }
+
+}

+ 17 - 0
src/MultiCurlService.php

@@ -0,0 +1,17 @@
+<?php namespace Hugh\MultiCurl;
+
+
+class MultiCurlService {
+
+    /**
+     * @param $url string   The URL to which the request is to be sent
+     * @return Builder
+     */
+    public function add($url)
+    {
+        $builder = new Builder();
+
+        return $builder->add($url);
+    }
+
+}

+ 33 - 0
src/MultiCurlServiceProvider.php

@@ -0,0 +1,33 @@
+<?php namespace Hugh\MultiCurl;
+
+
+use Illuminate\Support\ServiceProvider;
+
+class MultiCurlServiceProvider extends ServiceProvider {
+
+    /**
+     * @var bool
+     */
+    protected $defer = false;
+
+
+    /**
+     * @return void
+     */
+    public function register()
+    {
+        $this->app->singleton('Curl', function () {
+                return new MultiCurlService();
+            }
+        );
+    }
+
+    /**
+     * @return array
+     */
+    public function provides()
+    {
+        return array('MultiCurl');
+    }
+
+}