"Add as link" in Netbeans? - php

How can I (in the Netbeans IDE) add files as links, or point to existing files, kind of like a shortcut?
Visual Studio 2012 can do this, as shown in the following screenshot (found on Google Images - not mine).
I miss this feature in Netbeans. Copying my files over all the time is not an option, since I constantly improve my PHP library files, that are used across all other projects.
I am using the full version of Netbeans, and in this case, I am doing PHP development.

I am not sure that PHP is supposed to work like that, since its code is not compiled.
I could be completely wrong, and if I am, I'm sure someone else will educate us both.
What I've usually done is put the library in some directory and then add that directory to PHP's include path by adding this to php.ini:
include_path = "dir to your library"
And then I'd make sure that whatever class autoloader I was using was looking through the include path.
That said, I've more recently moved away from this, because a global library that changes often has caused me problems (a change would break something and similar issues).

Related

PhpStorm does not recognize PHP

I saw many different questions here, but nothing was helpful to me.
I have no trouble with an interpreter, I tried to reset PhpStorm's cache.
It looks like file functions.php isn't accessible.
I really don't want to make a total reset. Maybe somebody has an idea how to solve it?
I'm not sure what I actually did and how to reproduce this issue again, but now it works well. I took previous version of PHPstorm. When I installed new one, the previous one was simply renamed to sth like 'phpstorm2'.
Here are my thoughts what actually happened:
As I understand for highlighting is responsible that part of application which is managed under Languages & Frameworks / PHP / PHP Runtime.
To reproduce this issue you may try to disable there "Core / Core" and try to write down in any place of your phpfile following:
\Exception::class();
And in your case this class will not be highlighted, as it presents in Core_c.php. In my case it is placed in
/opt/phpstorm/plugins/php/lib/php.jar!/stubs/Core/Core_c.php
I'm 100% sure that these libs were always enabled, but why I didn't saw this - that is the question.
So if I face this issue again my steps would be:
Try to verify Languages & Frameworks / PHP / PHP Runtime. The better way would be to enable ALL libs.
Check External Libraries in the project tree. Check read privileges for /opt/phpstorm/plugins/php/lib/php.jar and probably reinstall this plugin.
Try to find out function which I don't actually see in External Libraries.

PHP Netbeans coding style configuration, where is it?

I want to standardize coding style accross all the developers computers in my office, I want to export my netbeans configuration and ask the other programmers to import it on their IDEs, do you know where that config file is?
I'm using netbeans 8.02 but if you have found it on another version I can use that information to figure it out. Thanks.
you can export your preferences via Tools|Options and use the "Export..." button on the bottom left corner. Check the "Formatting" checkboxe(s) to export formatting preferences only.
It will export your settings to a ZIP file.
To import these settings on other computers, simply go to Tools|Options and use the "Import..." button ;)
I've come to the conclusion that some settings are stored in hyperspace. So while that makes your efforts (to pass settings files around) futile, on the bright side it does mean interstellar travel is one step closer!
My experimental proof is to use this from inside the ~/.netbeans/ folder:
find . -mtime 1
I then altered some settings, closed netbeans, ran the above command again, and looked for which files changed. Nothing plausible seemed to, and the implausible ones did not contain anything that looked like my changes. I also ran the same test on the Project's nbproject folder (nothing had changed), and also had a poke around inside /etc/ (there seem to be no NetBeans files there). Yet, when I restart NetBeans, and go and look at the Options again (Editor | Formatting | PHP, then "Blank Lines" was where I did my test changes), my changes are still there.
So it is either Hyperspace, or Magic. And being a scientist I am not allowed to believe in magic. QED.

How to find a correct php file to edit in large live running web system?

I have a huge live running web site wich has lot of issues. This has developed by lot of programmers around the world. So If I want to fix some errors its really hard to find where it is and so on....These files are in zend framework. There are 100s of php files, css files java sripts files, etc. Is there any way that I can do global search a file or how to understand the file linkage of this kind of large systems?
If you are using Linux there are a bunch of ways to find the correct file -
On the command line
Find a file by name -
find . -name filename
Or the faster find a file by name -
sudo updatedb #Only needed the first time you run locate
locate filename
Search a directory's contents recursively for a string -
grep -ri somestring .
Here's a new trick I learnt recently - Using Ack! If you are on a Debian/Ubuntu system you can install ack by doing -
sudo apt-get install ack-grep
Then you can do -
ack-grep somestring
This is blazing fast!
In IDEs
In most IDEs or advanced editors you should be able to simply control click or right click and select "go to definition" to navigate to a function's definition.
I can attest that this works in Netbeans, Eclipse, Komodo, Emacs etc.
If you are open to adopting a new IDE, I suggest Netbeans. It's PHP mode is full of goodies including improved navigation. For example, to quickly open a file you can simply do Alt-Shift-O and type the filename.
First of all I think you'll need to learn a bit about Zend Framework, how it's MVC framework works and where the models, views and controllers are stored. This'll help you guess where to go looking for problems.
In terms of searching for specific lines of code or patterns most operating systems or IDEs will allow you perform a recursive search of a set of files. I think that's outside the scope of this site.
if you are using aptana you can search your whole workspace by going to search->search. If you are using dreamweaver you can open find menu and search through your current site
It will be pretty hard to locate the right file in a quick way if you don't have any knowledge about the application at all. I would recommend reading up on Zend Framework and how it's working.
debug_backtrace() can come in handy if you need to show a backtrace. This can be useful if you need to know from where a function has been called.
If you're searching for a file that outputs something, a simple "search all directories, recursive" search will probably do just fine. Most IDEs (even "simple" one like Notepad++) or even OSes have this built in.

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.

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