如何放置 Laravel 并使用工匠命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15682454/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:39:29  来源:igfitidea点击:

How to place Laravel and use artisan commands?

phpframeworkslaravel

提问by HenryJahja

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.

我最近在尝试 laravel php 框架。我使用的是 Windows 7 和 XP(尝试在两者上安装)、XAMPP 1.8.1 和 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:generateand 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 (/)?

  1. 在许多文章(包括 laravel 的文档本身)中,我遇到了许多工匠编码。
    什么是工匠?我自己无法定义这么清楚。我最终得到的文章没有给出任何简单的解释。
    我得到了诸如php artisan key:generate和其他命令教程。
    但我总是失败,在命令提示符上出现这个错误:'php' is not recognized as an internal or external command, operable program or batch file
    我得到了“将目录更改为 laravel 根目录”之类的解决方案,
    因此,我chdir将其更改为 C:\xampp\htdocs\laravel\public\,但没有任何效果。

  2. 我有权通过浏览器访问我的 Laravel 网站localhost/laravel/public/吗?
    那么,如果我尝试将它上传到我的公共站点,我应该将这些项目放在我的根文件夹 (/) 中吗?

回答by pandasauce

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:

调用 php.exe 时出现错误,因为 Windows 命令提示符未跟踪您的 PHP 安装。您可以通过将其添加到 PATH 环境变量中来解决此问题:

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

转到“我的电脑”>“属性”>“高级”>“环境变量”>“路径”,在末尾添加一个分号 (;),然后添加到您的 PHP 二进制文件文件夹的路径,在您的情况下为 C:\ xampp\php

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

重新启动命令提示符后,PHP 和 Artisan 应该可以正常工作。

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.

至于您的第二个问题,“public”文件夹应该是您服务器(或虚拟主机)的 DocumentRoot。无需在您的 Web 服务器上公开整个框架。

回答by Mirko Akov

  1. The artisancommand 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 documentationand the Code happybook by Dayle Rees, to understand the public folder and how to setup a Virtual host for your development

  1. artisan命令必须通过 php 解释器解析,这就是为什么你称之为php artisan...

    我认为,您必须使用 php.exe 才能使其在 Windows 上运行。就像是c:\path\to\php.exe artisan command

  2. 通读文档和Dayle Rees的Code 快乐书,了解公共文件夹以及如何为您的开发设置虚拟主机