Copy link to clipboard
Copied
In a .php file, when selecting Edit > Code > Apply Source Formatting, Dreamweaver has a code-breaking bug. It applies incorrect spacing before and after backslashes used in PHP Class namespaces. For instance, this is what a namespace looks like after formatting (two examples: one without a backslash to begin the namespace and one with):
<?php
use Path\ ToMy\ Namespaced\ PHPClass;
// Fully qualified name
use\ FullyQualified\ Namespaced\ PHPClass;
Before PHP version 8, this didn’t seem to affect the parser at all, so I never worried about it. After I updated my local environment to PHP 8.1, it throws a syntax error whenever there is a space after a backslash, or no space after a reserved keyword (use, new, return). This is probably a strict-mode condition that can be turned off, but that shouldn’t be necessary.
In all instances, it just seems like incorrect behavior to ever change source code in this way. Backslashes have a very important role in PHP and should not be affected by source formatting. Is there a way to change this behaviour in Dreamweaver, or is this simply a bug that Adobe needs to fix?
Copy link to clipboard
Copied
I tried it with the following code and can't reproduce what you describe. Auto format didn't not change my code.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP Info</title>
</head>
<body>
<p>
<?php phpinfo() ?>
<?php use Path\ToMy\Namespaced\PHPClass; ?>
</p>
</body>
</html>
When DW misbehaves, it's usually due to 1 of 2 things: 1) Code errors in the document or 2) corrupted preferences. See Restore Preferences below.
https://helpx.adobe.com/dreamweaver/kb/restore-preferences-dreamweaver.html
Copy link to clipboard
Copied
I am referring to a pure PHP document (as my example clearly showed), not a mixed content page. I rarely, if ever mix PHP and HTML anymore, since there are many good templating systems out there, and it isn’t good MVC principles to mix them anyway.
Also, this problem occurred in Dreamweaver 2020 and persisted in Dreamweaver 2021, even after a completely fresh install. It isn’t the preferences, and it isn’t a coding error. It is a problem with Dreamweaver’s source formatting engine, and there is no way given to alter the behaviour on the user’s end that I can see.
Copy link to clipboard
Copied
PATIENT: Doctor, doctor, it hurts when I format source code in PHP scripts.
DOCTOR: Then stop doing it.
😀
Seriously, I don't know of any way to change it, either. Sorry.
Copy link to clipboard
Copied
This was a known bug that had been sitting in the old uservoice forum (bug report/feature request forum) for quite a while. It was far worse when it was originally discovered and they did fix a lot of php rewriting issues that were introduced when Brackets was added.
However, I don't think Adobe plans any more bug fixes for DW. They're calling it "minimally maintained" now and have gotten rid of the uservoice forum all together.
Your best course is probably going to be what Nancy implies, don't use Apply Source Formatting in php files.
Copy link to clipboard
Copied
I’m unfortunately, one of those poor souls that started using GoLive back in the day and then transitioned to Dreamweaver. I haven’t been able to find an IDE that does what DW does out of the box without tons of mods and configuration. I’m just too ensconsed in it to change my work flow at this point. That might have to change...
It seems like DW is nearing end-of-life phase, so I hope Adobe does the right thing and releases the code into the wild as open source. It would free up their resources for other projects that are more important to them, and allow the open source community to actually do some critically necessary work on the app.
Copy link to clipboard
Copied
I haven’t been able to find an IDE that does what DW does out of the box without tons of mods and configuration.
By Dan@FWD
I'd be interested to know what Dreamweaver can do out of the box in terms of php.........have you tried the 'php storm' IDE from jet brains? Personally I think its the number one premium php editor out there, although granted it does have rather a lot going on, most of which I just ignore. At least its being actively updated.
Copy link to clipboard
Copied
DW can't do anything that even a text editor like VS Code or Atom can't do better. But I am a full stack developer who is constantly moving from php to html to js to css to twig to blade, etc.
I manage a lot of different sites, most with staging sites. The built-in sftp with sync is invaluable. The snippets library comes into use a lot. It feels like it would take me a month to configure another ide, set up shortcuts, install the necessary modules and learn the new workflow. But I think I'm going to have to bite the bullet soon.
Copy link to clipboard
Copied
DW can't do anything that even a text editor like VS Code or Atom can't do better. But I am a full stack developer who is constantly moving from php to html to js to css to twig to blade, etc.
I manage a lot of different sites, most with staging sites. The built-in sftp with sync is invaluable. The snippets library comes into use a lot. It feels like it would take me a month to configure another ide, set up shortcuts, install the necessary modules and learn the new workflow. But I think I'm going to have to bite the bullet soon.
By Dan@FWD
I think once you become ingrained with working in one editor its tough to move but at some stage it might be necessary. I used Dreamweaver for more years than I care to remember BUT it started to decline a lot in keeping pace with current methods, workflows, so I jumped ship and now use a number of editors, all of which, in my opinion, can do much more than Dreamweaver. The only area where I think Dreamweaver still shines is file management, its the only editor, apart from the ones jet brains produce which will update links if you pull files around inside the site folder.
Seriously I think you would benefit from giving php storm a trial if you never have before........its a dedicated php IDE.
Copy link to clipboard
Copied
Some code formatting issues with PHP have been around for a long time, some were fixed/some still remain.
Also I'm guessing Dreamweaver does not officially supports PHP 8 as in preferences the highest version option is PHP 7.1, so it is way behind the curve....