A programmer at any time can deploy a local server, like XAMPP or WAMPP, and test the site or web application directly on the local machine.
Nevertheless, in real life conditions, web developers have to develop and support projects that are located remotely, and servers can be even in another country.
The programming environment with support for FTP and SFTP protocols allows PHP programmers and designers to work with files on hosting as easily as with local files on their computers.
In this article, we will consider CodeLobster PHP IDE, learn its built-in FTP client and understand how to configure the FTP connection for your project.
Getting started – global FTP settings
First, we will look at the global settings of the program, launch the IDE and select the “Tools” -> “Preferences” item in the main menu, and in the opened dialog, go to the “FTP, SFTP” section.
Let’s look in more detail at the options which are available for us:
- Automatically overwrite files via FTP/SFTP – when this function is enabled, when you copy a local file to a remote server, if a file with that name already exists, it will automatically be replaced with a new one, without the appearance of a warning dialog.
- Automatically upload files from local folder – if this option is enabled, when you make changes to a file downloaded from a remote machine and then save this file, it will be uploaded to the server and will overwrite the original file, without additional confirmation from the user.
- Open FTP files at startup – if you enable this checkbox, local copies of files with which you worked on FTP in the previous session will be opened again when the program starts.
- Perform update for files from FTP/SFTP at startup – when this option is enabled, FTP will be connected at the program startup and files, with which you worked on FTP before, will be updated.
- ASCII transfer type in Auto mode – this field lists file extensions that contain only text data and can be safely transferred in ASCII mode. We have not to change these values, since all the necessary file types are already specified by default.
For this article, we have checked all the checkboxes, so let’s click “OK” and continue the work.
Creating an FTP/SFTP connection
Select “Tools” -> “FTP/SFTP” in the main menu and click on the <Create New> icon in the “FTP/SFTP Servers” section of the right information panel.
In the dialog box that opens, you should set the value of the “Server Type” field. We have got two alternatives for choosing the protocol:
- FTP or File Transfer Protocol is the most common protocol for transferring files, it works on 21 port, and it can use a secure connection using SSL/TLS.
- SFTP (Secure File Transfer Protocol) or SSH File Transfer Protocol – it has built-in encryption support, it works, as a rule, on 22 port and in most cases it is a faster and more reliable for work with files on a remote system.
Next, we will give an understandable name for the connection and enter it into the “Label” field.
The following two options are “Host” and “Port” – enter the Internet address of the remote computer.
The “User Name” and “Password” fields are filled in according to settings of the FTP account, created for you on the server.
Pay attention to the “Private Key File” field, this option is used only in case of SFTP connection – here you need to specify the path to the file with the private key. This file can be generated for you by the system administrator or by yourself when setting up SSH access.
“Remote Dir” is the folder on the remote machine to which your FTP account is attached, as a rule, by default this is the root directory, but you can select any subfolder.
“Local Dir” – a local folder with source files on your computer, the so-called “mirror” directory.
“File Transfer Type” – there are two basic types of file transfer:
- Binary – in this mode, files are copied byte by byte, and received and transferred files are identical, it is necessary to transfer images, archives and other data in a binary way in order to avoid their damage.
- ASCII – this method is used exclusively for text files, and the newline characters are automatically replaced by those, which accepted in the operating system, for example, “\r\n” for Windows and “\n” for Linux.
- Auto – in the automatic mode, the IDE will act according to the global settings, which we have already discussed above, text files will be transported in ASCII mode, and all the rest – in binary.
Now we need to decide, whether to enable the option “Use passive mode” or not:
- In active mode, the client computer not only connects to the server, but also accepts incoming connections from it.
- Passive mode implies only outgoing connections from the client machine, so if you are behind a firewall or behind a NAT router and have not got an external IP, you need to check the “Use passive mode” checkbox.
And the last option “Connection Type” – this field will be used only if we configure the connection via FTP protocol, in order to enable additional protection with use of encryption.
Typically, connection protection with explicit SSL and explicit TLS is supported by almost all servers, while the use of implicit SSL requires an additional port, most often 990, which can be closed by the system administrator of your server for security reasons.
Here you can select explicit SSL and do not worry, the username and password, in any case, are sent in encrypted form.
Click “OK” to save all settings.
Now you can view the structure of the files and folders of the remote directory, and also download any file for editing by double click on it.
Adding the FTP connection to the project in CodeLobster
In the “Project” tab, right-click on the project and select “Modify” from the context menu.
At the bottom of the dialog box under “FTP/SFTP” section, from the drop-down list select the connection that you have created for use in this project.
Also check the option “Upload files on save” and click “OK”.
In this example, we connected to the installed WordPress, to the folder “themes”. Now, to download the source files, click on the project and select “Download” from the context menu.
In the dialog that appears, select the files and directories that will be downloaded.
Confirm your choice by clicking “OK” and wait for the download finish. After that, you can make corrections in the source files, they will be automatically updated on the server after saving.
We can now add our own theme by placing the folder in the project directory, then click the “Reload Project” button to update the project structure.
Press “Upload” from the context menu, and select this folder in the dialog box. After clicking “OK” our new theme will be uploaded and will be available in the WordPress admin section.
Let’s sum up
While reading this tutorial, you learned all the features of setting up FTP connections. Built-in FTP client of CodeLobster IDE allows you to work transparently with files on the hosting.
Using these advantages, we can make any changes in the source code of our sites and web applications, and the IDE will take care of the synchronization and relevance of versions of files.