Welcome to the second lesson on “Built to success – PHP developer”.
After we created the infrastructure, we need to set a work environment, which is the IDE with it we will develop our PHP scripts and projects.
There are many IDEs out there, and there are great ones and lousy ones like in any other product or service. But in this guide i am giving you my own settings that i found most suitable for development fast and well performed.
Because eclipse was originally created for JAVA developers, the main structure of Eclipse is based on JAVA. For completing this chapter, you must first install the JRE on you local computer.
The Java Runtime Environment (JRE), also known as Java Runtime, is part of the Java Development Kit (JDK), a set of programming tools for developing Java applications.
I will not start talking about it here, but this installation is mandatory for our working environment stability.
If you want to read more about JRE, and what is it, feel free to go to Oracle website and study.It is a “Nice-to-have” in our case, but hey, i won’t stop you from learning…
We will not start to configure JVM (JAVA Virtual Machine) and other stuff regarding the JAVA environment issues, because we are PHP developers…Focus is everything!
Originally created for JAVA developers, the eclipse IDE is an open source project, and on it the open community created the PDT, that delivers a PHP Integrated Development Environment framework for the Eclipse platform.
What makes it so good working environment, you ask?
Well, a good programmer know that he/she don’t have to remember all by hard, this is why they invented the Content Assist, that can suggest auto complete methods and language keywords.
Even Zend, the mother of PHP, refer its developers to work with Eclipse IDE. They adopted the environment because they also discovered its benefits.
Zend is the most respected company in the online PHP world, and it is contributing to the growth and efficiency of the language.
Zend created the Zend studio platform, that is the complete working environment for PHP developers, and it is actually the best studio i worked with, but the price is too high and the licensing is too strict for me, i prefer my working environment to be affordable and easy to maintenance.
So, i will continue with Zend PDT, the free IDE with all the comfort of Zend support…
So, i hope by now you downloaded the Eclipse IDE and it is installed on your computer (Notice:Usually, the installation is unzipping the downloaded zip file to a folder under your root directory, like “c:\eclipse” or something like that).
Create a shortcut on your desktop to the IDE and double-click it…
You will get a pop-up window called “Workspace Launcher”. Each instance of Eclipse IDE have to be related to a workspace, where the projects are located in your hard drive. All projects are open under this workspace, and you can have multiple workspaces and you can switch between workspaces in the IDE.
We talked about it in the first chapter, our workspace will be our created Dropbox folder, and our localhost will look at our Dropbox folder as our document root. Do not get confused, we are talking about a folder for our IDE, where it will save our workspace preferences, and not our sources.
The workspace path can be on your local drive, or you can point it to be the same Dropbox folder you created. Why is it better to point to local folder and not the Dropbox folder? Simple reason, actually.Your workspece is created under the path you decide and create a “.metadata” folder with the workspace preferences. In older versions, the metadata included some full paths to JAVA_HOME (No need to learn it yet) and other libraries.
The Dropbox folder path is changing, in my case, i have my laptop, there it is on “c:\”, but i have my work computer, there i save my private Dropbox folder under “c:\Ofer”. So, it is kinda annoying when the Eclipse IDE crashes on start because it does not recognize the workspace’s folder on my machine.
Another reason is separated resources and projects, when a developer have several Eclipse instances for different projects/clients. This requires a different workspace folders, because if you make the same folder for all instances, you will end up with same configurations and eventually the same projects in your workspace.
Wrap it all up
So, we have an eclipse to create our scripts and projects, and we already have a web server and database configured and running (Remember Chapter #1?).
At this point you can get to know a little about working with eclipse by creating new Project.
- Open Eclipse and open a new project.
- A wizard will open to select what kind of project you want to create. Choose “Local PHP Project” and click “Next”.
- Name your project “Temp” and hold. Look at the “Location” field. As default, it will point to your workspace folder as where to save your resources. You want the project will be saved in your Dropbox folder. This is where you should change it to the path to your Dropbox folder.
- A new project will appear to your left sidebar (AKA “The Project Navigator”). In it you can find a project skeleton that includes all the PHP resources available for your convenience as a developer and an empty “index.php” script . Just add there “Echo ‘hello world!’;”.
- Launch XAMPP console and start Apache (The web server, as we know by now).
Remember, your projects is now under your Dropbox folder, so, if you worked it through Chapter #1, when launching the server and go to “http://localhost/Temp” in your browser, you will see the miracle happens and the web page will show you “Hello world!” as its content.
This is it for now. You made it through the second lesson and came closer to becoming a great PHP developer with kick-ass working environment…
See you at Chapter #3…