How to create Eclipse project from existing git repo - php

I have an existing project utilizing git and have just installed eclipse along with egit. I pointed to the git repository with egit and can see all my files, my existing branches and can switch between branches.
When I open a file from the view of the git repository it does not seem to recognize that it is a php file, doesn't show me the classes within it and doesn't do code completion. If I just drag a file in from explorer it at least recognizes that file as php, but doesn't understand the project well enough to show me code completion from installed libraries. I think I need to configure eclipse to understand the projects home directory, but am a bit lost. Any help would be appreciated.

Your answer may fall within this guide to change the "nature" of your project. It's at least worth exploring. I will be attempting to do the exact thing you've described some time this week so hopefully it will work. The wiki doc also suggests that certain "natures" may conflict with each other but hopefully that won't be the case here. Link -->
http://wiki.eclipse.org/IRC_FAQ#How_do_I_manually_assign_a_project_Nature_or_BuildCommand.3F
After just trying to reproduce your steps I am having the exact same experience. I believe this may be "expected" behavior. For clarity, when I open a php file from the "PHP Explorer" view everything seems to work fine but when I open a php file from the "Git Repositories" view Eclipse treats it as a text file (no code highlighting etc.). I suggest that you work from the PHP Explorer view and leave the Git Repositories view open separately only to watch/monitor the repository not as a working view of files to edit and what not.

You need to open it as a PHP Project from existing source (GIT working folder) then share the project with Git, ie, right-click on the project, go to Team > Share project, click on Git.
See http://www.youtube.com/watch?v=-Zba8iAnLms for a demo.

Did you install the pdt plugin in eclipse? It should recognize any .php file opened. Shouldn't matter where it's located.

Related

Eclipse for PHP, how to make it to include downloaded files in project?

first of all I explain the reason why I try to do it.
I tried many editors/IDEs which could provide convenient syntax and variables check. Eclipse did the best.
But it works correctly only if I work with its project, otherwise there are a lot of glitches and no correct support of syntax suggestion/auto-complete.
I set my FTP client to download files into project's folder, but Eclipse does not recognize them as a part of this project so I still don't have it's full support. If I create PHP files with Eclipse in the same folder it works just fine. Is there a way to make read all PHP files in project folder as parts of a project?
Or, if you can suggest IDE which performs syntax check/auto-complete tasks as Eclipse does please do, I check if I tried it. I can't include all CMS into project, because it is Bitrix, it can kill any IDE which can try to chew it, so I just need a reliable tool which could work as code validation of currently edited script. The perfect tool could just be set for PHP 5.6/7.1 for example and perform validation based on language rules.
If you are trying to get Eclipse php support for randomly downloaded files you can set your FTP client to download that files in project's folder. Then you open Project Explorer in Eclipse, press refresh button to get actual folders/files list, find you file in there and open it by that project explorer. That makes Eclipse to consider that file as a part of your project so auto-complete and validation works fine. Other ways of opening it does not count.

NetBeans - AngularJS project within a PHP project, all using the same git repo

I just inherited an application that is Magento with an Angular frontend. The Angular code is wholly contained within a single subdirectory of the Magento application. I can set up a PHP project in NetBeans and I get PHP autocomplete and other goodies, but no love for the Angular .js files. The goal is to have both PHP development goodies and angular development goodies. All the code is in one git repo (else this would not be an issue, I could just have two separate directory trees).
NetBeans will not let you create a project within a project. I've tried stitching the codebases together with a symlink both directions, and either git doesn't like it (refusing to treat the symlink as a directory), or NetBeans doesn't like it (still seeing the Angular files as residing with the already existent PHP project).
Anybody have any ideas? Changing the repo structure (like using a git submodule) is not an option currently.
You cannot make "a project inside a project", that is correct. :)
In your project, check if in Remote Files (next to Source Files in the Projects tab) you have the necessary JS files. If not, you have to link to them in your project.
Also what version of Netbeans are you using? It should work in the latest ones (8.1 and up) but may not work in earlier (8.0 and below).

my html file in htdocs to open in netbeans ide

how can i open my project/files in htdocs in netbeans IDE i tried looking for tutorial but there is none..i tried import but when i do it it does not have file to open or i tried open but i did not open as well..
I downloaded netbeans here i got the last one with many checks.
i also downloaded this but i cant import it as well.
any suggestions are accepted
GO to
File>New Project>PHP>PHP Application With Existing Sources.
The browse to htdocs and select your project folder.Optionally you can set the url for your application or you can just finish it there.
Did you follow this path when opening ?
Go to
File->New Project->Select a Category->Pick one from Projects.
Let's say PHP Application with Exciting Sources. Then select your project from the next window.
Hope this helps.
Cheers!
If you are wanting to work on a live site via FTP in NetBeans I would suggest using this NetBeans plugin:
Link:- http://plugins.netbeans.org/plugin/39197/ftpsitedeployer
If you are working with local files:
File>New Project> PHP/HTML5 > PHP/HTML Application With Existing Sources.
If you are working with a GIT type repo:
Create a proejct folder then initialize the repo and then pull from the repo you can also ADD/Commit/Push/Push via netbeans IDE toolbar.

