Comments (5)
Can you show the PHP code that triggers this error please?
from frankenphp.
Here's an example script:
<?php
while(frankenphp_handle_request(function() {
$value = $_ENV['stuff'] ?? null;
echo "_ENV: $value\n";
$value = getenv('stuff');
echo "getenv: $value\n";
$value = $_SERVER['stuff'] ?? null;
echo "_SERVER: $value\n";
})) {}
And the output:
// sudo stuff="abcs" ./frankenphp php-server --worker worker.php,2
> curl -k http://localhost/worker.php
_ENV:
getenv: abcs
_SERVER: abcs
Note: if I set php.ini's variable_order
to EGPCS
, then it is always filled:
❯ curl -k http://localhost/worker.php
_ENV: abcs
getenv: abcs
_SERVER: abcs
I can't reproduce your issue.
from frankenphp.
I added variables_order = EGPCS
to 10-app.ini and it apparently solved the problem, now that is a bit strange considering that this configuration is the PHP default, so in theory it should already be working, according to the documentation.
I'll leave this noted so I can check it next week with a standard project. If I can reproduce the problem, I'll upload the project here on Github along with the PR to add the line variables_order = EGPCS
.
from frankenphp.
This is a method to generate the correct API URL, where in the production environment it adds HTTPS and in development it adds HTTP.
public static function getURLAPI(Request $request): string {
$schemaURL = 'http' . (strtolower($_ENV['APP_ENV']) === 'prod' ? 's' : '') . '://';
$url = $schemaURL . $request->getHost();
if ($request->getPort() != 80 && $request->getPort() != 443)
$url .= ':' . $request->getPort();
return $url . $request->getPathInfo();
}
You can access this link and you will see that in proximaPagina
each time the page is updated it will be with HTTPS and the next with HTTP, when it is with HTTP it gives the error in the log:
{"level":"info","ts":1723499344.042241,"msg":"[error] Warning: Undefined array key \"APP_ENV\"","syslog_level":"notice"}
Running cat .env.local.php
gives this result:
<?php
// This file was generated by running "composer dump-env prod"
return array (
'APP_ENV' => 'prod',
'SYMFONY_DOTENV_PATH' => './.env',
'SOURCE_COMMIT' => 'XXXXX',
'COOLIFY_FQDN' => 'XXXXX',
'COOLIFY_URL' => 'XXXXX',
'COOLIFY_BRANCH' => 'XXXXX',
'COOLIFY_CONTAINER_NAME' => 'XXXXX',
'APP_SECRET' => 'XXXXX',
'CORS_ALLOW_ORIGIN' => '^https://(www.)?XXXXX.com.br$',
'DATABASE_URL' => 'XXXXX',
'JWT_PASSPHRASE' => 'XXXXX',
'JWT_PUBLIC_KEY' => 'XXXXX',
'JWT_SECRET_KEY' => 'XXXXX',
'JWT_TEMPO_VIDA' => 'XXXXX',
'QNT_PUBLICACOES_POR_PAGINA' => '20',
'SERVER_NAME' => 'api.aposentadoriadoinss.com.br:80',
'STORAGE_BUCKET' => 'XXXXX',
'STORAGE_ENDERECO' => 'XXXXX',
'STORAGE_ENDERECO_IMAGENS' => 'XXXXX/imagens',
'STORAGE_KEY' => 'XXXXX',
'STORAGE_REGIAO' => 'XXXXX',
'STORAGE_SECRET' => 'XXXXX',
'TINY_PNG_KEY' => 'XXXXX',
'PORT' => '80',
'HOST' => '0.0.0.0',
);
Running echo $APP_ENV
gives this result:
prod
These commands were run inside the resulting container from Dockerfile
from frankenphp.
Does the error still happen when you use getenv()
or $_SERVER
instead of $_ENV
?
Note: getenv
isn't thread safe, so if you have things changing the environment during runtime (like a dotenv module), you could end up with a segfault.
from frankenphp.
Related Issues (20)
- ./frankenphp.h:4:10: fatal error: Zend/zend_types.h: No such file or directory HOT 5
- @withinboredom use frankenphp builder images ? HOT 4
- Support curl-impersonate HOT 6
- Slow performance with Docker instalation on Windows. HOT 4
- Standalone binaries with Caddy cache-handler HOT 2
- Does frankenphp will cache the code? HOT 5
- Worker mode - objects are not resetted after finish one request HOT 1
- Non 200 responses on 1.2.3 HOT 10
- Question: How do you handle Runner errors? HOT 9
- Laravel HMR not working HOT 8
- should stdin be the request body?
- Segmentation fault /usr/local/bin/frankenphp php-cli ${args[@]} HOT 1
- Strange issues with file-descriptors HOT 2
- worker is not restarting when using xdebug on symfony project HOT 6
- Can't run Caddy with HTTP cache HOT 10
- thrown in /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php HOT 2
- "No Active Transaction" Error After Reconnecting Database in Worker Mode HOT 1
- Question: how to build a standalone frankenphp binary with Caddy cache-handler HOT 3
- curl.cainfo setting from php.ini is being ignored and thus certs aren't available to cURL HOT 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frankenphp.