howto set up autocomplete for php in eclipse similar to java - php

i'm pretty new to php development and want to start using an IDE with syntax checking and autocompletion.
I'm used to programming java with eclipse and thought that the PDT provides similiar functionality.
In java if i type in for example: "new Arr" and press ctrl+space autocomplete suggests a list of possibilities with "new ArrayList()" on top.
but if i try the same in a php project, for example with "new mysq" and ctrl+space i get nothing. I would expect to get "new mysqli()" or similar recommended.
Is the described functionality not included in PDT? Or did i configure something wrong?
I did the "right click on project-> configure-> Add php support" but it didn't change anything.

If you would like to have some basic auto complete feature you can use NotePad++ (download) for a quick and easy starter. This is a really great minimal program that can be used very efficiently to code in many different languages. It provides huge ammount of different functions. It is a must have tool for any developer.
I used Notepad++ to write ten thousands of lines of PHP code, it worked really great for me.
Otherwise PDT also supports autocomplete. Make sure that you have a PHP project added and then your are in a PHP file (.php extension). If you have Java autocomplete working in the same project then I think that you are in a Java project, try adding a PHP project, then a new PHP source file. Then PHP autocomplete should be working well in this source file.
Make sure also that you have PHP perspective selected.
I hope you can get by now starting using PHP! Have luck and good times using this great language!

I found the solution in this question: Why does Eclipse code completion not work on some projects?
I had to manually add this:
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
to the buildpath file of my project.

Related

Minify PHP in Visual Studio 2015

Is there any way to minify (or remove comments) in PHP using Visual Studio 2015? I use PHP Tools and when i release php scripts to public server, i would like at least remove all comments from code. I know, is there way to remove comments with content menu, but i wish to have comments in my project and no comments (or minimal and unread code) in publish scripts (some like Bundler & Minifier tool, but for php). Thanks
There is basically no point in minifying Php since there is no performance gain in doing so. Although if you insist, there are a few ways to remove comments/whitespaces from source. (and these are not limited to just VisualStudio) -
Use Gulp.
Use Command line options: php -w file.php => generates file without comments & whitespaces. Equivalent to php_strip_whitespace()
Use Regular Expression in Find-Replace Function of your IDE. You can use the following inside Find FieldBox. (and keep Replace fieldbox empty)
//.* or /.
Use a Library/tool like Php-Minify
Hope that helps!
Why aren't you going to use online tool to do it?
There are many online tools you can use instead of VS 2015.
Here is one tool for you.
http://beta.phpformatter.com/
Hope it helps you and check this answer as solved if it helps you.
Thanks!
You can check Comment Remover tool to remove all the comments from a file with a single button click. It also remove #regions and preserve XML Doc comments.
I think there is no tool for visual studio to do this. But you may use external tools to do the job. It's a common task to do this in build system like jenkins. The build system e. g. is able to react on many version control events.
But I also think that you want to make php code unreadable (like compiling). There are only a few options to hide your php code to other people. You could use ionCube for encrypting php files. But then you have to make sure, that the ionCube extension is also installed on the public web server. Also, ionCube is currently not available for php 7.2, only up to 7.1. Another option is to compile php code using HipHop, a PHP to C++ compiler engine: https://de.wikipedia.org/wiki/HipHop

Why notepad++ autocomplete doesn't work with function arguments?

