docs: workaround to use PHP in Composer scripts (#610)

* add @php workaround to known-issues.md

* minor tweaks

* switch to sh

Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>

* Update known-issues.md: sh compat

* change language name

---------

Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
This commit is contained in:
flexponsive
2024-02-28 19:17:14 +02:00
committed by GitHub
parent 2c6e201ea6
commit c9d33b981b

View File

@@ -80,7 +80,7 @@ docker run \
dunglas/frankenphp
```
> ![CAUTION]
> [!CAUTION]
>
> Be sure to replace `172.17.0.3` with the IP that will be assigned to your container.
@@ -96,3 +96,27 @@ docker run \
-p 80:80 -p 443:443 -p 443:443/udp \
dunglas/frankenphp
```
## Composer Scripts Referencing `@php`
[Composer scripts](https://getcomposer.org/doc/articles/scripts.md) may want to execute a PHP binary for some tasks, e.g. in [a Laravel project](laravel.md) to run `@php artisan package:discover --ansi`. This [currently fails]((https://github.com/dunglas/frankenphp/issues/483#issuecomment-1899890915)) for two reasons:
* Composer does not know how to call the FrankenPHP binary;
* Composer may add PHP settings using the `-d` flag in the command, which FrankenPHP does not yet support.
As a workaround, we can create a shell script in `/usr/local/bin/php` which strips the unsupported parameters and then calls FrankenPHP:
```sh
#!/bin/sh
# iterate over $@. if the current argument is -d, remove the argument and the next one
for i in "$@"
do
if [ "$i" = "-d" ]; then
shift
shift
fi
done
/usr/local/bin/frankenphp php-cli "$@"
```