开源贡献 计算_为开源做贡献-更新Phalconphp.com

开源贡献 计算

A while back, I wrote a tutorial about installing Phalcon on Windows Azure. However, Phalconphp.com's home page still doesn't mention Azure as a supported environment in the "Phalcon can be installed on" section:

前一段时间,我写了一个关于在Windows Azure上安装Phalcon的教程。 但是,Phalconphp.com的主页在“可以安装以下位置”部分中仍未提及Azure作为受支持的环境:

alt

In this tutorial, we'll clone the Phalconphp.com website to our local PuPHPet VM, update it to include new information about a supported environment, and submit a pull request to the project owners. This post is a spiritual successor to my Dillinger.io Pull Request Tutorial, so be sure to check it out before moving along, as this tutorial will focus more on the PuPHPet workflow than the actual pull request workflow.

在本教程中,我们将Phalconphp.com网站克隆到我们本地的PuPHPet VM,对其进行更新以包括有关受支持环境的新信息,然后向项目所有者提交请求请求。 这篇文章是我的Dillinger.io Pull Request教程的精神继任者,因此请务必在继续学习之前进行检查,因为本教程将重点关注PuPHPet工作流程,而不是实际的Pull Request工作流程。

Note that while I will be using PuPHPet to prepare an environment in which to launch the website, you're by no means bound by this restriction – if you'd prefer to just clone it to your already set up local environment, please feel free to do so, though I personally believe the PuPHPet way is faster if you just do what I did.

请注意,尽管我将使用PuPHPet准备启动网站的环境,但您绝不受此限制的限制–如果您希望将其克隆到已经设置的本地环境中,请放心这样做,尽管我个人认为如果您按照我的方式做,PuPHPet的方法会更快。

初始配置 (Initial configuration)

If you aren't familiar with PuPHPet yet, please see Matthew Setter's tutorial. Let's visit PuPHPet and set up our virtual machine. One thing we need to keep in mind to make things easier for us, is where the Phalcon website's document root is, so we can bind that in our VM. If we check their Github, we can see they use the standard public folder in the main "website" repo, and that's what we'll do too.

如果您还不熟悉PuPHPet,请参阅Matthew Setter的教程 。 让我们访问PuPHPet并设置我们的虚拟机。 为了让我们更轻松,我们需要记住的一件事是Phalcon网站的文档根目录所在的位置,因此我们可以将其绑定到我们的VM中。 如果我们检查他们的Github上 ,我们可以看到他们使用标准的public文件夹中的主要“网站”回购,而这正是我们要做的太多。

I've chosen the following options, so feel free to follow in my footsteps or download my final version here (anything I don't mention was left on the default value):

我选择了以下选项,因此请随时关注或在此处下载我的最终版本(默认值保留我不提及的任何内容):

  • Environment: Local

    环境:当地
  • Server: Apache

    服务器:Apache
  • OS: Ubuntu Precise 12.04 x64 – Virtualbox 4.3

    操作系统:Ubuntu Precise 12.04 x64 – Virtualbox 4.3
  • Name: upgrading-phalconphp

    名称:upgrade-phalconphp
  • Installed packages: vim

    安装的软件包:vim
  • Timezone: Europe/Zagreb (leave on your own if you want)

    时区:欧洲/萨格勒布(如果需要,可自行离开)
  • Install XDebug: yes

    安装XDebug:是
  • MySQL options: db1, user1, pass1

    MySQL选项:db1,user1,pass1

Under Apache Virtual Host, I put the values as follows:

在“ Apache虚拟主机”下,将值如下所示:

alt

Create and download the archive, place it in your vagrant boxes location and unzip it.

创建并下载档案,将其放置在无所事事的盒子中并解压缩。

Next, let's add the Phalcon provision script from this article to the shell subfolder, and add the following line under all the provision blocks in the Vagrantfile:

接下来,让我们从添加尔康提供脚本这篇文章给shell子文件夹,下的Vagrantfile所有规定模块添加下面一行:

