{"id":16872466,"url":"https://github.com/redgoose-dev/php-restapi","last_synced_at":"2025-08-27T09:44:21.116Z","repository":{"id":62534310,"uuid":"227133237","full_name":"redgoose-dev/php-restapi","owner":"redgoose-dev","description":"RestAPI interface on php","archived":false,"fork":false,"pushed_at":"2020-08-18T15:33:58.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T22:21:55.492Z","etag":null,"topics":["api","php","rest-api","restapi"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redgoose-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-10T13:54:15.000Z","updated_at":"2020-08-18T15:32:20.000Z","dependencies_parsed_at":"2022-11-02T15:00:29.426Z","dependency_job_id":null,"html_url":"https://github.com/redgoose-dev/php-restapi","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/redgoose-dev/php-restapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redgoose-dev%2Fphp-restapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redgoose-dev%2Fphp-restapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redgoose-dev%2Fphp-restapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redgoose-dev%2Fphp-restapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redgoose-dev","download_url":"https://codeload.github.com/redgoose-dev/php-restapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redgoose-dev%2Fphp-restapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272315634,"owners_count":24912615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","php","rest-api","restapi"],"created_at":"2024-10-13T15:14:55.300Z","updated_at":"2025-08-27T09:44:21.050Z","avatar_url":"https://github.com/redgoose-dev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# restapi\n\nRestAPI interface on PHP\n\nPHP 환경에서 `API`요청을 할 수 있도록 도와주는 인터페이스 클래스입니다.  \n이 패키지는 [cURL](https://www.php.net/manual/en/book.curl.php) PHP 모듈이 사용되기 때문에 `curl`모듈이 꼭 설치되어 있어야 합니다.\n\n```shell script\n# php7.4\nsudo apt-get install php7.4-curl\n```\n\n## Install\n\n다음과 같이 `composer`를 통하여 패키지를 설치합니다.\n\n```shell script\ncomposer require redgoose/restapi\n```\n\n`composer`를 사용하지 않는다면 `github`에서 소스를 다운로드 후에 `/src/RestAPI.php`로 사용합니다.\n\n\n## Usage\n\n### with composer\n\n```php\nrequire 'vendor/autoload.php';\nuse redgoose\\RestAPI;\n\n$restapi = new RestAPI();\n```\n\n### without composer\n\n소스를 다운로드하고 직접 연결할때 사용하는 방법입니다.\n\n```php\nrequire 'src/RestAPI.php';\nuse redgoose\\RestAPI;\n\n$restapi = new RestAPI();\n```\n\n### create instance\n\n`new` 키워드를 통하여 인스턴스 객체를 만들어서 사용할 수 있습니다.\n\n```php\nuse redgoose\\RestAPI;\n\n// example\n$restapi = new RestAPI((object)[]);\n```\n\n\n## Options\n\n```php\nuse redgoose\\RestAPI;\n\n$restapi = new RestAPI((object)[\n 'url' =\u003e 'https://api.address.com',\n 'outputType' =\u003e 'text',\n 'headers' =\u003e [],\n 'timeout' =\u003e 10,\n 'debug' =\u003e false,\n]);\n```\n\n인스턴스 객체를 만들때 사용하는 옵션들입니다.  \n객체를 만드는 예제소스와 같이 `object` 타입의 값은 다음과 같습니다.\n\n| Name       | Type    | Default | Description |\n| ---------- | ------- | ------- | ----------- |\n| url        | string  | ''      | url prefix |\n| outputType | string  | 'text'  | 출력방식 `json,text` |\n| headers    | array   | []      | 요청할때 `headers`값을 사용합니다. |\n| timeout    | int     | 10      | 요청 대기시간(초) |\n| debug      | boolean | false   | 요청할때 요청 정보값을 받아와서 어떻게 요청하고 있는지 확인할 수 있습니다. |\n\n\n## Methods\n\n### request\n\n함수 형식으로 접근하여 요청할때 사용합니다.\n\n```php\nuse redgoose\\RestAPI;\n\n$response = RestAPI::request($method, $path, $data, $files, $options);\n\n// example\n$response = RestAPI::request('get', 'https://api.domain.com', null, null, (object)[]);\n```\n\n이 메서드는 다음과 같은 인자값을 사용합니다.\n\n| Name     | Type         | Default | Description |\n| -------- | ------------ | ------- | ----------- |\n| $method  | string       | 'get'   | 요청 메서드 |\n| $path    | string       | ''      | 요청 URL 주소 |\n| $data    | object,array | null    | `mehtod=get`: url query string 방식으로 사용하고, 그 외에는 `data`로 사용됩니다. |\n| $files   | array        | null    | `$_FILES` 형식의 값 |\n| $options | object       | null    | `Options` 섹션에서 사용되는 값들과 동일합니다. |\n\n### call\n\n요청할때 사용하는 메서드입니다.  \n이 메서드 내부에서 `RestAPI::request()`함수를 사용하기 때문에 사용법은 `Methods/request`섹션과 비슷합니다.\n\n```php\nuse redgoose\\RestAPI;\n\n$restapi = new RestAPI((object)[]);\n$response = $restapi-\u003ecall($method, $path, $data, $files);\n\n// example\n$response = $restapi-\u003ecall('get', 'https://api.domain.com', null, null);\n```\n\n이 메서드는 다음과 같은 인자값을 사용합니다.\n\n| Name     | Type         | Default | Description |\n| -------- | ------------ | ------- | ----------- |\n| $method  | string       | 'get'   | 요청 메서드 |\n| $path    | string       | ''      | 요청 URL 주소 |\n| $data    | object,array | null    | `mehtod=get`: url query string 방식으로 사용하고, 그 외에는 `data`로 사용됩니다. |\n| $files   | array        | null    | `$_FILES` 형식의 값 |\n\n### update\n\n인스턴스의 값을 업데이트할때 사용 수 있습니다.\n\n```php\nuse redgoose\\RestAPI;\n\n$restapi = new RestAPI();\n$restapi-\u003eupdate($options);\n```\n\n이 메서드는 다음과 같은 인자값을 사용합니다.\n\n| Name     | Type   | Default | Description |\n| -------- | ------ | ------- | ----------- |\n| $options | object | null    | `Options` 섹션에서 사용되는 값들과 동일합니다. |\n\n\n## Examples\n\n[/tests](https://github.com/redgoose-dev/php-restapi/tree/master/tests)에서 개발을 위하여 만든 흔적들을 확인할 수 있습니다.\n\n### File upload\n\n개발을 위하여 파일 업로드 기능에 관한 샘플 소스를 만들었습니다.\n\n[page/upload.php](https://github.com/redgoose-dev/php-restapi/blob/master/tests/page/upload.php) 파일은 업로드하는 폼과 첨부된 파일로 요청하는 부분을 예제로 활용할 수 있습니다.  \n그리고 [api/upload.php](https://github.com/redgoose-dev/php-restapi/blob/master/tests/api/upload.php) 파일을 업로드하고 그 결과를 출력하고 받아올 수 있습니다.\n\n`curl`은 서로 같은 도메인으로 요청할 수 없기 때문에 테스트용 API 서버서를 하나 더 띄었습니다.  \n그것은 `script.sh` 스크립트를 통하여 서로다른 포트로 로컬서버를 띄어서 파일 업로드를 개발하고 테스트하게 되었습니다.\n\nAPI 서버에서는 `$_FILES` 형식으로 넘어가면 실질적으로 파일이 업로드가 가능하다는것을 알게되어 값을 넘겨주기 위한 갑 처리가 좀 더 필요하게 되었습니다.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredgoose-dev%2Fphp-restapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredgoose-dev%2Fphp-restapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredgoose-dev%2Fphp-restapi/lists"}