Automattic / Automattic/php-push

Running PHP index without a `.env` setup fails with an unclear error

Aperta
#3 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PHP
Stelle
5
Fork
2
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia eseguendo `php index.php` senza un file `.env` per riprodurre l’errore. Leggi `index.php` e `src/model/APNSCredentials.php`, in particolare la chiamata al costruttore e l’errore `strlen()` riportato. Il lavoro è completato quando la mancanza delle credenziali produce un messaggio chiaro sull’assenza di `.env` e su come configurarlo, invece dell’attuale TypeError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
backend
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.