Joomla 自定义组件开发环境:热部署

发布于 2025-01-07 01:05:58 字数 392 浏览 0 评论 0原文

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

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

而不是每次我想尝试使用 joomla 根文件夹作为我的 git 项目的根目录时都必须复制/压缩组件的 php/html 文件。我会使用 gitignore 功能来排除属于 joomla 核心项目的文件。我想知道是否有人做过类似的事情以及您最初如何部署组件。这只是使用 Joomla 扩展管理器并将目录指向 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

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?

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

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

发布评论

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

评论(1

怎樣才叫好 2025-01-14 01:05:58

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

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

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

请注意,我使用的是 Windows,但我认为这对于其他操作系统也是一个很好的解决方案。使用 Eclipse 作为编辑器也很好,具有代码完成等功能。我以前使用过 Notepad++。

我的扩展文件夹结构:

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>

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

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.

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.

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.

My extensions folder structure:

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

The Eclipse external tool to run the following file:

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

Example of Phing xml file (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>

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