如何使用 Zend_Tool 生成 XML 应用程序配置?

发布于 2024-08-31 03:19:32 字数 3844 浏览 4 评论 0原文

使用 zf create project myproject 创建新项目时,它将在 configs 文件夹中创建一个带有 application.ini 的默认项目布局。我可以在哪里更改这些默认设置,以便生成(并使用)XML 文件 (application.xml)?我查看了 Zend_Tool 的文档(http://framework.zend。 com/manual/en/zend.tool.html),但似乎没有关于如何执行此操作的信息。

假设您想使用不同的默认文件夹布局(即使用 htdocs 而不是 public 作为文档根),是否也可以指定它?

任何指向相关信息的指针(顺便说一句,我已经查看了快速入门,除非我忽略了它,否则没有提到任何相关内容)?

编辑

我已经尝试创建一个配置文件(存储在 .zf/project/profiles 中),并使用它来创建一个项目(使用 zf create project myproject myprofile< /code>),但这不会改变任何内容,即使新项目根目录中的 .zfproject.xml 文件确实包含 设置。 ..

新项目包含此内容(如您所见,这只是默认设置,仅更改了 applicationConfigFile 的类型):

<?xml version="1.0"?>
<projectProfile type="default" version="1.10">
  <projectDirectory>
    <projectProfileFile filesystemName=".zfproject.xml"/>
    <applicationDirectory classNamePrefix="Application_">
      <apisDirectory enabled="false"/>
      <configsDirectory>
        <applicationConfigFile type="xml"/>
      </configsDirectory>
      <controllersDirectory>
        <controllerFile controllerName="Index">
          <actionMethod actionName="index"/>
        </controllerFile>
        <controllerFile controllerName="Error"/>
      </controllersDirectory>
      <formsDirectory enabled="false"/>
      <layoutsDirectory enabled="false"/>
      <modelsDirectory/>
      <modulesDirectory enabled="false"/>
      <viewsDirectory>
        <viewScriptsDirectory>
          <viewControllerScriptsDirectory forControllerName="Index">
            <viewScriptFile forActionName="index"/>
          </viewControllerScriptsDirectory>
          <viewControllerScriptsDirectory forControllerName="Error">
            <viewScriptFile forActionName="error"/>
          </viewControllerScriptsDirectory>
        </viewScriptsDirectory>
        <viewHelpersDirectory/>
        <viewFiltersDirectory enabled="false"/>
      </viewsDirectory>
      <bootstrapFile filesystemName="Bootstrap.php"/>
    </applicationDirectory>
    <dataDirectory enabled="false">
      <cacheDirectory enabled="false"/>
      <searchIndexesDirectory enabled="false"/>
      <localesDirectory enabled="false"/>
      <logsDirectory enabled="false"/>
      <sessionsDirectory enabled="false"/>
      <uploadsDirectory enabled="false"/>
    </dataDirectory>
    <docsDirectory>
      <file filesystemName="README.txt"/>
    </docsDirectory>
    <libraryDirectory>
      <zfStandardLibraryDirectory enabled="false"/>
    </libraryDirectory>
    <publicDirectory>
      <publicStylesheetsDirectory enabled="false"/>
      <publicScriptsDirectory enabled="false"/>
      <publicImagesDirectory enabled="false"/>
      <publicIndexFile filesystemName="index.php"/>
      <htaccessFile filesystemName=".htaccess"/>
    </publicDirectory>
    <projectProvidersDirectory enabled="false"/>
    <temporaryDirectory enabled="false"/>
    <testsDirectory>
      <testPHPUnitConfigFile filesystemName="phpunit.xml"/>
      <testApplicationDirectory>
        <testApplicationBootstrapFile filesystemName="bootstrap.php"/>
      </testApplicationDirectory>
      <testLibraryDirectory>
        <testLibraryBootstrapFile filesystemName="bootstrap.php"/>
      </testLibraryDirectory>
    </testsDirectory>
  </projectDirectory>
</projectProfile>

When creating a new project using zf create project myproject it will create a default project layout with an application.ini in the configs folder. Where can I change these default settings so that it generates (and uses) an XML file (application.xml)? I've looked at the documentation for Zend_Tool (http://framework.zend.com/manual/en/zend.tool.html), but there seems to be no information on how to do this.

And suppose you'd like to use a different default folder layout (ie. use htdocs instead of public as your document root), is there a way to specify this as well?

Any pointers to relevant information (btw I've looked at the Quickstart, nothing relevant is mentioned there unless I'm overlooking it)?

edit

I already tried creating a profile (stored in .zf/project/profiles), and used that to create a project (using zf create project myproject myprofile) but that doesn't change anything, even though the .zfproject.xml file in the root of the new project does contain the <applicationConfigFile type="xml"/> setting...

The new project contains this (as you can see, it's just the default settings, only the type of applicationConfigFile has been changed) :

<?xml version="1.0"?>
<projectProfile type="default" version="1.10">
  <projectDirectory>
    <projectProfileFile filesystemName=".zfproject.xml"/>
    <applicationDirectory classNamePrefix="Application_">
      <apisDirectory enabled="false"/>
      <configsDirectory>
        <applicationConfigFile type="xml"/>
      </configsDirectory>
      <controllersDirectory>
        <controllerFile controllerName="Index">
          <actionMethod actionName="index"/>
        </controllerFile>
        <controllerFile controllerName="Error"/>
      </controllersDirectory>
      <formsDirectory enabled="false"/>
      <layoutsDirectory enabled="false"/>
      <modelsDirectory/>
      <modulesDirectory enabled="false"/>
      <viewsDirectory>
        <viewScriptsDirectory>
          <viewControllerScriptsDirectory forControllerName="Index">
            <viewScriptFile forActionName="index"/>
          </viewControllerScriptsDirectory>
          <viewControllerScriptsDirectory forControllerName="Error">
            <viewScriptFile forActionName="error"/>
          </viewControllerScriptsDirectory>
        </viewScriptsDirectory>
        <viewHelpersDirectory/>
        <viewFiltersDirectory enabled="false"/>
      </viewsDirectory>
      <bootstrapFile filesystemName="Bootstrap.php"/>
    </applicationDirectory>
    <dataDirectory enabled="false">
      <cacheDirectory enabled="false"/>
      <searchIndexesDirectory enabled="false"/>
      <localesDirectory enabled="false"/>
      <logsDirectory enabled="false"/>
      <sessionsDirectory enabled="false"/>
      <uploadsDirectory enabled="false"/>
    </dataDirectory>
    <docsDirectory>
      <file filesystemName="README.txt"/>
    </docsDirectory>
    <libraryDirectory>
      <zfStandardLibraryDirectory enabled="false"/>
    </libraryDirectory>
    <publicDirectory>
      <publicStylesheetsDirectory enabled="false"/>
      <publicScriptsDirectory enabled="false"/>
      <publicImagesDirectory enabled="false"/>
      <publicIndexFile filesystemName="index.php"/>
      <htaccessFile filesystemName=".htaccess"/>
    </publicDirectory>
    <projectProvidersDirectory enabled="false"/>
    <temporaryDirectory enabled="false"/>
    <testsDirectory>
      <testPHPUnitConfigFile filesystemName="phpunit.xml"/>
      <testApplicationDirectory>
        <testApplicationBootstrapFile filesystemName="bootstrap.php"/>
      </testApplicationDirectory>
      <testLibraryDirectory>
        <testLibraryBootstrapFile filesystemName="bootstrap.php"/>
      </testLibraryDirectory>
    </testsDirectory>
  </projectDirectory>
</projectProfile>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淑女气质 2024-09-07 03:19:32

好问题。

您需要某种项目简介。查看:

library\Zend\Tool\Project\Provider\Project.php

有一个带有默认配置的部分。

 protected function _getDefaultProfile()
    {
        $data = <<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<projectProfile type="default" version="1.10">
    <projectDirectory>
        <projectProfileFile />
        <applicationDirectory>
            <apisDirectory enabled="false" />
            <configsDirectory>
                <applicationConfigFile type="ini" />

上周有一个很好的 VideoScreencast 解释了如何创建自己的 Zend 工具提供程序,我认为这会有所帮助。

更新:

我检查了源代码,看起来文件名不可更改。

class Zend_Tool_Project_Context_Zf_ApplicationConfigFile extends Zend_Tool_Project_Context_Filesystem_File
{

    /**
     * @var string
     */
    protected $_filesystemName = 'application.ini';

无法找到将其设置为 xml 的方法。

Zend 工具简介

Good Question.

You need some kind of project profile. Have a look in:

library\Zend\Tool\Project\Provider\Project.php

There is an section with an default config.

 protected function _getDefaultProfile()
    {
        $data = <<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<projectProfile type="default" version="1.10">
    <projectDirectory>
        <projectProfileFile />
        <applicationDirectory>
            <apisDirectory enabled="false" />
            <configsDirectory>
                <applicationConfigFile type="ini" />

Last week there was an good VideoScreencast explaining how to create your own Zend Tool Providers, i think this can help.

Update:

I have checked the sourceCode, looks like the filename is not changeable.

class Zend_Tool_Project_Context_Zf_ApplicationConfigFile extends Zend_Tool_Project_Context_Filesystem_File
{

    /**
     * @var string
     */
    protected $_filesystemName = 'application.ini';

Was not able to found an method to set it to xml.

Introducing Zend Tool

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文