We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

[2.0] getHeader() didn't work

Can not get header from request->getHeader(), but from getallheaders() is normal. I use Apache 2.4.12, PHP 5.6.7



4.7k

What exactly is your question?

$clientId = $app->request->getHeader('API_ID'); $clientId = NULL

but with $serverHeader = getallheaders(); $clientId = $serverHeader['API_ID']; This get the data.



4.7k

Which Headers do you get if you call getHeaders() ?

$allHeaders = $app->request->getHeaders();

var_dump($allHeaders);

Is your Header "API_ID" in this array list?

It's return NULL for get by getHeaders(). And yes, API_ID is in headers if get by getallheaders().

Are you using \Phalcon\DI::FactoryDefault() for your depenency injection?

If not, try

$app->getShared('request')->getHeaders();