config.vm.provision :shell, :path => "shell/install_phalcon.sh"

This will make sure Phalcon is installed on VM boot.

这将确保在虚拟机启动时安装了Phalcon。

Next, we need to make sure the website is ready to run when the VM boots. We first need to fork the website repository. Go to https://github.com/phalcon/website and fork it.

接下来,我们需要确保在VM启动时网站可以运行。 我们首先需要派生网站存储库。 转到https://github.com/phalcon/website并进行分叉。

Clone your fork into the box's folder root:

将叉子克隆到盒子的文件夹根目录中:

git clone http://github.com/YOUR_USERNAME/website

After cloning, my folder structure looked like this:

克隆后,我的文件夹结构如下所示:

alt

If you used the PuPHPet procedure above, run vagrant up and wait for the VM boot to finish. If you picked Apache as the server like I did, after the VM boot, you might have to disable the default vhost. You can do this by SSHing to the box with vagrant ssh and executing:

如果您使用了上面的PuPHPet过程,请运行vagrant up并等待VM启动完成。 如果像我一样选择Apache作为服务器,则在VM启动后,您可能必须禁用默认的vhost。 您可以通过使用vagrant ssh到框并执行以下操作来执行此操作:

sudo a2dissite 15-default.conf
sudo service apache2 reload

This removes the default configuration, leaving alive only the one we set up in PuPHPet under "Virtual Host". Since the Phalcon website doesn't use a database (most of the material is static), we can immediately run it locally, without the need for any further modifications:

这将删除默认配置,仅保留我们在PuPHPet中“虚拟主机”下设置的配置。 由于Phalcon网站不使用数据库(大多数资料都是静态的),因此我们可以立即在本地运行它,而无需进行任何进一步的修改:

alt

There might be some warnings about PHP not being able to write to the cache directory in the source code folder, but we won't be dealing with that right now as it's not that important for this particular quick fix.

可能会有一些关于PHP无法写入源代码文件夹中的缓存目录的警告,但是我们现在不会处理,因为它对于此特定的快速修复并不重要。

Connect your repo to the original upstream, then make a new branch called adding-azure and switch to it, by executing:

将您的存储库连接到原始上游,然后通过执行以下命令创建一个新的分支,称为adding-azure并切换到该分支:

git remote add --track master upstream http://github.com/phalcon/website
git branch adding-azure
git checkout adding-azure

Theoretically, we could have added the default vhost disable commands and the git procedure to a final provision shell file. I'll leave that up to you for experimentation.

从理论上讲,我们可以将默认的vhost disable命令和git过程添加到最终的配置外壳文件中。 我让你自己去做实验。

更新网站 (Updating the website)

Finally, we can start working.

最后,我们可以开始工作了。

The relevant files will be:

相关文件为:

  • app/views/index/index.volt

    app/views/index/index.volt

  • app/views/pages/hosting.volt

    app/views/pages/hosting.volt

We will also need a new image file as the logo for Windows Azure. I've made one you can download:

我们还将需要一个新的图像文件作为Windows Azure的徽标。 我已经制作了一个您可以下载的文件:

alt

Add this image to public/images/hosting. Seeing as all the hosting provider images in that folder have their color counterpart, even if the color version is never used, let's respect this tradition and add our own as well.

将此图像添加到public/images/hosting 。 鉴于该文件夹中的所有托管提供程序映像都有对应的颜色,即使从未使用过颜色版本,我们也要尊重这一传统并添加自己的颜色。

alt

Next, we need to edit the home page to include the image into the image-set link. Open index.volt and add it to the end of the hosting images, like so:

接下来,我们需要编辑主页以将图像包含在图像集链接中。 打开index.volt并将其添加到托管映像的末尾,如下所示:

<img src="{{ cdn_url }}images/hosting/azure-gray.jpg" alt="Windows Azure" />
alt

Now enter hosting.volt, and duplicate the last <tr> block, the one mentioning RackSpace. Change this content to reflect Azure, like so:

