Dreamweaver extension to beautify PHP/JavaScript/jQuery code - php

I'm looking so long for a Dreamweaver extension to auto beautify PHP / JavaScript / jQuery code. Currently Dreamweaver can beautify only HTML and CSS (Apply Source Formatting).
Any kind of help will be much appreciated.

Online solutions for validation and formatting JavaScript:
Validate JavaScript code:
http://www.javascriptlint.com/
Format JavaScript code:
http://jsbeautifier.org/

For the PHP side of things use https://github.com/fabpot/PHP-CS-Fixer
This short excerpt and more information is taken from the README.
Installation:
Download the php-cs-fixer.phar file and store it somewhere on your
computer.
Usage:
The fix command tries to fix as much coding standards problems as
possible on a given file or directory:
php php-cs-fixer.phar fix /path/to/dir
php php-cs-fixer.phar fix /path/to/file

I have found this great dreamweaver extenstion, just give it a try
Their Homepage: http://www.decodize.com/projects/
extension download page: http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=2107536

You can use PhpEdit, it's an extra debugger!
DW doesn't do debug, you find the error if and only if you run your code.
With PhpEdit, it is onTime.

Maybe try http://www.javascriptlint.com/
says it works on some IDEs, maybe DW is one of them.
Try googling, but use 'code format' not 'beautify'

I was wondering if you could elaborate on how to set this up. I see the CSS and Tag Libraries options under "Advanced Formatting", but I am stuck at that point as to how to get my PHP to start auto-indenting.
Or, if Dreamweaver has somehow fixed this problem, let me know! It seems like every other IDE has an auto-indent feature! Thanks :)

It's been a while since I have used DW, I use Aptana now and there is an option to format the code from one of the drop down menus. Just use something like "control a" (To select all your code), "control f" (To format your code). There might be another key combination but I think this will work if memory serves.
Maybe "esc control f"

I've not seen anything for Dreamweaver, but if you can copy ans paste the code, http://jsbeautifier.org/ can help you with making code look a good bit better. I've just tried it on some packed JavaScript and it worked out very well. You can also download the application and run it locally (it's only HTML and JavaScript), so you won't need an internet connection to get your code prettier.

Best way i found is to set the way Dreamweaver displays code yourself. Sure it takes some time to do but its worth it.
Here is how:
Dreamweaver: Edit > Preferences > Code Format
Then under Advanced Formatting you can pick CSS... or Tag Libraries...
You can make any of your code look as it should this way.
Like i said, will take some time but do it once and you can keep using it with all your future Dreamweaver versions.

In Dreamweaver CS6 no need any other extension or tools.
Just select your code and then Go to 'Commands' > 'Apply Source Formatting' or 'Apply Source Formatting to Selection'
Done. :)

Related

Is there a way to auto-indent HTML/PHP files?

My first place to look at this was a fix with Notepad++.
This quite quickly brought me to "TextFX HTML Tidy".
Read the description and it seemed to be the problem for all my problems.
However, the install is quite hard, apparently TextFX used to be standard practice for Notepad++, for some reason that is no longer the case. I eventually fixed this by downloading an older install for Notepad++ and copied the plugin folder to my own Notepad++ file.
This gave me acces to the correct plugin, but this plugin is written purely for HTML, C++, or XML.
Since I use php in my files, this gives some complications. Normal tags are ignored as they should be, but when I use php inside an html string, in a link for instance, the php tags get converted to html.
For instance:
The start of my sentence Here my anchor tekst.
After tidy HTML becomes
The start of my sentence Here my anchor tekst.
Rendering this solution unusable.
There must be a lot of people looking for this functionality, and since this one is no longer standard practice for Notepad++, I figured there must be a better method to auto format your HTML code. But for some reason I can't find it.
So my question is: Is there a way to autoformat my code, clearing empty lines and indenting tags in the correct opening and closing order?
Preferably with Notepad++ but any other program will do.
Kind regards
For anyone looking for the same things. Switching to Netbeans did the trick for me, options with Notepad++ are still appreciated.
In Netbeans, using Shift+alt+F did the trick for me.

Need a live PHP editor like dreamweaver

I am in need of a live editing software for PHP like there is DreamVeawer for CSS. I need the functionality that I can select items from the webpage and it will highlight the particular source code for it. If anyone knows about such a software please let me know.
Thanks in advance.
Firefox has a nifty add-on called Web Developer. You can't edit the PHP code directly because it's server side but you can highlight/edit the resulting HTML. You can find it here https://addons.mozilla.org/en-US/firefox/addon/web-developer/
Use google chrome's webkit inspector, it will find you the right html source code, which you can then trace back to the PHP code.
I'm afraid you won't find a solution for that.
PHP runs on the server-side and doesn't render any code to the browser like HTML does.
The closest you'll come is selecting DOM elements in Firebug/Dreamweaver(or any other designy IDE) rendered after the PHP is parsed
Im not sure what youre looking for exactly. If you want a WYSIWYG html editor they are plenty.
If youre tring to trace function and method calls in code then you need an IDE with code assist. Both Eclipse and Netbeans with their respective PHP plugins have this - i.e. you click on a function call and it opens the file containing that function. Depending on the context this can also work with variables...
I think there are also WYSIWYG html plugins for both but im not sure as i dont use them.
This isn't exactly what you want but this IDE can give a help
Aptana http://www.aptana.com/
or
PHPStorm http://www.jetbrains.com/phpstorm/

