自定义组件开发环境

自定义组件开发环境

本文介绍了Joomla 自定义组件开发环境:热部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划开发 Joomla 自定义组件并将文件存储在 git 存储库中.我的 git 项目的结构将模仿部署的 joomla 结构

I'm planning on developing a Joomla custom component and storing the files in a git repo. The structure of my git project will mimic the deployed joomla struture

<root>
-administrator
  -components
    -com_abc
-components
  -com_abc
-modules
  -com_abc
-plugins
  -com_abc

每次我想尝试使用 joomla 根文件夹作为我的 git 项目的根时,不必复制/压缩组件的 php/html 文件.我会使用 git ignore 功能来排除属于 joomla 核心项目的文件.我想知道是否有人做过类似的事情,以及您最初如何部署您的组件.是否只是使用 Joomla 扩展管理器并将目录指向 joomla 根目录的情况?

Rather than having to copy/zip the php/html files for the component each time i'd like to try and use the joomla root folder as the root for my git project. I'd use the git ignore feature to exclude files that belong to the joomla core project. I'm wondering has anybody done something similar and how do you initially deploy your component. Is is just a case of using the Joomla Extension Manager and pointing the directory to the joomla root dir?

推荐答案

我自己不久前也做过这样的事情.我使用以下三个链接来设置我的开发结构:

I myself did this kind thing not long ago. I used the following three links to setup my development structure:

我现在得到的是一个单独的 Eclipse 项目,用于我的本地 Joomla 安装和每个 Joomla 扩展/模板.我在每个扩展上都使用 Git,但不使用 Joomla 安装本身.

What I now got is a separate Eclipse project for my local Joomla installation and every Joomla extension/template. On every extension I use Git, but not the Joomla installation itself.

每次对扩展进行更改时,我都会使用 Eclipse 构建器调用 Phing,将编辑后的文件复制到我的 Joomla 安装中.这样,我可以在本地测试更改.当我准备将扩展部署到远程站点时,我使用 Phing 构建 zip 包,以便我可以使用 Joomla 扩展管理器手动安装它们.

Every time I make a change to a extension, I use a Eclipse builder to call on Phing that copies the edited files to my Joomla installation. This way, I can test the changes locally. When I'm ready to deploy the extensions to a remote site, I use Phing to build the zip packages so that I can manually install them using the Joomla Extension Manager.

请注意,我使用的是 Windows,但我认为这对于其他操作系统也是一个很好的解决方案.用Eclipse做编辑器也不错,有代码补全等.之前用过Notepad++.

Note that I'm on Windows and but I think it's a good solution for other operating systems too. Using Eclipse as editor is also nice, with code completion etc. I used Notepad++ before.

我的扩展文件夹结构:

com_extensionname
    - backend
         - assets
         - controllers
         - helpers
         - language
         - models
         - sql
         - tables
         - views
         - access.xml
         - extensionname.php
         - config.xml
         - controller.php
         - index.html
         - router.php
         - LICENSE.txt
    - frontend
         - assets
         - controllers
         - helpers
         - language
         - models
         - views
         - extensionname.php
         - controller.php
         - index.html
         - router.php
    - build.xml
    - extensionname.xml

运行以下文件的Eclipse外部工具:

Location: Path to phing.bat
Working Directory: ${project_loc}
Arguments: create_packages (This only argument only goes to the "Create packages"-tool

Phing xml 文件(build.xml)示例:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Project Name" default="copy_to_test" basedir=".">
<property name="test" value="YOUR PATH TO LOCAL JOOMLA INSTALLATION" override="true" />
<property name="src" value="${project.basedir}" override="true"/>

<!-- Package properties -->
<property name="package_path" value="PATH WHERE PACKAGES SHOULD GO" override="true" />
<property name="package_name" value="com_YOUREXTENSION" override="true" />

<!-- Files -->
<fileset dir="./frontend" id="frontend_files">
    <include name="**" />
    <exclude name="language/**" />
</fileset>
<fileset dir="./backend" id="backend_files">
    <include name="**" />
    <exclude name="language/**" />
    <exclude name="packages/**" />
</fileset>

<!-- Language files -->
<fileset dir="./frontend/language" id="frontend_language_files">
    <include name="**" />
</fileset>
<fileset dir="./backend/language" id="backend_language_files">
    <include name="**" />
</fileset>

<!-- All files (for packaging) -->
<fileset dir="${src}" id="allfiles">
    <include name="**" />
    <exclude name="backend/packages/**" />
    <exclude name=".**" />
</fileset>

<!-- Target: Copy to test -->
<target name="copy_to_test" description="Copies files to test project.">
    <echo message="Running build.xml. Copying files from dev to test..." />

    <!-- Manifest file -->
    <copy file="MANIFEST_FILE.xml" todir="${test}/administrator/components/com_YOUREXTENSION" />

    <!-- Component files -->
    <copy todir="${test}/components/com_YOUREXTENSION">
        <fileset refid="frontend_files" />
    </copy>
    <copy todir="${test}/administrator/components/com_YOUREXTENSION">
        <fileset refid="backend_files" />
    </copy>

    <!-- Language files -->
    <copy todir="${test}/language/en-GB">
        <fileset refid="frontend_language_files" />
    </copy>
    <copy todir="${test}/administrator/language/en-GB">
        <fileset refid="backend_language_files" />
    </copy>
</target>

<!-- Target: Create packages -->
<target name="create_packages" description="Generates package files">
    <echo message="Running build.xml. Generating package files" />

    <!-- <propertyprompt propertyName="package_version" defaultValue="" promptText="Enter version" /> -->
    <xmlproperty file="MANIFEST_FILE.xml"/>

    <delete file="${package_path}/${package_name}-${extension.version}.zip" />
    <delete file="${package_path}/${package_name}-${extension.version}.tar.gz" />

    <zip destfile="${package_path}/${package_name}-${extension.version}.zip">
        <fileset refid="allfiles" />
    </zip>
    <tar destfile="${package_path}/${package_name}-${extension.version}.tar.gz" compression="gzip">
        <fileset refid="allfiles" />
    </tar>
</target>

这篇关于Joomla 自定义组件开发环境:热部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 00:27