3

What platforms do Magento 2 developers use to code live? By this I mean, make a change and view it in browser as soon as I save my file. I was thinking that I could use Nano to create files and do everything from command line. For my own live site, development is very slow as I have to:

  1. Download the file I wish to change from Filezilla
  2. Make changes to the file
  3. Re-upload the file to filezilla
  4. Terminal commands to upgrade and clear caches

This cannot be the most efficient way to develop surely. What do the rest of you do in order to develop for a live dev website?

  • Is your question maybe more precise about "how to properly develop on a remote server?" – Flyingmana Sep 11 '18 at 9:19
  • filezilla??? setup github private repo, create hooks, edit your file, refresh page... – MagenX Oct 18 '18 at 18:13
3

Thinking that your questions is more about working on remote environments, so my answer centers around this.

The nowdays most used PHP IDE is PHPStorm, but other traditional IDEs are similar in this. They have a remote deployment setting, which allows you to upload/sync files directly on save. Thats quite powerfull.

Or if you are more crazy, you can run such an IDE via X-Forwarding with SSH on the remote server. (this aproach has issues, and requires a few more things on the server)

We have for several years now also IDEs, which are made to be run on a remote server, and used over a webbrowser. The first one is "cloud9 IDE", which was recently bought by Amazon and is now also available as an AWS service. They originally were openSource, but I dont know the state of this. https://aws.amazon.com/cloud9/?origin=c9io

The other now bigger one is Eclipse CHE, which is more about having a dedicated Docker setups managed over the IDE. https://www.eclipse.org/che/

1

In addition to the great answers already given, I would like to add another perspective. For the sake of the point I'm trying to make I'm gonna assume that the tools you mention are the only tools at your disposal. Disclaimer: You really should not edit 'live code' directly, as others have pointed out. This is just to illustrate my point.

Programming is all about automating things that otherwise would have to be done manually. This includes your own workflow. You say that you already work with the command line, so consider this:

Almost all OS's have a command line ftp client already installed, these offer most of the functionality of filezilla, be it without a gui.

So let's say we want to upload a file to the remote server, we are going to do something like this from the command line:

ftp myfile.php ftp.example.com/mydir

Now we need to log in remotely and clear the cache, something like

ssh example.com
clear-cache

This worklow, small as it is, is cumbersome, you will have to type a lot, and type it over and over again in the course of development.

But what if we combine these command in to a single .sh (on windows .BAT) file? We will call the file upload.sh and it will read something like this:

ftp myfile.php ftp.example.com/mydir
ssh example.com
clear cache

Now we only have to type ./upload.sh and all three commands will be executed at once, a small but noticable improvement over the former situation. However, we still have to edit ./upload.sh every time we have another file to edit. We can tackle this with command line arguments, to read something like this (the '$1' is the variable that holds your command line argument)

ftp $1 ftp.example.com/mydir
ssh example.com
clear cache

Now we can type ./upload.sh myfile.php (and make use of the autocomplete function of the command line shell) to upload any file we want. We can use another command line argument for the target directory, to make this a variable too.

Of course, you will soon notice that their are other repetitive tasks that need doing (typing your passwords for ftp and ssh for example). Also, if you've taken the advice from the other answers, you've started working on a local copy in stead of the live files, this will bring even more repetitive tasks, because now you will have to synchronize your local copy with the live files. (usually done with tools like git or mercurial).

Of course you can simply add these commands to an ever expanding uploads.sh, but you presumably will want to work on your project, not on writing your own home grown workflow tool. Luckily you don't have to because there are plenty of tools out there, and most are incorporated in IDE's like PHPStorm or Atom. These will give a lot of other perks too, like Magento aware syntax highlighting, auto indent, type hinting etc etc.

When working with others on bigger projects you will probably want to incorporate things like automated tests and quality checks, and be able to publish (deploy) to more than a single server. We have now entered the realm of Continuous Integration and Continuous Deployment (CI/CD) and Devops, which are huge subjects and worth a Google search imho.

All this however, from IDE's to Git to the whole of CI/CD, started with a developer having the exact same problem as you and a mindset of 'automate everything'. Also, when there is no (affordable) tool available, writing your own scripts to automate (parts of) your workflow is a perfectly viable option, my colleagues and I use multiple custom scripts daily.

1

This one is newer https://github.com/rotati/wiki/wiki/Deployment-and-QA-Workflow

I use Kubuntu so:

  1. You can use bitbucket is free for non public repo instead GIT.
  2. For file editing I use Kate with plugin for sessions , with ssh connection (PHPStorm is not free)
  3. For fast access to console Yakuake
  4. Digitalocean with droplets (cheaper cloud server)
  5. Enable developer mode via command line and change server caching to browser in magento settings.
  6. For PSD to code very helpful apps Zeplin or Avocade or AdobeXD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.