Add symfony abbreviations

This commit is contained in:
Tim 2025-05-16 16:19:45 +02:00
parent 3405ca7784
commit c2c4b4755c
2 changed files with 34 additions and 0 deletions

View File

@ -19,3 +19,8 @@ abbr -a gp git push
if type -q "lazygit"
abbr -a lg lazygit
end
# doctrine
abbr -a scme sc make:entity
abbr -a scmm sc make:migration
abbr -a scdm sc doctrine:migrations:migrate

View File

@ -0,0 +1,29 @@
function sc
# Step 1: Extract PHP version constraint from composer.json
set constraint (jq -r '.require.php // empty' composer.json | grep -oP '\d+\.\d+')
if test -z "$constraint"
echo "No PHP version constraint found in composer.json"
return 1
end
# Step 2: Find matching PHP binaries using find
set match ""
for bin in (find /usr/bin -maxdepth 1 -type f -executable -regex '.*/php[0-9]+\.[0-9]+')
set version_output ($bin -v 2>/dev/null | head -n 1)
set php_version (echo $version_output | grep -oP '\d+\.\d+')
if test "$php_version" = "$constraint"
set match $bin
break
end
end
if test -z "$match"
echo "No installed PHP binary matches constraint $constraint"
return 1
end
# Step 3: Execute Symfony console with matched PHP binary
$match ./bin/console $argv
end