NetBeans + FTP + BitBucket

I know this has been asked before, but I couldn't get the answer I needed.
Currently I'm developing an website using PHP and was using Notepad++ before, and it all worked well because I'm developing with a co-worker so we both keep on changing different files on the FTP.
Switched to NetBeans. All went ok, pulled the entire website via FTP to my local computer and everytime I edited a file and saved it uploaded to the FTP. But, there is a problem. If my colleague updates a file, it doesn't update on my local folder. So, I thought: "Let's try versioning".
Created a team on bitbucket, created a repository. All went ok.
But now, I'm in a struggle to get everything up and running on both NetBeans (mine and colleague's) so that my colleague is editing a file on his NetBeans and constantly saving so that it gets saved on FTP and only when he stops working on that file push it to BitBucket so that I can pull after.
Suggestions?
About setting up your work environment :
In order to set up your bitbucket repository and local clone, go read this link (official doc).
You will need to repeat the cloning part once for each PC (e.g : once on yours, once on your colleague's).
Read the account management part to see how you can tag your actions with your account, and your colleague's action with his own account.
Start using your git workflow ; when you are tired of always typing your password to upload modifications to your bitbucket account, take the time to read the ssh keys setup part - read carefully, you will need to execute the procedure once for you and once for your colleague.
Using your local git repository with Netbeans is pretty straightforward :
From netbeans, run the File > New Project ... command (default: Ctrl+Shift+N),
Select PHP application with Existing Sources and click Next >,
For the Sources Folder: line, select your local git directory,
Fill the remaining fields, and if you want the last Run configuration screen, then click Finish.
After the project is created in netbeans, you can modify the Run configuration part by right clicking on the project's icon, selecting the Properties menu entry, and going to the Run configuration item.
About solving your workflow "problem" :
Your current FTP workflow can lead you to blindly squash your colleague's modifications (when uploading), or have your colleague's modification blindly squash your own local modifications (when downloading). This is bad, and you will generally notice it only after the bad stuff happened - too late.
Correctly using version control allows you to be warned when this could potentially happen, and to keep an almost infinite undo stack on the modifications of the project's files. The cost, however, is that both of you will have to add several actions in your day to day workflow - some choices can not be made automatically.
You may find it cumbersome in the beginning, but it really pays off, and quite quickly - we're talking big bucks here. So use it and learn.
On top of using Ctrl+S to save your modifications on disk, you and your colleague will need to integrate 3 extra commands in your daily work :
Save your work to your local repository (git add / git commit)
Download the latest modifications shared by your colleague (git pull)
Upload your work to the central repository (git push)
You can access these commands :
from a terminal,
from a GUI frontend : you can try TortoiseGit for windows, or gitk for linux,
from Netbeans :
in the contextual menu of the files/folders in the project tree (right click on the item, there is a "Git" entry),
using the Team > Git > ... menu
Since you provided a git tag, I'll describe what's to do for Git.
set up a remote bare repo on a server that you both could access (BitBucket in your case):
http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server
you both clone that remote repo to your local machines:
http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository
each of you works in her part of the application. When one is done, publish the work to the server:
http://git-scm.com/book/en/Git-Basics-Working-with-Remotes#Pushing-to-Your-Remotes
By now, the remote server holds the version that was just pushed. What's missing is the deployment of the website. This has been discussed here:
Using GIT to deploy website
Doing so, you will decouple your work from that of your colleague since you're not changing files over FTP all the time. You work in your part, your partner works on her part. The work is getting merged and then a new version of the website gets published.
You can create git or Mercurial repositories in Atlassian Bitbucket (http://bitbucket.org). If your team is new to version control, i advise you no forks in your first project.
The easy solution ins to use Atlassian SourceTree (http://www.sourcetreeapp.com/) to control your code since there is a bug in netbeans. See NetBeans + Git on BitBucket
You need to create a new repository in bitbucket. I assume you already configure the ssh2 keys. Using Git you need:
git clone --bare --shared php_project php_project.git
git commit
Using Mercurial you need:
hg init
hg commit
Good luck / boa sorte
Pedro

Eclipse PDT + Code completion not working at all

I wanted to start a new Zend project, and currently I'm facing some issues regarding Eclipse PDT... My problem is, that the code completion in Eclipse for PHP does not work at all.
I tried a lot of different tutorials etc, for example making a new project and import the files; making a new workspace and import projects there; almost every possible combination of buildpath settings and library imports; deleting several files in .metadata (you will find lots of tutorials like this if you google for it), but nothing worked.
[Edit] Also the PHPNature is set (thanks to tranisstor):
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
(It also does not work if there is only the PHPNature set, and no other in addition)
[/Edit]
The problem in detail: I made a new Zend project, and tried to start coding in the IndexController.indexAction(). First thing I did: I typed in $this->, but no code completion came... I thought maybe I would need to add the Zend library, which I did. When I click into the Zend_Controller_Action in class IndexController extends Zend_Controller_Action I can see the documentation of Zend_Controller_Action, I also can press F3 and the corrosponding file will appear... Which means, Zend is successfully added as library.
I also tried Ctrl + Space, but just nothing happens. By the way, the standard PHP functions like isset() also won't show up in code completion
Does anybody have a idea how to fix this? I am using Eclipse Juno, with Eclipse PDT 3, and Zend Framework 1.x (don't know exactly, but it's not ZF2 and it works well if I open http://localhost.
I'm grateful for any help
I had the same problem when upgrading eclipse to Kepler. The following worked for me:
Remove files under workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2
The reason was that the workspace old DLTK index is not compliant with the new version and needs to be rebuilt. Start eclipse and the DLTK index will be regenerated.
Code completion worked for me again after that.
i feel you, i had to deal with this quite often too, and the mentioned .project file modifications didn't do the trick.
What helped me was this:
edit the .buildpath file and add
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
My complete build file might then look sth. like this:
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>
i also added my folder which contains the php files to the build and include path (RMB over the project), but i don't think that it was necessary, the most important part was the modification of the .buildpath file for me.
Hope that helps...
The standard solution (at Eclipse forum) didn't work for me. What fixed this problem was the following:
going to Properties for my project (right click on it in PHP Explorer, then Properties),
select PHP Build Path/"Add Folder"
in there I ticked/selected my project's main folder.
It took a while while the DLTK database was refreshed (it could block your machine for a couple of minutes, be patient) but then it started working great.
Remove workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/*. It should works.
Hope it helps!
I think this is the best way:
Right click on you project in the project Explorer » Configure » Add PHP support...
Maybe you need to edit your .project-File and add a "PHP nature" tag. See this thread for more information. I once had this issue after putting a project under svn version control and it seems to be a common problem.
I've found a sollution on eclipse forum. Downgrading to PDT 3.1.2 solved the problem.
Regards,
Marek
I had a similar issue, but involving just one PHP file. Then I found that I was using the following syntax for the initialization of a variable inside a method:
$rule = ($fullValidation)?(new StartTimeRule()):(new NullRule());
The problem seems to be the use of the inline condition. The code was working but apparently broke some Eclipse features, like the F3 command, autocompletion, the outline view, etc. I could be wrong, but I think this is a bug of the DTLK indexer.
I changed that line with a standard if statement, not an inline condition, and all the features now work again.
Hope this can help!
After trying the other possible solutions on this page, I managed to get code completion to work in PDT 3.2 with the latest Dynamic Languages Toolkit in Eclipse Juno.
Juno usually installs DLTK version 4.0 by default so I downloaded DLTK 5.0 from here: http://download.eclipse.org/technology/dltk/downloads/drops/R5.0/R-5.0-201306060709/. Use the Core Frameworks > EMF > Runtime Version link, which downloads a zip file so you will need to do a local install:
In Eclipse select Help > Install New Software > Add > Archive > navigate to the zip file > type DLTK in the Name box and confirm.
Use Eclipse's Install new software to get PDT 3.2 from the PDT repository, if it is not already installed: http://download.eclipse.org/tools/pdt/updates/3.2/release
Option 2: Before I tried the previous method I installed PDT 3.1, which I got from the Juno update site (instead of the PDT repository):
Install New Software > http://download.eclipse.org/releases/juno. Code completion worked in 3.1, so it's another possibility.
Download ZF2 and put it to your perefered Location (~Frameworks/ZF2)
Eclipse: Window > Preferences > PHP > Libraries = Push "New"-Button, add a Name
choose added Item and click "Add External Folder"-Button. Choose you ZF2 destination
Be sure, your Project is "PHP Project" (see: Mark Project-Base-Folder, click Project in Menu > Project Natures and choose PHP Project.
This will rebuild your Project, if not also choose Project > build Project.
Now all should work like a charm (on Kepler Service Release 2)

Categories