Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions code-examples/protect-page-login/php/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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.

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 <project_id>
```

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.
3 changes: 2 additions & 1 deletion code-examples/protect-page-login/php/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require": {
"ory/client": "^1.20",
"php": ">=8.1",
"ory/client": "^1.22.8",
"bramus/router": "^1.6"
}
}
Loading
Loading