Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

baskarks's avatar

can't run php artisan command from vs code terminal

It showing zsh: command not found: php

0 likes
4 replies
LaryAI's avatar
Level 58

The error message "zsh: command not found: php" suggests that the PHP executable is not in the system's PATH variable. To resolve this issue, you can follow these steps:

  1. Open your terminal in VS Code.

  2. Check if PHP is installed on your system by running the following command:

    php -v
    

    If PHP is not installed, you need to install it first. You can refer to the official PHP website for installation instructions.

  3. Once PHP is installed, you need to add it to your system's PATH variable. To do this, open your terminal and run the following command:

    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
    

    This command appends the PHP executable path to the PATH variable and saves it in the .zshrc file.

  4. After running the command, restart your terminal or run the following command to reload the .zshrc file:

    source ~/.zshrc
    
  5. Now, you should be able to run the php command from the VS Code terminal without any issues.

If you're still facing the same issue, make sure that the PHP executable path is correct. You can find the correct path by running the following command:

which php

If the path is different, update the export PATH command in step 3 accordingly.

I hope this helps! Let me know if you have any further questions.

Please or to participate in this conversation.