Automattic / Automattic/php-push
Running PHP index without a `.env` setup fails with an unclear error
- Vorherrschende Sprache
- PHP
- Sterne
- 5
- Forks
- 2
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hey @jkmassel, as you know, I'm a PHP noob. So feel free to close this issue if what I'm saying doesn't make sense.
I'm tracking this as an issue rather than a Slack convo because it feels tidier. Also, it might be a chance for me to link a PR to this issue to practice fixing.
---
After cloning the repo and running Composer, I tried to run `php index.php` knowing that I had no credentials setup to see the kind of error I'd get. This is what happened
```
➜ php index.php
=== Push Notification Server ===
PHP Fatal error: Uncaught TypeError: strlen() expects parameter 1 to be string, bool given in /Users/gio/Developer/a8c/php-push/src/model/APNSCredentials.php:12
Stack trace:
#0 /Users/gio/Developer/a8c/php-push/index.php(7): APNSCredentials->__construct(false, false, false)
#1 {main}
thrown in /Users/gio/Developer/a8c/php-push/src/model/APNSCredentials.php on line 12
Fatal error: Uncaught TypeError: strlen() expects parameter 1 to be string, bool given in /Users/gio/Developer/a8c/php-push/src/model/APNSCredentials.php:12
Stack trace:
#0 /Users/gio/Developer/a8c/php-push/index.php(7): APNSCredentials->__construct(false, false, false)
#1 {main}
thrown in /Users/gio/Developer/a8c/php-push/src/model/APNSCredentials.php on line 12
```
What I would have expected was a message about the missing `.env` with info on how to set it up.
Granted, for the context of this application, handling as one-off basic task like setting app `.env` might be overkill. Still worth tracking, though, I think.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Führe zunächst `php index.php` ohne eine `.env`-Datei aus, um den Fehler zu reproduzieren. Lies `index.php` und `src/model/APNSCredentials.php`, insbesondere den Konstruktoraufruf und den gemeldeten `strlen()`-Fehler. Als abgeschlossen gilt die Änderung, wenn fehlende Zugangsdaten eine klare Meldung über die fehlende `.env`-Datei und deren Einrichtung ausgeben, anstatt des aktuellen TypeError.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100