1 <?xml version="1.0" encoding="utf-8"?>
2 <!-- jEdit buffer-local properties: -->
3 <!-- :indentSize=2:noTabs=true: -->
4 <!-- :xml.root=docmaster.xml: -->
9 So, when finished with setting up a workspace, we can go for our first PHP project. This is a necessary step, because a workspace alone will not help. We also need to set up a project within a workspace. As we want to work with PHP we will create a PHP project.
12 <sect1 id="sec.project_creation">
13 <title>Create a project</title>
15 For creating a project klick on
17 <guimenu>File</guimenu>
18 <guisubmenu>New</guisubmenu>
19 <guisubmenu>Project...</guisubmenu>
20 </menuchoice> (see <xref linkend="fig.create_new_project"/>). This will open a project creation wizard dialog (see <xref linkend="fig.select_a_wizard"/>). Now click on <quote>PHP Project</quote> under the PHP tree entry as you can see in <xref linkend="fig.php_project_name"/>. When you click on <guibutton>Next ></guibutton> the PHP Project dialog will be shown, where you can input a name for your new PHP Project. In our example we choose the name <quote>MyFirstPHPProject</quote>. Now, just click on <guibutton>Finish</guibutton>, and your project will be created. Now you should see your project within the Navigator pane (see x
23 <figure id="fig.create_new_project">
24 <title>Create a new projec</title>
26 <imageobject role="html">
27 <imagedata align="center" fileref="img/en/xo-002/create_new_project_1.png" format="PNG"/>
29 <imageobject role="fo">
30 <imagedata align="center" fileref="img/en/xo-002/create_new_project_1.png" format="PNG" width="12cm"/>
36 <figure id="fig.select_a_wizard">
37 <title>Select a wizard</title>
39 <imageobject role="html">
40 <imagedata align="center" fileref="img/en/xo-002/create_new_project_2.png" format="PNG"/>
42 <imageobject role="fo">
43 <imagedata align="center" fileref="img/en/xo-002/create_new_project_2.png" format="PNG" width="12cm"/>
49 <figure id="fig.php_project_name">
50 <title>Name your PHP Project</title>
52 <imageobject role="html">
53 <imagedata align="center" fileref="img/en/xo-002/create_new_project_3.png" format="PNG"/>
55 <imageobject role="fo">
56 <imagedata align="center" fileref="img/en/xo-002/create_new_project_3.png" format="PNG" width="12cm"/>
62 <figure id="fig.php_project">
63 <title>The new PHP Project within the Navigator pane</title>
65 <imageobject role="html">
66 <imagedata align="center" fileref="img/en/xo-002/create_new_project_4.png" format="PNG"/>
68 <imageobject role="fo">
69 <imagedata align="center" fileref="img/en/xo-002/create_new_project_4.png" format="PNG" width="8cm"/>
76 <sect1 id="sec.add_files_to_projects">
77 <title>Adding files to the project</title>
79 Now, as we have created a PHP project we need some PHP files in it. The following sections will explain the different aspects about adding a file to your project.
82 <sect2 id="sec.add_file_simple">
83 <title>Adding a simple file</title>
85 Per se, there are two different methods of adding a file to your project. Both are available through the <quote>File</quote> menu.
89 The first method is to add a <quote>simple</quote> file to your project by clicking on <menuchoice>
90 <guimenu>File</guimenu>
91 <guisubmenu>New</guisubmenu>
92 <guisubmenu>File</guisubmenu>
93 </menuchoice> (see <xref linkend="fig.add_file_menu_file"/>). This will open the appropriate <quote>New File</quote> dialog. Input the name for that file (with the extension <quote>php</quote>), and click on <guibutton>Finish</guibutton>. This will add the new file to the <quote>Navigator</quote> pane, and opens an editor view.
97 <figure id="fig.add_file_menu_file">
98 <title>Adding a simple file to the project</title>
100 <imageobject role="html">
101 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_1.png" format="PNG"/>
103 <imageobject role="fo">
104 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_1.png" format="PNG" width="10cm"/>
110 <figure id="fig.new_file_dialog">
111 <title>The <emphasis>New File</emphasis> Dialog</title>
113 <imageobject role="html">
114 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_2.png" format="PNG"/>
116 <imageobject role="fo">
117 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_2.png" format="PNG" width="12cm"/>
123 <figure id="fig.new_file_in_navigator">
124 <title>The new file in the <emphasis>Navigator</emphasis> view</title>
126 <imageobject role="html">
127 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_3.png" format="PNG"/>
129 <imageobject role="fo">
130 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_3.png" format="PNG" width="6cm"/>
136 <figure id="fig.new_file_in_editor">
137 <title>The new file opened in PHP editor</title>
139 <imageobject role="html">
140 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_4.png" format="PNG"/>
142 <imageobject role="fo">
143 <imagedata align="center" fileref="img/en/xo-002/add_file_to_project_4.png" format="PNG" width="12cm"/>
150 <sect2 id="sec.add_file_php">
151 <title>Add a PHP file to the project</title>
153 The second method of adding a PHP file to your project is through
155 <guimenu>File</guimenu>
156 <guisubmenu>New</guisubmenu>
157 <guisubmenu>PHP File</guisubmenu>
158 </menuchoice> (see <xref linkend="fig.add_file_menu_phpfile"/>). This will open a <quote>New PHP file</quote> dialog with a default File name entry of <quote>file.php</quote> (see <xref linkend="fig.new_phpfile_dialog"/>). We change the file name to <filename>mySecondFile.php</filename> (see <xref linkend="fig.new_phpfile_dialog_change_name"/>) and click on <guibutton>Finish</guibutton>.
163 This also will add a PHP file to your project as you can see in the <emphasis>Navigator</emphasis> view (see <xref linkend="fig.new_phpfile_in_navigator"/>), and it also opens this new file within the PHP editor (see <xref linkend="fig.new_phpfile_in_navigator"/>) as it was done in <xref linkend="sec.add_file_simple"/>.
167 But there is obviously a difference. In opposite to <filename>myFirstFile.php</filename> which is a real empty file, <filename>mySecondFile.php</filename> has some text in it (see <xref linkend="fig.new_phpfile_in_editor"/>). The file we just created is filled with a <quote>template</quote>. <!-- todo: link to the template config section once this is written -->
171 The difference is only at creation time. The files themselfs, when created, do not differ in any sense.
174 <para id="para.absolute_file_path">
175 When we look at file system level, the absolute path of the files we just created are in respect of the current workspace, in general: <filename>workspace_path/project/file.php</filename>. For example if you have accepted the default workspace when you started eclipse (and your username is Robert):
179 <emphasis>myFirstFile.php</emphasis>: <filename>C:/Dokuments and Settings/Robert/workspace/MyFirstPHPProject/myFirstFile.php</filename>
184 <emphasis>mySecondFile.php</emphasis>: <filename>C:/Dokuments and Settings/Robert/workspace/MyFirstPHPProject/mySecondFile.php</filename>
192 The importance of knowing the absolute path is when the web server comes into account. As you want to test the program you have written, the web server needs access to your PHP files. This could be accomplished either when you set your web server's document root to point at your current workspace, or set your workspace to the currect web server's document root. <!-- todo point to the xammp installation section -->
196 But there is a third way, which will make things easier, as you can leave the workspace wherever you want, and also do not need to change the web server's document root.
200 <figure id="fig.add_file_menu_phpfile">
201 <title>Adding a PHP file to the project</title>
203 <imageobject role="html">
204 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_1.png" format="PNG"/>
206 <imageobject role="fo">
207 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_1.png" format="PNG" width="12cm"/>
213 <figure id="fig.new_phpfile_dialog">
214 <title>The <emphasis>New PHP file</emphasis>dialog</title>
216 <imageobject role="html">
217 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_2.png" format="PNG"/>
219 <imageobject role="fo">
220 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_2.png" format="PNG" width="12cm"/>
226 <figure id="fig.new_phpfile_dialog_change_name">
227 <title>Change the name to what you like</title>
229 <imageobject role="html">
230 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_3.png" format="PNG"/>
232 <imageobject role="fo">
233 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_3.png" format="PNG" width="12cm"/>
239 <figure id="fig.new_phpfile_in_navigator">
240 <title>The new PHP file in the &navview;</title>
242 <imageobject role="html">
243 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_4.png" format="PNG"/>
245 <imageobject role="fo">
246 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_4.png" format="PNG" width="6cm"/>
252 <figure id="fig.new_phpfile_in_editor">
253 <title>The new PHP file opened in PHP editor</title>
255 <imageobject role="html">
256 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_5.png" format="PNG"/>
258 <imageobject role="fo">
259 <imagedata align="center" fileref="img/en/xo-002/add_phpfile_to_project_5.png" format="PNG" width="12cm"/>
266 <sect2 id="sec.add_file_existing">
267 <title>Add existing files to the project</title>
269 There are generally two ways to add files, which already exists anywhere on your file system, to a project<footnote><para>Every file which you want to open and handle with &phpeclipse; needs to be within a project.</para></footnote>.
272 <sect3 id="sec.add_file_by_import">
273 <title>Import Files</title>
275 You can import files from anywhere on your local machine by eclipse itself via <menuchoice>
276 <guimenu>File</guimenu>
277 <guisubmenu>Import...</guisubmenu>
278 </menuchoice> (see <xref linkend="fig.file_import_1"/>) or by manually copying the files via the file system into your project folder (see <xref linkend="para.absolute_file_path"/>). In fact the way via <emphasis>Import...</emphasis> is more convenient.
282 But this method only makes a copy of existing files, and doesn't disburden you from changing the web server's &docroot;. Especially if the files you have currently imported to your workspace are located on your current web server's &docroot;.
286 In this case it would be easier to set the workspace to the current web server's &docroot;, or do as described in the following section <xref linkend="sec.add_file_by_linking"/>.
290 <figure id="fig.file_import_1">
291 <title>Import Files into Project</title>
293 <imageobject role="html">
294 <imagedata align="center" fileref="img/en/xo-002/file_import_1.png" format="PNG"/>
296 <imageobject role="fo">
297 <imagedata align="center" fileref="img/en/xo-002/file_import_1.png" format="PNG" width="10cm"/>
305 <sect3 id="sec.add_file_by_linking">
306 <title>Link Folders</title>
308 Indeed, this should be the best option if you want to have independence between a eclipse workspace and the web server's &docroot;.
315 Create a new project (e.g. <quote>MyLinkedPHPProject</quote>).
320 Right click on this project within the <quote>Navigator View</quote> to open the context menu and click on.
322 <guimenu>New</guimenu>
323 <guisubmenu>Folder</guisubmenu>
324 </menuchoice> (see <xref linkend="fig.linked_project_1"/>).
329 Click on <guibutton>Advanced >></guibutton> and enable <guibutton>Link to folder in the file system</guibutton> (see <xref linkend="fig.linked_project_2"/>).
334 Now you can either manually enter the path or browse to the folder which is to link. In the example we input <filename class="directory">C:\Program Files\apachefriends\xampp\htdocs</filename>, and click on <guibutton>Finish</guibutton>. The &navview; should now look like (see <xref linkend="fig.linked_project_3"/>).
339 At last we have to set the correct &docroot; (which is <filename class="directory">C:\Program Files\apachefriends\xampp\htdocs</filename>) within the project properties as shown in <xref linkend="fig.linked_project_4"/>
346 <figure id="fig.linked_project_1">
347 <title>Add a Folder to Project</title>
349 <imageobject role="html">
350 <imagedata align="center" fileref="img/en/xo-002/linked_project_1.png" format="PNG"/>
352 <imageobject role="fo">
353 <imagedata align="center" fileref="img/en/xo-002/linked_project_1.png" format="PNG" width="8cm"/>
359 <figure id="fig.linked_project_2">
360 <title>Create a Link Folder</title>
362 <imageobject role="html">
363 <imagedata align="center" fileref="img/en/xo-002/linked_project_2.png" format="PNG"/>
365 <imageobject role="fo">
366 <imagedata align="center" fileref="img/en/xo-002/linked_project_2.png" format="PNG" width="12cm"/>
372 <figure id="fig.linked_project_3">
373 <title>The &navview; with the new Project</title>
375 <imageobject role="html">
376 <imagedata align="center" fileref="img/en/xo-002/linked_project_3.png" format="PNG"/>
378 <imageobject role="fo">
379 <imagedata align="center" fileref="img/en/xo-002/linked_project_3.png" format="PNG" width="4cm"/>
385 <figure id="fig.linked_project_4">
386 <title>Change the Project's DocumentRoot Setting</title>
388 <imageobject role="html">
389 <imagedata align="center" fileref="img/en/xo-002/linked_project_4.png" format="PNG"/>
391 <imageobject role="fo">
392 <imagedata align="center" fileref="img/en/xo-002/linked_project_4.png" format="PNG" width="12cm"/>