Every web developer needs to set up a development environment—a set of tools to work with, such as
每个Web开发人员都需要建立一个开发环境 -一组可以使用的工具,例如
a code editor 代码编辑器 a version control system (such as Git or SVN) 版本控制系统(例如Git或SVN) build tools and/or package managers 构建工具和/或程序包管理器 DevOps and provision tools (Docker, Puppet, Ansible, Vagrant) DevOps和配置工具(Docker,Puppet,Ansible,Vagrant)… and so on. Having a good setup is crucial for maximizing productivity.
… 等等。 良好的设置对于最大化生产率至关重要。
Development stacks vary from developer to developer, and can depend a lot on a developer's field of work. However, there are some pretty typical setups. SitePoint has recently published examples of local development environments for Linux, Windows and Mac.
开发堆栈因开发人员而异,并且在很大程度上取决于开发人员的工作领域。 但是,有一些非常典型的设置。 SitePoint最近发布了适用于Linux , Windows和Mac的本地开发环境的示例。
In this article, I'll take a look at a fourth kind of development environment—one that's based wholly in the cloud. This will normally happen through a third party service, and there are quite a few to choose from—such as Cloud9, Codenvy and Nitrous.
在本文中,我将介绍第四种开发环境-一种完全基于云的开发环境。 通常,这将通过第三方服务来实现,并且有很多可供选择的选择,例如Cloud9 , Codenvy和Nitrous 。
When using a cloud development environment, you're actually a client of a development platform as a service (dPaaS)—which offers a lot more than just an online code editor.
使用云开发环境时,您实际上是开发平台即服务 (dPaaS)的客户端,它不仅提供在线代码编辑器,还提供了更多功能。
Faster setup Firstly, developing in the cloud reduces the setup time. Usually you can use your framework of choice, or use boilerplate code structured as it should be, and all that is done by only clicking some buttons.
更快的设置首先,在云中进行开发可以减少设置时间。 通常,您可以使用自己选择的框架,也可以使用结构合理的样板代码,而所有这些只需单击某些按钮即可完成。
Access from Anywhere You can code from any computer, as long as you have an internet connection—whether you're using the latest iMac, an old Netbook or even a tablet.
随时随地访问只要您可以连接互联网,就可以使用任何计算机进行编码,无论您使用的是最新的iMac,旧的上网本,还是平板电脑。
Remote Pairing One of the features I love about these environments is remote pair programming. Cloud IDEs allow more than one developer to access the source code at the same time. You can see each other write code, test and chat in real time.
远程配对我喜欢这些环境的功能之一是远程配对编程 。 Cloud IDE允许多个开发人员同时访问源代码。 您可以看到彼此实时编写代码,测试和聊天。
Multiple Installs I recently had a problem with a Scala application. The dependencies just wouldn't install. It turned out to be because I had Java 8 installed, while some of the dependencies required Java 7. I did't want to downgrade, since it would probably affect other applications, so I decided to go on with a Vagrant config. Well, if you're in the cloud, you don't have to do that. You can require a container for each application you develop, and the container will be just like you want it to be (Java 7 in this case).
多次安装我最近在Scala应用程序中遇到了问题。 依赖项将不会安装。 原来是因为我安装了Java 8,而某些依赖项需要Java7。我不想降级,因为它可能会影响其他应用程序,所以我决定继续使用Vagrant配置。 好吧,如果您在云中,则不必这样做。 您可以为开发的每个应用程序都需要一个容器,并且该容器将像您想要的那样(在这种情况下为Java 7)。
For the rest of this article, I'll walk you through a few examples of what you can do with Cloud9, one of the many dPaaS services available to developers.
在本文的其余部分,我将为您提供一些示例,说明如何使用Cloud9进行开发, Cloud9是开发人员可以使用的许多dPaaS服务之一。
Cloud9 offers 5 plans, one of which is free. Each plan uses Docker containers running on Ubuntu Linux, offering full terminal access, multiple collaborator access, and infinite open-source projects.
Cloud9提供5个计划 ,其中一项是免费的。 每个计划都使用在Ubuntu Linux上运行的Docker容器,从而提供完整的终端访问,多个协作者访问以及无限的开源项目。
It's really handy that multiple developers can work on the same source code. Each collaborator has an active cursor, and they can write code at the same time.
多个开发人员可以使用相同的源代码确实很方便。 每个协作者都有一个活动的游标,他们可以同时编写代码。
In the screenshot above, you can see two users, me and jamesbond006, accessing the same controller code at the same time. Notice the lines marked with different colors in the left side of the line numbers. Each color identifies a user. The @message on line 8 is underlined with the color corresponding to jamesbond006—meaning he's the one who wrote the code. This feature is very helpful and beats TeamViewer anytime! You can use it to help a friend, get help from a friend, and even test or teach some student/job candidate remotely.
在上面的屏幕截图中,您可以看到两个用户me和jamesbond006 ,它们同时访问同一控制器代码。 注意行号左侧用不同颜色标记的行。 每种颜色标识一个用户。 第8行上的@message用与jamesbond006相对应的颜色加下划线-表示他是编写代码的人。 此功能非常有用,可以随时击败TeamViewer! 您可以使用它来帮助朋友,从朋友那里获得帮助,甚至可以远程测试或教一些学生/求职者。
If you're a front-end web developer or designer, you'll sometimes have to switch browsers to check if what you wrote is what you expect to see. You'll likely have Chrome, Firefox, Opera, and possibly IE and/or Edge installed.
如果您是前端Web开发人员或设计人员,则有时必须切换浏览器,以检查所写内容是否符合您的期望。 您可能已经安装了Chrome,Firefox,Opera,并可能安装了IE和/或Edge。
Cloud9 saves you from installing a whole stack of web browsers. You can remotely test your layout on the major browsers—both desktop and mobile. You can also test your app on iPad, iPhone, Android and Kindle.
Cloud9使您不必安装整个Web浏览器。 您可以在主要的浏览器(台式机和移动版)上远程测试布局。 您还可以在iPad,iPhone,Android和Kindle上测试您的应用。
Like other services, Cloud9 supports a wide range of programming languages and frameworks, including Ruby on Rails, various PHP frameworks, Node.js and also databases such as MySQL, PostgreSQL, Cassandra, MongoDB and others.
与其他服务一样,Cloud9支持广泛的编程语言和框架,包括Ruby on Rails,各种PHP框架,Node.js以及MySQL,PostgreSQL,Cassandra,MongoDB等数据库。
Even if you want to develop in a language not listed above, such as Scala, you can choose the Custom template and install your chosen language via the terminal.
即使您要使用上面未列出的语言(例如Scala)进行开发,也可以选择“ 自定义”模板并通过终端安装所选的语言。
You can create a Rails app by choosing the Rails template, or by choosing the Custom template and executing rails new in the terminal.
您可以通过选择Rails模板或选择Custom模板并在终端中执行rails new的Rails来创建Rails应用程序。
You can start the application by executing this on the terminal:
您可以通过在终端上执行以下操作来启动应用程序:
rails s -p $PORT -b $IPYou can then access the application you're developing by navigating to <workspace>-<username>.c9.io.
然后,您可以通过导航到<workspace>-<username>.c9.io来访问正在开发的应用程序。
To install gems, just add them inside your Gemfile and run bundle install in the terminal—just like you'd do in a local environment. The rails generate and rake db remain the same, and migrations create tables in the default db/development.sqlite3 file. If you don't want to use SQLite, read the docs on how to set up a database.
要安装gem,只需将它们添加到Gemfile ,然后在终端中运行bundle install Gemfile就像在本地环境中一样。 rails generate和rake db保持不变,并且迁移在默认的db/development.sqlite3文件中创建表。 如果您不想使用SQLite,请阅读有关如何设置数据库的文档。
For more language setup examples, I've put together some demos on GitHub—including C and C++, PHP and MySQL, Gradle and more.
有关更多语言设置示例,我在GitHub上放了一些演示-包括C和C ++,PHP和MySQL,Gradle等。
Of course, online code editors like Cloud9's come with a host of nice features that you'd expect in an editor. These include:
当然,诸如Cloud9的在线代码编辑器附带了许多您希望在编辑器中使用的出色功能。 这些包括:
outline views and code completion (including Emmet integration) 大纲视图和代码完成(包括Emmet集成) debugging tools 调试工具 split view 拆分视图 themes 主题 key bindings 键绑定 modes of popular editors (VIM, Emacs, Sublime) 流行编辑器的模式(VIM,Emacs,Sublime) built-in image editing. 内置图像编辑。Whether developing locally or in the cloud, you'll eventually want to deploy your code to a server. Some cloud development services include hosting as an option. But you can also deploy your code elsewhere.
无论是在本地还是在云中进行开发,您最终都希望将代码部署到服务器上。 一些云开发服务还包括托管。 但是您也可以将代码部署到其他地方。
On Cloud9, you can mount an FTP or SFTP (S for SSH/Secure) server by going to File > Mount FTP or SFTP server:
在Cloud9上,您可以通过转到文件>挂载FTP或SFTP服务器来挂载FTP或SFTP(用于SSH / Secure的S) 服务器 :
In the image above, you can see how an FTP server is mounted. I recommend using SFTP, which is more secure and uses an SSH connection with the hosting server. With SFTP, you don't have to specify a password; by default the SSH key in the workspace is used. (I recommend you read about setting up an SSH key if the concept is new to you.)
在上图中,您可以看到如何安装FTP服务器。 我建议使用SFTP,它更安全,并且与托管服务器使用SSH连接。 使用SFTP,您无需指定密码。 默认情况下,使用工作区中的SSH密钥。 (如果您不熟悉此概念,我建议您阅读有关设置SSH密钥的信息。)
The alternative to FTP is called Push to Deploy. Most cloud services—including Google App Engine, Heroku and Azure—allow you to use Git (or a similar VCS) to push the source code into a cloud VM for deployment. Since Git is already included in every Cloud9 workspace, you can use it to deploy your application by pushing it to the production server.
FTP的替代方法称为“ 推送到部署” 。 大多数云服务(包括Google App Engine , Heroku和Azure)都允许您使用Git(或类似的VCS)将源代码推送到云VM中进行部署。 由于Git已包含在每个Cloud9工作区中,因此您可以通过将其推送到生产服务器来使用它来部署应用程序。
If you want to continue your work offline, that's no issue. Cloud9 allows you to download the source code as a .zip archive and then you can develop locally in your machine. It also supports FTP. You can push the project directly into the development or the production server.
如果您想离线继续工作,那就没问题了。 Cloud9允许您将源代码下载为.zip存档,然后可以在计算机中进行本地开发。 它还支持FTP。 您可以将项目直接推送到开发或生产服务器中。
Cloud IDEs try to make the developer as mobile as possible. The whole environment is somewhere far removed from your machine, which enables you to use it even if you're using an old computer or sitting at someone else's machine. It comes with Git included, so you can use it to put the project under version control and/or work with a team of developers.
Cloud IDE尝试使开发人员尽可能地移动。 整个环境都远离您的计算机,即使您正在使用旧计算机或坐在其他人的计算机上,也可以使用它。 它附带了Git,因此您可以使用它来将项目置于版本控制之下和/或与一组开发人员一起工作。
I'd recommend using a Cloud IDE at times such as these:
我建议在以下情况下使用Cloud IDE:
Your computer is not powerful enough and your internet connection is stable (not getting regularly disconnected). 您的计算机功能不够强大,并且互联网连接稳定(没有定期断开连接)。 You want to practice pair programming with another developer when one of you is working off-campus. 当您中的一个在校外工作时,您想与另一位开发人员练习结对编程。 You don't mind using a code editor that's less powerful than your local locally installed code editor. 您不介意使用功能不如本地本地安装的代码编辑器强大的代码编辑器。 You quickly want to spin up an alternate environment without all the hassles of local installation. 您很快就想要建立一个备用环境,而无需进行本地安装的所有麻烦。You want to show someone a demo of the website/web application/Wordpress theme you're developing. (You just have to Run the application and share the URL.)
您想向某人演示您正在开发的网站/ Web应用程序/ Wordpress主题。 (您只需要运行该应用程序并共享URL。)
In this article, I've mainly covered the features of Cloud9's online IDE, but it's not the only one out there. There are lots of alternatives, including Nitrous, Codeanywhere and Codenvy. Which you choose, of course, will depend on your particular needs and preferences.
在本文中,我主要介绍了Cloud9的在线IDE的功能,但这并不是唯一的功能。 有很多选择,包括Nitrous , Codeanywhere和Codenvy 。 当然,您选择哪种取决于您的特定需求和偏好。
Have you ever developed in the Cloud? If so, how did you find it? What's your preferred service, and why?
您曾经在云端开发吗? 如果是这样,您是如何找到它的? 您首选的服务是什么?为什么?
翻译自: https://www.sitepoint.com/developing-in-the-cloud-an-introduction/
相关资源:xyPlatform:xyPlatform:在本地开发和测试,在云中部署和运行-源码