[rps-include post=6522]
[rps-include post = 6522]
While developing Php applications using IDE will provide a lot of useful feature.
在使用IDE开发Php应用程序时,将提供许多有用的功能。
创建Hello World项目 (Create Hello World Project)
We have installed required software properly in previous steps. As a first step we will run Eclipse
. We can start eclipse in different ways. In this situation we prefer starting it from Program menu like below.
在前面的步骤中,我们已经正确安装了必需的软件。 第一步,我们将运行Eclipse
。 我们可以用不同的方式开始Eclipse。 在这种情况下,我们更喜欢从下面的“程序”菜单中启动它。
![](https://i-blog.csdnimg.cn/blog_migrate/8782e05e337f700cfb488097887682f1.png)
Another ways to start eclipse is running eclipse
command in the terminal like below.
启动eclipse的另一种方法是在终端中运行eclipse
命令,如下所示。
$ eclipse
We will see Eclipse Launcher
where we will set projects home directory.
我们将看到Eclipse Launcher
,将在其中设置项目的主目录。
![](https://i-blog.csdnimg.cn/blog_migrate/ec299d9376bae7d076f6486599f35fc8.png)
We click OK
and resume
我们单击OK
然后继续
创建PHP项目(Create Php Project)
We will create a Php project in eclipse IDE with the following screen. We will click File
-> New
-> Project
我们将使用以下屏幕在eclipse IDE中创建一个Php项目。 我们将单击File
-> New
-> Project
![Create Php Project](https://i-blog.csdnimg.cn/blog_migrate/903159cf3cec5f1dc8c856ca94170749.png)
Then we will see following screen where we select PHP Project
然后,我们将看到以下屏幕,我们在其中选择了PHP Project
![](https://i-blog.csdnimg.cn/blog_migrate/dd7527fc9e4476abd256cbd69ce74d1f.png)
Then we will set name of the project and click Finish
. We can also select Next
where we will specify detailed options of the Php project. In this form we can see that project path where it will be stored.
然后,我们将设置项目的名称,然后单击Finish
。 我们还可以选择Next
,在这里我们将指定Php项目的详细选项。 在此表单中,我们可以看到将要存储该项目的路径。
![](https://i-blog.csdnimg.cn/blog_migrate/a16a39a2223aef2ccea275899005d958.png)
Simply click Yes
to setup screen properly for Php project
只需单击“ Yes
即可为Php项目正确设置屏幕
![](https://i-blog.csdnimg.cn/blog_migrate/66234d2762b6ce0f878c52b6b18bc884.png)
添加新PHP文件(Add New Php File)
We have created our project named Hello World
. We need to add some file to the project. We right click on our project on the project pane and select New
-> PHP File
我们创建了名为Hello World
的项目。 我们需要向项目添加一些文件。 我们在项目窗格上右键单击我们的项目,然后选择New
> PHP File
![Add New Php File](https://i-blog.csdnimg.cn/blog_migrate/4838f394ce32a96730b3341e4f8ba274.png)
We will set the file name as index.php
which is default most of the Php projects.
我们将文件名设置为index.php
,这是大多数Php项目的默认设置。
![Add New Php File](https://i-blog.csdnimg.cn/blog_migrate/0463217b6351d905c2e9e253665a6bbe.png)
配置PHP解释器和可执行文件(Configure Php Interpreter and Executable)
We need to configure the Php interpreter to run applications in Eclipse. We will click the Eclipse main menu Window
-> Preferences
and get following screen. From Here we will select Php Executable
and click Add
我们需要配置Php解释器以在Eclipse中运行应用程序。 我们将单击Eclipse主菜单Window
-> Preferences
,然后显示以下屏幕。 从这里我们将选择Php Executable
,然后单击Add
![Configure Php Interpreter and Executable](https://i-blog.csdnimg.cn/blog_migrate/cad1262bf52da2d9f24ab6667ae61194.png)
We will set new interpreter’s name as php
and path as /bin/php
which is default in Linux. Executable path can be found where Php is installed in other operating systems too.
我们将新解释器的名称设置为php
,将路径设置为/bin/php
,这在Linux中是默认设置。 在其他操作系统中安装Php的位置也可以找到可执行路径。
![Configure Php Interpreter and Executable](https://i-blog.csdnimg.cn/blog_migrate/5d645ed0684357157e6a2d3dac30076b.png)
运行PHP项目(Run Php Project)
Now everything is ok we can run our Hello World applications after putting following code to the index.php
and click Run
from menu.
现在一切正常,在将以下代码放入index.php
并单击Run
从菜单Run
之后,我们可以运行Hello World应用程序。
![Run Php Project](https://i-blog.csdnimg.cn/blog_migrate/a2ba6c55a5cc589a718baafcf89b3dd3.png)
This will print Hello World
in the console of Eclipse.
这将在Eclipse的控制台中打印Hello World
。
![Run Php Project](https://i-blog.csdnimg.cn/blog_migrate/bb843b5d84f20e65cb2444c8387d1056.png)
[rps-include post=6522]
[rps-include post = 6522]
翻译自: https://www.poftut.com/php-create-hello-world-project-eclipse/