Yii 和 Git 存储库 [英] Yii and Git Repos

查看:25
本文介绍了Yii 和 Git 存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在同时学习 Yii 和 Git,并且正在发现我的提交问题.如果重要的话,我正在使用 BitBucket.

I'm learning both Yii and Git at the same time, and am finding issues with my commits. I'm using BitBucket if that matters any.

基本上,如果我创建一个项目并提交到 repo,当我尝试将该 repo 拉到另一台机器上时,我会从一大堆 Yii 运行时配置错误开始.

Basically, if I create a project and commit to the repo, when I then try to pull that repo onto another machine, I start with a whole bunch of Yii runtime configuration errors.

我找到了解决方法,但它看起来很乱.如果我在添加项目后立即加载较旧的 repo 提交并手动删除该项目,然后通过 yii 工具(yiic)重新添加它,我可以使用最近提交的更新覆盖它以恢复所有内容.

I've found a way around it, but it seems messy. If I load an older commit of the repo from just after the project was added and delete the project manually then re-add it through the yii tools (yiic) I can overwrite it then with the updates from the most recent commit to get everything back.

这看起来很乱,像是在自找麻烦.我在 Yii 上做错了什么吗?

This seems messy and like it's asking for trouble. Is there something I'm doing wrong here with Yii?

编辑以下是出现的确切错误消息:

Edit Below is the exact error message as it appears:

CException

Application runtime path "/Applications/MAMP/htdocs/yii-sandbox/projects/trackstar/protected/runtime" is not valid. Please make sure it is a directory writable by the Web server process.

/Applications/MAMP/htdocs/yii-sandbox/framework/base/CApplication.php(289)

277             return $this->_runtimePath;
278         }
279     }
280 
281     /**
282      * Sets the directory that stores runtime files.
283      * @param string $path the directory that stores runtime files.
284      * @throws CException if the directory does not exist or is not writable
285      */
286     public function setRuntimePath($path)
287     {
288         if(($runtimePath=realpath($path))===false || !is_dir($runtimePath) || !is_writable($runtimePath))
289             throw new CException(Yii::t('yii','Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.',
290                 array('{path}'=>$path)));
291         $this->_runtimePath=$runtimePath;
292     }
293 
294     /**
295      * Returns the root directory that holds all third-party extensions.
296      * @return string the directory that contains all extensions. Defaults to the 'extensions' directory under 'protected'.
297      */
298     public function getExtensionPath()
299     {
300         return Yii::getPathOfAlias('ext');
301     }

推荐答案

您已将 main.php 配置文件添加到 git 存储库.如您所见,该文件包含每个主机的配置设置,如果将文件传输到另一台机器,这些设置可能会无效.

You have added your main.php configuration file to the git repository. That file contains per-host configuration settings that will likely not be valid if the file is transferred to another machine, as you are finding out.

解决方案是不在存储库中包含实时配置文件.相反,在部署时包含一个参考配置文件(不会被 Yii 加载)并将其内容复制到新的 main.php 中.以下是您需要做的第一步:

The solution is to not include the live configuration file in the repository. Instead, include a reference configuration file (that won't be loaded by Yii) and copy its contents to a new main.php when you deploy. Here's what you need to do as the first step:

git mv main.php main.reference.php
git commit -m "renamed configuration file"

在此之后,您还需要将名称 /protected/config/main.php 添加到 git 忽略的文件列表中,这样它就不会打扰您在部署目录.为此,请在结帐的根目录中创建一个名为 .gitignore 的文件并添加行

After this you also need to add the name /protected/config/main.php to the list of the files that git ignores, so that it won't bother you about unversioned files in your deployment directory. To do this, create a file named .gitignore in the root directory of your checkout and add the line

protected/config/main.php

这篇关于Yii 和 Git 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