|
| 1 | +<div align="center"> |
| 2 | +<a href="https://github.com/playwright-php"><img src="https://github.com/playwright-php/.github/raw/main/profile/playwright-php.png" alt="Playwright PHP" /></a> |
| 3 | + |
| 4 | +  |
| 5 | +  |
| 6 | +  |
| 7 | +  |
| 8 | + |
| 9 | +</div> |
| 10 | + |
| 11 | +# Playwright PHP Device Descriptors |
| 12 | + |
| 13 | +[Microsoft Playwright](https://github.com/microsoft/playwright) ships an official catalogue |
| 14 | +of [device descriptors](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json). |
| 15 | + |
| 16 | +This package mirrors that list for PHP by exporting the JSON data to `data/devices.php`, and exposes a `DeviceRegistry` |
| 17 | +class to retrieve device descriptors by name. |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +composer require playwright-php/devices |
| 23 | +``` |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +```php |
| 28 | +use Playwright\Device\DeviceRegistry; |
| 29 | + |
| 30 | +$iphone = (new DeviceRegistry())->get('iPhone 15 Pro'); |
| 31 | + |
| 32 | +// Pass the device properties to a new browser context: |
| 33 | +$browser->newContext([ |
| 34 | + 'userAgent' => $iphone->getUserAgent(), |
| 35 | + 'viewport' => $iphone->getViewport(), |
| 36 | + 'isMobile' => $iphone->isMobile(), |
| 37 | + 'hasTouch' => $iphone->hasTouch(), |
| 38 | +]); |
| 39 | + |
| 40 | +// Or more simply: |
| 41 | +$browser->newContext($iphone->toArray()); |
| 42 | +``` |
| 43 | + |
| 44 | +## Device descriptors |
| 45 | + |
| 46 | +Explore the full catalogue in [`docs/DEVICES.md`](docs/DEVICES.md). |
| 47 | + |
| 48 | +### Desktop devices |
| 49 | + |
| 50 | +| Device | Browser | Viewport | Scale | Mobile | Touch | |
| 51 | +|-----------------------|----------|------------|-------|--------|-------| |
| 52 | +| Desktop Chrome | Chromium | 1280 x 720 | 1 | No | No | |
| 53 | +| Desktop Chrome HiDPI | Chromium | 1280 x 720 | 2 | No | No | |
| 54 | +| Desktop Edge | Chromium | 1280 x 720 | 1 | No | No | |
| 55 | +| Desktop Edge HiDPI | Chromium | 1280 x 720 | 2 | No | No | |
| 56 | +| Desktop Firefox | Firefox | 1280 x 720 | 1 | No | No | |
| 57 | +| Desktop Firefox HiDPI | Firefox | 1280 x 720 | 2 | No | No | |
| 58 | +| Desktop Safari | Webkit | 1280 x 720 | 2 | No | No | |
| 59 | + |
| 60 | +### Mobile devices |
| 61 | + |
| 62 | +| Device | Browser | Viewport | Scale | Screen | Viewport | |
| 63 | +|---------------------|----------|------------|-------|------------|----------| |
| 64 | +| LG Optimus L70 | Chromium | 640 x 384 | 1.25 | 384 x 640 | Yes | |
| 65 | +| iPhone 15 Pro Max | Webkit | 814 x 380 | 3 | 430 x 739 | Yes | |
| 66 | +| Kindle Fire HDX | Webkit | 1280 x 800 | 2 | 800 x 1280 | Yes | |
| 67 | +| Microsoft Lumia 550 | Chromium | 640 x 360 | 2 | 360 x 640 | Yes | |
| 68 | +| Pixel 7 | Chromium | 863 x 360 | 2.63 | 412 x 839 | Yes | |
| 69 | + |
| 70 | +## License |
| 71 | + |
| 72 | +This package is released by the [Playwright PHP](https://playwright-php.dev) |
| 73 | +project under the MIT License. See the [LICENSE](LICENSE) file for details. |
0 commit comments