现在输入hosting.volt ,并复制最后一个<tr>块,其中提到RackSpace。 更改此内容以反映Azure,如下所示:

<tr>
            <td align="center">
                <img src='{{ cdn_url ~ 'images/hosting/azure-gray.jpg' }}' title='Windows Azure' alt='Windows Azure' />
            </td>
            <td>
                <h4><a target="_blank" href='http://www.windowsazure.com'>Windows Azure</a></h4>
                <p>{{ tr('hosting_azure_1', 'http://www.windowsazure.com') }}</p>
                <p>{{ tr('hosting_azure_2', 'https://www.sitepoint.com/phalcon-windows-azure/') }}</p>
            </td>
        </tr>

Notice how we used some translation placeholders like hosting_azure_1. This is because Phalcon uses language files as a multi-language site, and the actual text of the content presented on the website is defined elsewhere.

注意我们如何使用某些翻译占位符,例如hosting_azure_1 。 这是因为Phalcon使用语言文件作为多语言站点,并且网站上显示的内容的实际文本在其他位置定义。

These language files are in app/var/languages. They are simple key=>value arrays defined in PHP files, and easily editable.

这些语言文件位于app/var/languages 。 它们是在PHP文件中定义的简单key => value数组,并且易于编辑。

Open the en.php file for English, and find the part where the hosting descriptions are (should be line 198). At the bottom of that section, add our own:

打开英语的en.php文件,并找到托管描述所在的部分(应为198行)。 在该部分的底部,添加我们自己的:

'hosting_azure_1'    => "The <a href=':1:'>Windows Azure cloud</a> provides you with highly scalable and manageable Windows hosting for your web apps. Use Phalcon to reduce your instance costs.",
'hosting_azure_2'    => "To install Phalcon, follow the step by step procedure in <a href=':1:'>this SitePoint article</a>.",

The final result should look something like this:

最终结果应如下所示:

alt

and when you reload the hosting page:

当您重新加载托管页面时:

alt

If you're feeling extra generous, add some other translations to the other language files – I'm sure the Phalcon team would appreciate it.

如果您觉得自己很慷慨,请将其他翻译添加到其他语言文件中-我相信Phalcon团队将不胜感激。

发送拉取请求 (Sending a pull request)

Once we add everything to Git with git add and commit with a decent message like "Added Azure to hosting providers, both on home page and the hosting page. Linked to article describing the procedure.", we can push the repo online.

一旦我们使用git add将所有内容添加到Git,并提交了一条体面的消息,例如“在主页和托管页面上都将Azure添加到托管服务提供商。链接到描述该过程的文章。”,我们就可以在线推送回购协议。

Once pushed, we submit the Pull Request.

推送后,我们将提交“拉取请求”。

alt

结论 (Conclusion)

All that's left to do now is wait and see if the devs will accept it. Regardless of whether or not the PR pulls through, this article has taught you how simple it actually is to contribute to an open source project.

现在剩下要做的就是等待开发人员是否接受它。 不管PR是否通过,本文都告诉您对开源项目做出贡献实际上是多么简单。

If you want your contributions count to go up or just need to gain some experience slowly but surely, look around for some projects that need help and assist. Start small, like we did in this article – by making changes to HTML and text, then slowly move on to proper functionality as you see some missing.

如果您希望自己的贡献有所增加,或者只是需要慢慢但肯定地获得一些经验,请到处寻找一些需要帮助和协助的项目。 首先,就像我们在本文中所做的那样,先对HTML和文本进行更改,然后慢慢发现某些缺失,然后继续使用适当的功能。

If you have your own contribution story you'd like to share, a specific request, or just general feedback regarding this article, please don't hesitate to leave it in the comments below!

如果您想分享自己的贡献故事,特定的要求或只是对本文的一般性反馈,请随时在下面的评论中保留!

翻译自: https://www.sitepoint.com/contributing-open-source-updating-phalconphp-com/

开源贡献 计算

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值