PHP syntax highlighting code editor

I need a configureable and extendable in browser code editor using JS and/or PHP (no python or flash etc).
Something like code.google.com editor (it rocks!) and I really like the diff capability it provides. It would be cool but I can't find info on what editor it is employing.
Anyone know something like that? Or if code.google.com's code is open Source? If yes, where can I get it?
I think this has been previously answered with CodeMirror being the preferred choice and it is apparently used by Googles code playground. See Is there a good in-browser code editor? for more information.

Question about software that tracks divs better than notepad++

I recently got hired as a web developer, and the project that I am overseeing has a formatting issue on one of the pages because one of the divs is out of whack. It is a fairly complex page with quite a bit of php, and from what I can gather, I am missing a </div> tag somewhere, and accordingly everything is messed up.
I am currently using notepad++, which is decent at lining up divs, meaning that if you click on the opening div tag, it will highlight purple and also highlight the closing one. But it seems as though if you have div tags that span several lines (hundreds) it won't work.
Has anyone else run into a similar situation? Is there a better editor I could be using that would do a better job of helping me with my div issue? Or do I have to go through and line up the divs 1 by 1? (there are like over 100). Please let me know!! Thanks
An alternate route I would like to suggest is running your page through a validator, such as the W3C service at http://validator.w3.org
HTML Validator is an addon for Firefox that can automatically run your pages through a local validator and notify you of any issues with an icon in the satus bar.
You want an editor that detects and highlights syntax errors in markup (as well as validity). There are many. I use Komodo Edit from ActiveState (www.activestate.com)
A cross platform solution is Eclipse (PDT). It comes with a nice and handy html editor. For quick file changes and hotfixes I use TextMate – but this is OS X only :(
Sometimes, when I have crazy X/HTML that I am trying to clean up/debug I put it into an XML editor and let it do some of the matching/formatting for me. My personal choice is Altova's XMLSpy. It is not free (hell, it's not even cheap), but I really like the power it has. You can download a free demo from their website and see if it helps you out.
Like what others have said, use a free editor like Eclipse. Open your HTML in Eclipse, then press CTRL+SHIFT+F and it will format and indent the code, just like what Notepad++ does.
Is this page already online in public area?
If yes, did you try to validate the HTML/XHTML with W3C validator http://validator.w3.org/, it might tell you the exact line where the closed DIV tag is missing.
UPDATE: you can also copy and paste code of the page deirectly into the validator and validate it: you go with your browser at the page, then you select "View Source" from the browser manu, than you copy & paste code into W3C validator.
You could try using a more "Powerful" editor such as Eclipse or Netbeans. I use Netbeans for most of my HTML / PHP development, and it does a good job of highlighting matching tags.
Vim + matchit plugin
I use http://users.rcn.com/creitzel/tidy.html#tidyui for fixing html.

Is there a code style enforcer?

I'm working with websites written in PHP, along with many other programmers, and sometimes I have to deal with really awful code.
Indentation totally messed up, curly braces in the wrong places, terrible whitespace use, it really hurts my eyes and actually makes my work harder and take longer.
Is there a tool where you can specify your coding style and then it applies it to files?
I'm sure there must be such functions in different IDEs, but I need an independent tool as I code with simple notepads like Notepad++ or the like. ( if it's such a function in Notepad++, I didn't see it )
Try PHP Code Sniffer.
That should be exactly what you are looking for(at least that's what I thought afert reading the heading, see the update).
UPDATE:
Actually what Code Sniffer does is go through your code and detect coding style violations, it does not however fix the problems.
But by telling you what's wrong it enforces you to adhere to a certain coding style. So that might be an option for you in the future.
While I have never used any, as I (luckly?) don't use anyone else code much, google found this, PHP Beautifier.
EDIT
See this question which recommends PHP Code Beautifier which is free (but requires an account creation)
Eclipse PDT also can format your code. Not sure how configurable it is. Just hit CTRL-Shift-F.
Well for a quick solution Aptana IDE does support a code format option
See the SD PHP Formatter for a tool that prettyprints source files, one at a time, or in large batches, according to your preferred style.
From what I can find Notepad++ doesn't even do basic linting (syntax checking) so it won't be able to do code sniffing: http://sourceforge.net/p/notepad-plus/discussion/482781/thread/b802c218:
Can anyone write a PHP syntax checker plugin?
...
What's wrong with PHP itself? If you run PHP as a command line utility with -l (letter L), it will run as PHP lint and check for syntax errors. e.g.
php -l broken.php
Hook it up as an external tool, perhaps through a batch file.
But you can get Code Sniffers for other text editors e.g. Sublime Text, Atom.io.

Categories