Skip to content

Instantly share code, notes, and snippets.

@tuliocll
Last active July 27, 2023 22:25
Show Gist options
  • Save tuliocll/16952e8635eee21e6f3d59083ae6d3b8 to your computer and use it in GitHub Desktop.
Save tuliocll/16952e8635eee21e6f3d59083ae6d3b8 to your computer and use it in GitHub Desktop.
script to create a php executable file from container to your machine, then you can setup the PHP › Validate: Executable Path on vscode.

Starting

  • create a file on /usr/local/bin with name 'php';
nano /usr/local/bin/php
  • paste de following code:
#!/bin/bash
docker exec -i --user=1000:1000 YOUR-CONTAINER-NAME php "$@"

*** Change "YOUR-CONTAINER-NAME".***

  • Give permission to execute:
chmod +x /usr/local/bin/php
  • Now, you can do:
php -v

on your local machine.

  • And your php path is; /usr/local/bin/php

Some issues

permission denied: php

just change the owner of file;

sudo chown $USER:$USER /usr/local/bin/php
Error: No such container: docker_apache

check container name on php file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment