From 40cb13c8ea145bb089247089a6658a5f4558918d Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:40:45 +0100 Subject: [PATCH 1/6] chore: update PHP dependencies and add README for protect-page-login example --- .../protect-page-login/php/README.md | 42 +++++ .../protect-page-login/php/composer.json | 5 +- .../protect-page-login/php/composer.lock | 168 +++++++++--------- .../getting-started/integrate-auth/05_php.mdx | 2 +- 4 files changed, 128 insertions(+), 89 deletions(-) create mode 100644 code-examples/protect-page-login/php/README.md diff --git a/code-examples/protect-page-login/php/README.md b/code-examples/protect-page-login/php/README.md new file mode 100644 index 0000000000..f93515db23 --- /dev/null +++ b/code-examples/protect-page-login/php/README.md @@ -0,0 +1,42 @@ +# Protect page login Example in PHP + +This example demonstrates protecting a page in a PHP web app using the Ory PHP SDK and the Ory Account Experience. + +For the full step-by-step guide, see: [Integrate authentication into PHP](https://www.ory.sh/docs/getting-started/integrate-auth/php) + +## Prerequisites + +- PHP 8.1+ +- Composer +- Node.js (to run the Ory CLI via `npx`) +- An Ory Network project and the Ory CLI logged in + +## Install dependencies + +```bash +composer install +``` + +## Run locally + +1. Start the PHP built-in server: + +```bash +php -S 127.0.0.1:3000 +``` + +2. In another terminal, start the Ory Tunnel pointing to your local app and project: + +```bash +npx @ory/cli tunnel --dev http://localhost:3000 --project +``` + +3. Open http://localhost:3000 in your browser. You will be redirected to the Ory Account Experience for sign-in, and then returned to the protected page. + +## Notes + +- The app reads the tunnel port from `TUNNEL_PORT` (defaults to `4000`). +- The middleware uses `toSession` to validate the user session and redirects unauthenticated users to the login UI served via the Ory Tunnel. + + + diff --git a/code-examples/protect-page-login/php/composer.json b/code-examples/protect-page-login/php/composer.json index b1b3ff26ca..ed408fae99 100644 --- a/code-examples/protect-page-login/php/composer.json +++ b/code-examples/protect-page-login/php/composer.json @@ -1,6 +1,7 @@ { "require": { - "ory/client": "^1.20", + "php": ">=8.1", + "ory/client": "^1.22.8", "bramus/router": "^1.6" } -} +} \ No newline at end of file diff --git a/code-examples/protect-page-login/php/composer.lock b/code-examples/protect-page-login/php/composer.lock index 3b6402a8ca..6c83a3e3a8 100644 --- a/code-examples/protect-page-login/php/composer.lock +++ b/code-examples/protect-page-login/php/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f9a8701c311e516fbb6778556186629c", + "content-hash": "0c48d26d4174efb37bebeb9e7c1acf98", "packages": [ { "name": "bramus/router", @@ -59,22 +59,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.5.0", + "version": "7.10.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba" + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba", - "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5", - "guzzlehttp/psr7": "^1.9 || ^2.4", + "guzzlehttp/promises": "^2.3", + "guzzlehttp/psr7": "^2.8", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -83,10 +83,11 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", + "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", - "php-http/client-integration-tests": "^3.0", - "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -99,9 +100,6 @@ "bamarni-bin": { "bin-links": true, "forward-command": false - }, - "branch-alias": { - "dev-master": "7.5-dev" } }, "autoload": { @@ -167,7 +165,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.5.0" + "source": "https://github.com/guzzle/guzzle/tree/7.10.0" }, "funding": [ { @@ -183,38 +181,37 @@ "type": "tidelift" } ], - "time": "2022-08-28T15:39:27+00:00" + "time": "2025-08-23T22:36:01+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.5.2", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "b94b2807d85443f9719887892882d0329d1e2598" + "reference": "481557b130ef3790cf82b713667b43030dc9c957" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", - "reference": "b94b2807d85443f9719887892882d0329d1e2598", + "url": "https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957", + "reference": "481557b130ef3790cf82b713667b43030dc9c957", "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.44 || ^9.6.25" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "1.5-dev" + "bamarni-bin": { + "bin-links": true, + "forward-command": false } }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Promise\\": "src/" } @@ -251,7 +248,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.2" + "source": "https://github.com/guzzle/promises/tree/2.3.0" }, "funding": [ { @@ -267,26 +264,26 @@ "type": "tidelift" } ], - "time": "2022-08-28T14:55:35+00:00" + "time": "2025-08-22T14:34:08+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.4.3", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "67c26b443f348a51926030c83481b85718457d3d" + "reference": "21dc724a0583619cd1652f673303492272778051" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", - "reference": "67c26b443f348a51926030c83481b85718457d3d", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051", + "reference": "21dc724a0583619cd1652f673303492272778051", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", + "psr/http-message": "^1.1 || ^2.0", "ralouphie/getallheaders": "^3.0" }, "provide": { @@ -294,9 +291,9 @@ "psr/http-message-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.44 || ^9.6.25" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -306,9 +303,6 @@ "bamarni-bin": { "bin-links": true, "forward-command": false - }, - "branch-alias": { - "dev-master": "2.4-dev" } }, "autoload": { @@ -370,7 +364,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.3" + "source": "https://github.com/guzzle/psr7/tree/2.8.0" }, "funding": [ { @@ -386,20 +380,20 @@ "type": "tidelift" } ], - "time": "2022-10-26T14:07:24+00:00" + "time": "2025-08-23T21:21:41+00:00" }, { "name": "ory/client", - "version": "v1.20.3", + "version": "v1.22.8", "source": { "type": "git", "url": "https://github.com/ory/client-php.git", - "reference": "b32921accf0a9034498e18d246e60a3cf31f7072" + "reference": "2fddf16b830827de6b3bb5b1171c79c28f04cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ory/client-php/zipball/b32921accf0a9034498e18d246e60a3cf31f7072", - "reference": "b32921accf0a9034498e18d246e60a3cf31f7072", + "url": "https://api.github.com/repos/ory/client-php/zipball/2fddf16b830827de6b3bb5b1171c79c28f04cc67", + "reference": "2fddf16b830827de6b3bb5b1171c79c28f04cc67", "shasum": "" }, "require": { @@ -443,7 +437,7 @@ ], "support": { "issues": "https://github.com/ory/client-php/issues", - "source": "https://github.com/ory/client-php/tree/v1.20.3" + "source": "https://github.com/ory/client-php/tree/v1.22.8" }, "funding": [ { @@ -455,25 +449,25 @@ "type": "patreon" } ], - "time": "2025-04-04T09:20:07+00:00" + "time": "2025-10-31T10:58:29+00:00" }, { "name": "psr/http-client", - "version": "1.0.1", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", - "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { "php": "^7.0 || ^8.0", - "psr/http-message": "^1.0" + "psr/http-message": "^1.0 || ^2.0" }, "type": "library", "extra": { @@ -493,7 +487,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for HTTP clients", @@ -505,27 +499,27 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/master" + "source": "https://github.com/php-fig/http-client" }, - "time": "2020-06-29T06:28:15+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/http-factory.git", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", "shasum": "" }, "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0" + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" }, "type": "library", "extra": { @@ -545,10 +539,10 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], - "description": "Common interfaces for PSR-7 HTTP message factories", + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", "keywords": [ "factory", "http", @@ -560,31 +554,31 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-factory/tree/master" + "source": "https://github.com/php-fig/http-factory" }, - "time": "2019-04-30T12:38:16+00:00" + "time": "2024-04-15T12:06:14+00:00" }, { "name": "psr/http-message", - "version": "1.0.1", + "version": "2.0", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -599,7 +593,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for HTTP messages", @@ -613,9 +607,9 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-message/tree/master" + "source": "https://github.com/php-fig/http-message/tree/2.0" }, - "time": "2016-08-06T14:39:51+00:00" + "time": "2023-04-04T09:54:51+00:00" }, { "name": "ralouphie/getallheaders", @@ -663,16 +657,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.1.1", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918", - "reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { @@ -680,12 +674,12 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.1-dev" - }, "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" } }, "autoload": { @@ -710,7 +704,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.1.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -726,7 +720,7 @@ "type": "tidelift" } ], - "time": "2022-02-25T11:15:52+00:00" + "time": "2024-09-25T14:21:43+00:00" } ], "packages-dev": [], @@ -735,7 +729,9 @@ "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": {}, + "platform": { + "php": ">=8.1" + }, "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/docs/getting-started/integrate-auth/05_php.mdx b/docs/getting-started/integrate-auth/05_php.mdx index 42a2c175d0..ec87c100c8 100644 --- a/docs/getting-started/integrate-auth/05_php.mdx +++ b/docs/getting-started/integrate-auth/05_php.mdx @@ -111,7 +111,7 @@ Console account. ory tunnel --project http://localhost:3000 ``` -To access the PHP app through the Ory Tunnel, open [http://localhost:4000](http://localhost:4000) in your browser. You are +To access the PHP app through the Ory Tunnel, open [http://localhost:3000](http://localhost:3000) in your browser. You are presented with Ory's Sign In page. Let's click on sign up and create your first user. ## Go to production From a5cc6636eb050ae8829b1151dfb02c45714b79d0 Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:59:25 +0100 Subject: [PATCH 2/6] docs: improve formatting in README for protect-page-login example --- code-examples/protect-page-login/php/README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/code-examples/protect-page-login/php/README.md b/code-examples/protect-page-login/php/README.md index f93515db23..c05d35321c 100644 --- a/code-examples/protect-page-login/php/README.md +++ b/code-examples/protect-page-login/php/README.md @@ -1,8 +1,10 @@ # Protect page login Example in PHP -This example demonstrates protecting a page in a PHP web app using the Ory PHP SDK and the Ory Account Experience. +This example demonstrates protecting a page in a PHP web app using the Ory PHP +SDK and the Ory Account Experience. -For the full step-by-step guide, see: [Integrate authentication into PHP](https://www.ory.sh/docs/getting-started/integrate-auth/php) +For the full step-by-step guide, see: +[Integrate authentication into PHP](https://www.ory.sh/docs/getting-started/integrate-auth/php) ## Prerequisites @@ -25,18 +27,18 @@ composer install php -S 127.0.0.1:3000 ``` -2. In another terminal, start the Ory Tunnel pointing to your local app and project: +2. In another terminal, start the Ory Tunnel pointing to your local app and + project: ```bash npx @ory/cli tunnel --dev http://localhost:3000 --project ``` -3. Open http://localhost:3000 in your browser. You will be redirected to the Ory Account Experience for sign-in, and then returned to the protected page. +3. Open http://localhost:3000 in your browser. You will be redirected to the Ory + Account Experience for sign-in, and then returned to the protected page. ## Notes - The app reads the tunnel port from `TUNNEL_PORT` (defaults to `4000`). -- The middleware uses `toSession` to validate the user session and redirects unauthenticated users to the login UI served via the Ory Tunnel. - - - +- The middleware uses `toSession` to validate the user session and redirects + unauthenticated users to the login UI served via the Ory Tunnel. From c9f97d4f5c6ed19d0438f0e3cee6714a84bae198 Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Fri, 7 Nov 2025 12:39:31 +0100 Subject: [PATCH 3/6] chore: add missing newline at end of composer.json for protect-page-login example --- code-examples/protect-page-login/php/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-examples/protect-page-login/php/composer.json b/code-examples/protect-page-login/php/composer.json index ed408fae99..93dcafdd58 100644 --- a/code-examples/protect-page-login/php/composer.json +++ b/code-examples/protect-page-login/php/composer.json @@ -4,4 +4,4 @@ "ory/client": "^1.22.8", "bramus/router": "^1.6" } -} \ No newline at end of file +} From d185f03a2e53c187ca17d7e5b6b6c1204b7fbe7c Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Fri, 7 Nov 2025 12:47:59 +0100 Subject: [PATCH 4/6] docs: refine README description for protect-page-login example --- code-examples/protect-page-login/php/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-examples/protect-page-login/php/README.md b/code-examples/protect-page-login/php/README.md index c05d35321c..fd704addb9 100644 --- a/code-examples/protect-page-login/php/README.md +++ b/code-examples/protect-page-login/php/README.md @@ -1,7 +1,7 @@ # Protect page login Example in PHP -This example demonstrates protecting a page in a PHP web app using the Ory PHP -SDK and the Ory Account Experience. +This example demonstrates a PHP web app page, built using Ory Account +Experience, and protected using the Ory PHP SDK. For the full step-by-step guide, see: [Integrate authentication into PHP](https://www.ory.sh/docs/getting-started/integrate-auth/php) From c7b106a570e8a6b494d480d7ff4fd5fa67f75581 Mon Sep 17 00:00:00 2001 From: wassimoo <12980387+wassimoo@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:50:40 +0100 Subject: [PATCH 5/6] docs: update README title for clarity in protect-page-login example --- code-examples/protect-page-login/php/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-examples/protect-page-login/php/README.md b/code-examples/protect-page-login/php/README.md index fd704addb9..1537b42a89 100644 --- a/code-examples/protect-page-login/php/README.md +++ b/code-examples/protect-page-login/php/README.md @@ -1,4 +1,4 @@ -# Protect page login Example in PHP +# Protect page with login example in PHP This example demonstrates a PHP web app page, built using Ory Account Experience, and protected using the Ory PHP SDK. From 1a353dd59da61b578d43a18c9647cf75a5bd0d34 Mon Sep 17 00:00:00 2001 From: Wassim <12980387+wassimoo@users.noreply.github.com> Date: Mon, 10 Nov 2025 09:54:59 +0100 Subject: [PATCH 6/6] docs: update README title to reflect authentication focus in protect-page-login php example --- code-examples/protect-page-login/php/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code-examples/protect-page-login/php/README.md b/code-examples/protect-page-login/php/README.md index 1537b42a89..6b8bd50ab8 100644 --- a/code-examples/protect-page-login/php/README.md +++ b/code-examples/protect-page-login/php/README.md @@ -1,4 +1,4 @@ -# Protect page with login example in PHP +# Ory Authentication Example with PHP This example demonstrates a PHP web app page, built using Ory Account Experience, and protected using the Ory PHP SDK.