{"id":18939306,"url":"https://github.com/gentics/mesh-php-client","last_synced_at":"2025-04-15T19:30:46.968Z","repository":{"id":41514120,"uuid":"146315267","full_name":"gentics/mesh-php-client","owner":"gentics","description":"PHP Client implementation for Gentics Mesh REST API.","archived":false,"fork":false,"pushed_at":"2023-11-14T22:55:00.000Z","size":230,"stargazers_count":2,"open_issues_count":4,"forks_count":2,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-29T01:13:01.773Z","etag":null,"topics":["gentics-mesh","php-client"],"latest_commit_sha":null,"homepage":"https://getmesh.io/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gentics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-27T15:13:24.000Z","updated_at":"2021-11-30T17:44:28.000Z","dependencies_parsed_at":"2023-01-27T16:00:40.931Z","dependency_job_id":null,"html_url":"https://github.com/gentics/mesh-php-client","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gentics%2Fmesh-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gentics%2Fmesh-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gentics%2Fmesh-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gentics%2Fmesh-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gentics","download_url":"https://codeload.github.com/gentics/mesh-php-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248789453,"owners_count":21161835,"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","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":["gentics-mesh","php-client"],"created_at":"2024-11-08T12:17:05.606Z","updated_at":"2025-04-15T19:30:46.539Z","avatar_url":"https://github.com/gentics.png","language":"PHP","readme":"# Gentics Mesh PHP Client\n\n\u003e PHP Client implementation for [Gentics Mesh REST API](https://getmesh.io/docs/beta/raml).\n\n## Installation\n\n```sh\ncomposer require gentics/mesh-php-client\n```\n\n## Basic usage\n\n```php\nuse Gentics\\Mesh\\Client\\MeshClient;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$client = new MeshClient(\"http://localhost:8080/api/v1\");\n\n// Load user info (sync)\n$request = $client-\u003eme();\n$response = $request-\u003esend();\necho $response-\u003egetBody();\n\n// Load user info (async)\n$promise = $request-\u003esendAsync();\n$promise-\u003ethen(function ($response) {\n  echo 'I completed! ' . $response-\u003egetBody();\n});\n$promise-\u003ewait();\n\n// Load users and apply paging\n$request = $client-\u003efindUsers([\"perPage\" =\u003e 1]);\n$response = $request-\u003esend();\necho $response-\u003egetBody(); \n```\n\n## Authentication\n\n```php\n$client = new MeshClient(\"http://localhost:8080/api/v1\");\n\n// You can either login and use the build-in cookie handling\n// Keep in mind that your cookie will not be automatically refreshed.\n// Any authenticated request will refresh the cookie and keep you authenticated.\n$client-\u003elogin(\"admin\", \"admin\")-\u003ewait();\n\n// Or use a dedicated API key which will never expire\n// You can use the mesh-cli to generate a key\n// Setting the API key will invalidate any previously set login token information\n$client-\u003esetAPIKey(\"eyJ0eXAiOiJKV1QiLC … ZYYJbD8HllF6XZT0xRTxr3i4b9PY\");\n```\n\n## GraphQL Example\n\n```php\n$client = new MeshClient(\"http://localhost:8080/api/v1\");\n$query = [\n    \"query\" =\u003e \"{users{elements{uuid, username}}}\"\n];\n$request = $client-\u003egraphQL(\"demo\", $query);\n$response = $request-\u003esend();\n$json = $response-\u003etoJson();\n$this-\u003eassertEquals(\"anonymous\", $json-\u003edata-\u003eusers-\u003eelements[0]-\u003eusername);\n```\n\n## WebRoot Example\n\nWith webroot you can fetch any node which contains a `segment` field in the schema. \nThe webroot endpoint is also able to directly return binary data.\n\n```php\n$client = new MeshClient(\"http://localhost:8888/api/v1\");\n$request = $client-\u003ewebroot(\"demo\", \"/images/yacht-pelorus.jpg\");\n$response = $request-\u003esend();\n// You can check whether the webroot response returns json or otherwise binary data (e.g. image data)\n$response-\u003eisJson();\n```\n\n\n## CRUD Example\n\n```php\n$client = new MeshClient(\"http://localhost:8080/api/v1\");\n$client-\u003elogin(\"admin\", \"admin\")-\u003ewait();\n\n// 1. Create User\n$request = [\n  \"username\" =\u003e \"guzzle\",\n    \"password\" =\u003e \"geheim\",\n];\n$uuid = \"5725992507e748a1a5992507e7f8a115\";\n$userResp = $client-\u003ecreateUserWithUuid($uuid, $request)-\u003esend()-\u003etoJson();\n\n// 2. Read user\n$user = $client-\u003efindUserByUuid($uuid)-\u003esend()-\u003etoJson();\n\n// 3. Update user\n$user-\u003eusername = \"hugo\";\n$updated = $client-\u003eupdateUser($uuid, $user)-\u003esend()-\u003etoJson();\n\n// 4. Delete user\n$client-\u003edeleteUser($uuid)-\u003esend();\n```\n\n## Error Handling\n\nBy default exceptions will be thrown if the request fails (e.g. 4xx, 5xx error code).\n\n```php\ntry {\n  $uuid = \"5725992507e748a1a5992507e7f8a115\";\n  $client-\u003edeleteUser($uuid)-\u003esend();\n} catch (ClientException $e) {\n    // Error could indicate a 404\n    $response = $e-\u003egetResponse();\n    echo $response-\u003egetBody()-\u003egetContents();\n}\n```\n\n## Configuration\n\nIt is possible to configure the underlying Guzzle client:\n\n```php\n// Change the default error behaviour to not throw error exceptions\n$config = ['http_errors' =\u003e false];\n$client = new MeshClient(\"http://localhost:8080/api/v1\", $config);\n```\n\n## Compatibility\n\n* Gentics Mesh 1.8.x\n* PHP 8.1+\n\n# TODOs\n\n* Implement full upload support\n* Implement eventbus websocket support\n\n## Release\n\n**maintenance-0.10.x branch**\nVersioning: 0.10.x - PHP 7.x, Guzzle 6\n\n**master branch**\nVersioning: 0.20.x - PHP 8.1+, Guzzle 7\n\n## License\n\n[Apache License Version 2.0](http://www.apache.org/licenses/)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgentics%2Fmesh-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgentics%2Fmesh-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgentics%2Fmesh-php-client/lists"}