I checked "Settings > Prefences > Backup/Auto-Completion > Enable Auto-completion on each input" and "Function parameters hint on input" options. I have Notepad++ 5.9 (unicode) version. It auto completes function names but not their arguments. Also i tried re-install. I know it has this feature but not working. Any idea why?
I mean it auto completes print_r when i write "pri" but i want it to work like in the image;
http://i51.tinypic.com/3322auc.jpg
Hmm, this is not an answer to your question but I want to share it anyway.
I have used Notepad++ for years. I didn't like Eclipse and NetBeans is just so damn slow.
I never used the auto complete function for anything.
Notepad++ can't really do any code analysis, it can only give you auto-completion on the known PHP functions.
I've since switched to an IDE that does full code analysis and can do auto-completion for your own code as well.
Notepad++ is great if you just want to write something real quick. It's also a great tool if you want to learn about PHP since it doesn't do auto-completion very well ;) but if you really want to be productive when you're working on a large application I recommend you use an IDE that does code analysis. Productivity is the key here. I spend less time looking through files and more time actually writing code, which is great! :D
Good IDEs for PHP: NetBeans, PHPStorm, Eclipse.
For this feature to work, you need to supply an .xml file which contains the appropriate functions and parameters.
An example for Javascript with installation instructions can be found here.
I have not yet found xml files for PHP (or Python, which I'm looking for). But it seems this can work in npp, you just need to locate the right xml file.
Best of luck!
(Oh, and don't listen to the naysayers who are too quick to give up, npp works fine as an IDE.)
Notepad++ it's very good text editor, but it's not IDE.
Try to use IDE - NetBeans or PhpStorm, and you will get much more than just smart autocomplete.
I have a same question about this, function hint is Ok,but param hints not display until I download a new release of notepad++(a not install release), all is ok. before, I tryed many time, and edit the xml files.
If you will edit you own language, Can copy from a exist language xml ,for cpp.xml in plugins/APIs folder. It's easy to understand its rule.
It is very easy to have a error, if you config file is changed.

Tools to understand website source code

I recently had a website developed by an external source. They gave me the source code as well as sql files.
When I extract the source code I see folders like Smarty, fckeditor and many php files. I want to start editing these as I find it to be the best way to learn. What tool should I use. I tried using trial version of PHPdesigner, but it just doesnt open my php files.
Is there any tool that can take all these files in the form of a project and simultaneously show me a visual display of any changes that I make.
I suppose it is very clear that I am new to this. Any help will be greatly appreciated.
Just use simple text editor with some code highlight like Notepad++
It is free to use, very fast and it does what you need.
First of all try to know what are the different file types and which lanuguage are those targeted to. Once you know that you can then decide on the editor.
What i recommend is you try to find out if they used a framework for the website, something like CakePHP or CodeIgniter. The next step after you find out is to go the framework website and start reading the documentation.
If the site id developed in php most likely any type of WYSIWYG editing is going to inaccurate. This is because a number of different files need to be processed and combined by the php interpreter before they come together to make any given page or view. Thus the only way to really preview is to run it on a server. Since you say there are sql files he has laso used a DB to store something so most likely any changes you would need to make are going to be spread between both the php source files and the records in the db.
Aptana (Which is Eclipse based) is great at handling many different file type in one IDE. I would use Studio 2 w/ the plugins you need or if you feel cutting edge try Studio 3. It's cross platform so Linux/Windows or OSX.

PHP syntax highlighting in Visual Web Developer?

I recently installed PHP 5 on IIS, however, I am unable to find a PHP syntax highlighting plug-in or extension for VWD. Where can I find a plug-in? I thought there was an official one.
Consider PHP IDE for Visual Studio.
http://www.jcxsoftware.com/vs.php
I have used this and it adds a lot of nice PHP specific features to Visual Studio.
From their site...
Editor and File Management
•PHP4 and PHP5 Support
•Syntax Coloring for PHP, Smarty, HTML, JavaScript, CSS, XML and XSLT
•File templates for PHP, Smarty, HTML, JavaScript, CSS, XML and XSLT
•Intellisense for PHP, Smarty, HTML, JavaScript, CSS, XML and XSLT
Debugging
•XDebug and DBG support
•Debug PHP, JavaScript and .Net in one single session
•Built-in Apache web server for ease of debugging. Preconfigured with Php4, Php5, XDebug and DBG.
I've tried a lot of text editors, some free, some commercial. So far Visual Studio is the only one that has the right combination of features to be most useful to me. So, coding PHP in VS is important to me.
You can trick Visual Studio (and hopefully also Visual Web Developer) into thinking .php files are C++ with a registry hack. The syntax highlighting is close enough to be useful.
This blog post explains how to do it for all versions of VS: http://blog.cumps.be/visual-studio-2008-and-php-coloring/
I don't know about older versions, but VWD 2010 allows you to link any extension to any type of formatting in its options.
Tools->Options
click 'show all options'
Expand 'Text editor'
click on 'file extensions'
type in 'php' and select how you want it to be formatted (I recommend the Automatic Editor Selector), click Add
And there you go! Next time you load the page you will see the changes. If you don't like it, there's 20 other styles to choose from.
There is no official plugin for PHP for Visual Web Developer. I believe that this is because Microsoft would rather you use their .NET products, (notably ASP) which serves most of if not all of (I can't exactly say as I don't really use ASP as much as PHP) of the functionality of PHP.
There are however, some very good PHP IDEs out there. A list of which you Here
thx, I use the last post with "HTML format" instead "automatic editor selector"
I would recommend using Netbeans. It has code completion for PHP and runs xdebug for debugging. I've been using it for over a year and the support for PHP just keeps getting better.
Definitely worth trying.
I would recommend Visual Studio with this Extension :
http://phalanger.codeplex.com/
It is free and gives you more functionality than most of the expensive tools.
if you're using windows there's an application called notepad++ that will do syntax highlighting for dozens of languages. I used it for C but I know it has a php syntax highlighter and many more languages coming along. Check it out on sourceforge. If your using Linux or Unix you can use K Advanced Text Editor (kate). It also has a console window built in.
What I am looking is for a debugger for PHP that is as useful as the one built into Visual Studios. I searched high and low for this and there seems to be none that works well.
What I used is the PHP Designer 2007 - Personal Version 5.0.2 is a fully functional php editor, for free! from mpsoftware[dot]dk/, however I like using MSVWD a lot too, and now that I've seen how to make php files work in it, I gonna stick with that! Thanks!
btw Aptana Studio looks promising too tho
The closest Visual Studio like PHP environment I have found yet is CodeLobster. It has a free version for PHP and CSS, as well as for pay versions that include for the Pro version a plug-in for CakePHP, CodeIgniter, Drupal, Facebook, JQuery, Joomla, Smarty, Symfony, WordPress and Yii.
It isn't perfect, but it is pretty good and free for the basic version.

Find PHP Orphan Page

I've inherited a PHP application that has "versions" of pages (viewacct.php, viewacct2.php, viewacct_rcw.php, etc). I want to discover which of these pages are called from other pages in the application and which are not. Is there a tool available that will help with that?
Using whatever tools you would like (Find/Grep/Sed on Linux, I use Visual Studio on windows), it is just a matter of crawling your source tree for references of the filenames in each file.
Similar to FlySwat's answer: any good text editor or IDE with multi-file search should be able to help you find the orphan pages. On Mac OS X I would suggest TextWrangler(free), TextMate($), or BBEdit($$). I've had good success with each of these tools, but your mileage may vary.
If you wish to find out what pages are called by other pages, you need to look at where stuff is being called. Obviously in php code, you can only reference other files via includes or requires and the singular versions of those functions.
So if I were you I would grep your code for include and then require and attempt to make some kind of map showing what is calling what. Eventually you should end up with a pretty clear map of how the php files talk to each other. Then you will need to work out how the various points of the application talk to each other from there via HTML/AJAX etc.
Good luck. I have done it before, it takes a while, but you'll get there, just make sure you document what you find out.
You may want to try out nWire for PHP.
nWire for PHP is an innovative Eclipse plugin (works with Eclipse PDT & Zend Studio 7) which accelerates PHP development by helping developers navigate through their code and better understand the architecture of their application. nWire offers unique tools for real time code visualization, navigation and search.
nWire analyzes all the components and associations in your project. While opening a file you can immediately see where (and if) it is being used.

Categories