Conversation
|
As expected mac/arm currently fails the sanity check https://github.com/dunglas/frankenphp/actions/runs/14283719364/job/40036289078?pr=1482 |
|
I wonder if it would make sense to just enter the cli sapi if argv[0] is Edit: Or actually, if it is just |
|
Yeah I thought of that too, though I'm not sure what would be the best way to do this, maybe by somehow exposing the main function directly in php-src? |
| Executes a PHP script similarly to the CLI SAPI.`, | ||
| CobraFunc: func(cmd *cobra.Command) { | ||
| cmd.DisableFlagParsing = true | ||
| cmd.Flags().StringP("code", "r", "", "Execute PHP code directly without <php ... ?> tags") |
|
Nvm mac sanity check was failing due to a typo 😅 |
Or just copy-paste, er, vendor it. |
|
@AlliBalliBaba any chance you can verify that the |
|
Sadly, I don't have a mac either, but I can try asking a colleague tomorrow. |
|
Hey! It’s a bit of a ninja patchwork, but it gets the job done for now 😄 #!/usr/bin/env bash
args=("$@")
index=0
filename=
for i in "$@"
do
if [ "$i" == "-d" ]; then
unset 'args[$index]'
unset 'args[$index+1]'
fi
if [ "$i" == "-r" ]; then
filename=$(cat /proc/sys/kernel/random/uuid).temp.php
echo "<?php ${args[$((index+1))]} ?>" | tee "$filename" > /dev/null
unset 'args[$index]'
unset 'args[$index+1]'
args=("$filename")
break
fi
index=$((index+1))
done
/usr/bin/frankenphp php-cli ${args[@]}
if [ -n "$filename" ]; then
rm -f "$filename"
echo
fi
Thank you @Lolozendev for your help |
|
Can we merge this one @AlliBalliBaba? |
|
Yeah I think so 👍 . Just forwarding the input to php-cli is something for a different PR |
This PR adds the -r option for directly executing code with php-cli
frankenphp php-cli -r "echo 'Hello world'";This can be useful in some situations where PHP is not directly installed on the system, but some library setup code uses the
-rflagThe main reason I'm adding this option though is to have another sanity check for the static binaries after compilation.