diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..7ce7846f5151d458b4a31e3885b03ec3f9190c14 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,24 @@ +# https://git-scm.com/docs/gitattributes +# https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings + +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted to native line endings on checkout. + +# Configs +.editorconfig text eol=lf +.gitattributes text eol=lf + +# Documentation +*.md text eol=lf diff=markdown + +# Ignore files +*.*ignore text eol=lf + +# Do not export +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.gitkeep export-ignore +CHANGELOG.md export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..1663a238eb09b6cbd153415e9e9cf1bd98a553a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +### JetBrains working directory +/.idea/ + +### Composer files +composer.phar +composer.lock +/vendor/ + +### keep all placeholders +!.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..29d19b115566dfdc31a3aa8b5666be1e513467c3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added +- Feature [#1](https://gitlab.com/take-me/curl/-/issues/1) - First Project Structure + +### Changed + +### Deprecated + +### Fixed + +### Removed diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..593728aa204fb694b71c8a2a93dfa359837bb216 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Jens Nimmich + +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. diff --git a/README.md b/README.md index 5c484152ae42b35ae0df50e5beeec241b937b3a5..ae1066bdbbe7df45c0a2e6e3cf81c0d007e1e7b4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,31 @@ # TakeMe / cURL -A OOP PHP wrapper for native cURL functions. +--- + +This is an OOP wrapper for native PHP cURL functions without any business logic. +It does not contain all possible functions, but it will be extended on demand. + +## ⚙️Installation +Use composer to install this wrapper: + +` +composer require take-me/curl +` + +## ✔️Usage + +Create a Curl-instance and a CurlOption-instance and start: + +` + $curl = new TakeMe/Curl(); + $curlOption = new TakeMe/CurlOption($curl); + + $curl->exec(); +` + +## ⁉️ Support +If you have questions about this project please [email](mailto:lmo5-support@jens-nimmich.de?subject=Support%20for%20LMO5) me. + +## 📝 License +Copyright (C) 2025 [Jens Nimmich](mailto:project-curl@jens-nimmich.de).
+This project is [MIT](https://choosealicense.com/licenses/gpl-3.0/) licensed. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..3ab8501645652fb8434fc673fb1af3f65bc6c4dd --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "take-me/curl", + "description": "An OOP wrapper for native PHP cURL functions.", + "license": "MIT", + "type": "library", + "authors": [ + { + "name": "Jens Nimmich", + "email": "project-curl@jens-nimmich.de" + } + ], + "require": { + "php": "^8.2", + "ext-curl": "*" + }, + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "TakeMe\\": "src/" + } + }, + "config": { + "prefer-stable": true, + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + } + } +} diff --git a/src/Curl.php b/src/Curl.php new file mode 100644 index 0000000000000000000000000000000000000000..99c92c3fdca9312943249a1babac8f1b1632ee5c --- /dev/null +++ b/src/Curl.php @@ -0,0 +1,34 @@ +handle = $this->init(); + } + + public function getHandle(): \CurlHandle + { + return $this->handle; + } + + public function exec(): bool|string + { + return curl_exec($this->handle); + } + + private function init(): \CurlHandle|false + { + return curl_init(); + } +} diff --git a/src/CurlOptions.php b/src/CurlOptions.php new file mode 100644 index 0000000000000000000000000000000000000000..409c641abf2efa2e0f3e5fc60c0ebbfd6118134f --- /dev/null +++ b/src/CurlOptions.php @@ -0,0 +1,26 @@ +setOpt(CURLOPT_RETURNTRANSFER, true); + } + + public function setUrl(string $url): bool + { + return $this->setOpt(CURLOPT_URL, $url); + } + + private function setOpt(int $optionId, mixed $value): bool + { + return curl_setopt($this->handle, $optionId, $value); + } +} diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php new file mode 100644 index 0000000000000000000000000000000000000000..c39951ccd26c0d2c1709aaac3bdc60323f08bb0b --- /dev/null +++ b/src/Exception/RuntimeException.php @@ -0,0 +1,7 @@ +