In the few weeks since I last wrote about Visual Studio Code (VSC), I have not used any other editor to write code. That includes Rapid PHP 2020, PhpStorm, and even Notepad++. That, alone, should make clear that VSC can be my central development tool for building Web sites.
This update discusses what I have done with VSC to make this possible and also how I have reduced my reliance on Expression Web while not abandoning it entirely.
PHP Editing
Writing PHP is my primary editing requirement. Native support for PHP in VSC is poor; I characterize such weak support as making the language second-class. The only option is to add extensions, which Microsoft itself suggests is the proper paradigm.
I began by choosing the most popular extension for PHP. It helped a lot. It was a mistake. What I should have done was more research because the second most popular extension proved not only to be more complete and powerful but also to have a substantially better user rating. It also replaced not one but three different PHP extensions that I previously had installed.
That second choice was Intelephense by Ben Mewburn in Australia. Installing it immediately improved PHP editing but not as much as I had hoped. I read the installation instructions (like a moron for the first time), realized I had missed a few vital steps, corrected, and things got way better. Then I discovered that Intelephense is a "freemium" extension, with the bulk of features in the free edition but some useful additions in the paid version. One of those premium features was enough to convince me to pay up that same day, $12 for a perpetual license. Worth every penny.
The huge plus of Intelephense is that it supplies code intelligence not only to pure PHP but also to PHP files that include HTML, CSS, and JavaScript. This was a key omission of the first extension I tried and it was that omission that made me consider other options in the first place. The essence of PHP is that it is easily embedded in HTML pages, its original scripting strength, and that means any PHP editor must be able to deal with a multi-language module.
With Intelephense installed, VSC becomes at least an excellent PHP editor. That is why I stopped using Rapid PHP and stopped exploring PhpStorm.
Which is not to say there are not problems. The biggest one I've noted is stalls, in which Intelephense does not seem to index when changes have been made. The only way I've been able to cure this is to shut VSC down and restart, which is not quite as bad as it sounds because VSC starts quickly. A side effect of the stalls is that corrected errors are not cleared right away and the wavy-line error indicators remain in the code, usually offset away from the original source of the error. They eventually vanish when Intelephense catches up. I am heartened that support for Intelephense is active and ongoing; I suspect that things will get better over time.
Intelephense is an essential VSC extension for anyone doing PHP work.
Publishing
As mentioned in the previous article, I'm using the SFTP extension to handle publishing. And as mentioned in several articles about Expression Web and Rapid, I'm looking for a solution that matches the selections available in EW (because EW handles this very well). Here's the list, showing whether SFTP can do the same.
The file currently being edited
Any file or selection of files in the Explorer
Any folder or selection of folders in the Explorer
A group of files selected as the result of a search
Not bad. I make use of the last one quite a bit and I miss it; I've posted a feature request for it and perhaps it will appear.
One other handy feature is publishing all the files in open editors. EW and VSC (meaning SFTP) cannot do it; Rapid can.
There is no UI for configuring a publishing connection. The connections for a given site are stored in a JSON file (a very common VSC configuration method). I'm getting used to this manual editing and it's not terrible. SFTP creates a default layout for the JSON file and I'd like to change it, but I haven't found the template yet. I keep my template in a text file and copy & paste. SFTP's documentation regarding configuration is poor.
SFTP allows file exclusions. Because Expression Web keeps metadata in a parallel set of ghost files and I don't want to publish them, the exclusion feature is very important. I should add that sometimes my excluded files get published, which might be my mistake or a bug.
SFTP is fast. It's faster than EW (as is everything else), Rapid, and sometimes FileZilla. That high speed has proven very helpful because there are many cases where rather than selecting several files from a folder, I just upload the entire folder.
SFTP is unreliable. It suffers from stalls and sometimes (often) fails to upload a complete folder. Restarting VSC clears stalls but if a folder upload is incomplete there is no warning or indication unless you examine every line of SFTP's output in VSC, a tedious task.
I consider SFTP an essential extension but its use must be backed up by an FTP utility like FileZilla or WIN-SCP. The other FTP extensions in the Visual Studio Marketplace are not as advanced as SFTP and do not have as large a user base.
Other Helpful Extensions I'm Using
Apache Conf: This is a syntax highlighter for Apache configuration files. It provides colorization but not code intelligence. Nevertheless, it is better than editing plain text. It's a minor but helpful extension because I do edit .htaccess files.
change-case: This is crazy. I've never used an editor that could not do basic case change operations. In 2016, VSC got the ability to switch between all lower and all upper case but this was not exposed on any menu nor was it bound to keyboard shortcuts. I thus installed change-case, which is a bit inconvenient to use but supports every imaginable case change scenario. Helpful.
CSS Formatter: CSS is a first-class language in VSC. Sorry, but I seem to have forgotten why I installed this extension. I can't imagine having installed it unless I thought it made a difference. (Let me get back to you.)
MySQL: Rapid and PhpStorm have database browsers built in. VSC does not and thus an extension is needed. The MySQL extension is basic but sufficient for my needs and displays query results nicely. This is one thing Rapid does a little better; PhpStorm's database capability is terrific.
I was hoping to find an extension that would allow WYSIWYG editing. No such luck. There are thousands of extensions and I've only done a few searches so far. I'm not holding my breath.
Expression Web as Adjunct
Unexpectedly, I needed to update the dynamic Web template of one of my sites and thus returned to Expression Web to handle the task. EW made quick work of it but, because the site is hosted in a plan that no longer allows open FTP (only SFTP or FTPS), I needed to return to VSC to publish the files.
That's where the lack publishing of search results hurts. The files updated by the change to the DWT are not in one place but are scattered around the folder structure of the site. In EW, a quick process allows them to be found and selected, then published with one click. VSC's SFTP extension can't do that, as noted above.
Just for the record, the process in EW is:
- Search for whatever will result in the collection of files you want.
- Select all of the items in the search result. (This is not possible in the VSC explorer.)
- Click an option in the search results window called "Select Resulting Files in Folder List."
- Right-click any of the selected files in the Folder List and select the publish option.
Step 3 would be called "Select Resulting Files in the Explorer" in VSC and then it would be simple to publish the group, no matter how dis-contiguous. Step 2 would not be needed.
Even though I'd like to start doing only SFTP publishing, where possible I can always let EW do FTP when available and thus complete the task quickly. You can see why I'd like the SFTP extension to allow publishing of search results.
Also this past week I updated all the topics of my content management system's help system. The content is predominantly static HTML. I made many of the changes in VSC but in cases where more writing was needed, I found it easier to switch back to EW for its WYSIWYG capabilities. This worked out very well because I could open the file in VSC, edit in EW and close it, then return to VSC to find the file automatically updated. It was a very seamless process.
The bottom line is that EW delivered those things unique to it and except for the problem of publishing a non-contiguous set of files, I was able to use the two products together without difficulty.
Project Management
The concept of a project in VSC is different than in EW or in Rapid PHP. However, all three tools can treat one folder as containing a project, so opening a folder in all three tools constitutes opening a project. It is also the case that all three tools look at the folder as the entire context of the project (in my case, a Web site) and thus code intelligence, even in the older EW, works within that context. That is the most important unifying aspect of standalone Web site projects.
I have previously written about features supporting project management - the ability to have more than one project open at a time and the ability to restore the workspace to its last condition, to resume in a project where it was last left.
Expression Web allows multiple instances and thus allows multiple sites open at the same time. Visual Studio Code does the same. Rapid PHP does not allow multiple instances and I've called that a shortcoming.
Expression Web does not restore a project workspace. Because it allowed multiple instances, it can mimic the effect to an extent - one simply keeps each instance running as long as needed. Rapid PHP does not restore a project workspace and because it does not allow multiple instances, it can't be faked. Some salvation came in an extension built for Rapid that did keep track of the workspace and reloaded it. The extension proved very helpful but was somewhat limited by the extension model in Rapid. Visual Studio Code automatically, smoothly and quickly restores project workspaces.
Both EW and Rapid (to a slightly lesser extent) keep records of projects and have a UI devoted to the function. VSC does not; it keeps only a most recently used list. So far I haven't noticed a problem but I've only worked on six projects with VSC so far and haven't exhausted the MRU list yet. From what I can see so far, opening a project directly doesn't take much more time than selecting it from the MRU list and thus I don't think I will have a complaint about this.
Progress
Progress towards adopting a new toolset for my work is good. It is not without problems; the two primary extensions, both excellent, have issues that at least require me to restart VSC from time to time. Not every capability I'd like to see is present in the configuration I've built. But the fact that I've not used anything besides VSC and EW in three weeks confirms that I can do work productively in this new way.
One thing is clear. I can't see any reason to continue using Rapid PHP. It was a big help to me when I started using it four years ago but it is surpassed, at least for my style of work, by VSC with a carefully selected package of extensions.
Tags: coding, development, Expression Web, Programming, Visual Studio Code
A total of 21 related articles were found. See them all...