Home » Php » php – How to place Laravel and use artisan commands?

php – How to place Laravel and use artisan commands?

Posted by: admin July 12, 2020 Leave a comment


I’m trying laravel php framework recently. I’m using Windows 7 and XP (tries to install it on both), XAMPP 1.8.1 and PHP 5.4.7.

So confusing.

  1. In many articles (including laravel’s documentation itself), I meet up many artisan codings.
    What is artisan? I can’t define it myself so clear. I end up with articles that not giving any simple explanation.
    I got commands tutorials like php artisan key:generate and else.
    But I always failed, with this error on Command Prompt : 'php' is not recognized as an internal or external command, operable program or batch file.
    I got solution like “change directory to laravel root”,
    So, I chdir-ed to C:\xampp\htdocs\laravel\public\ but nothing works.

  2. I that right to access my laravel site with browser via localhost/laravel/public/?
    So, if I try to upload it to my public site, I should place those items in my root folder (/)?

How to&Answers:

You are getting the error when calling php.exe because windows command prompt is not tracking your PHP installation. You can fix that by adding it into PATH environment variable:

Go to “My Computer” > “Properties” > “Advanced” > “Environment Variables” > “Path”, add a semicolon (;) at the end and then path to your PHP binaries folder, which in your case is C:\xampp\php

After you restart the command prompt PHP and Artisan should work fine.

As to your second question, “public” folder should be your server’s (or virtual host’s) DocumentRoot. There is no need to expose the whole framework on your web server.


  1. The artisan command has to be parsed through a php interpreter, thats why you call it like php artisan...

    I think, you have to use the php.exe to make it work on Windows.
    Some thing like c:\path\to\php.exe artisan command

  2. Read through the documentation and the Code happy book by Dayle Rees, to understand the public folder and how to setup a Virtual host for your development