Actions

Difference between revisions of "Using the installer API to support package installation"

From Joomla! Documentation

(New page: == Packaging == [http://www.mjaztools.com/ MjazTools] have come up with a [http://extensions.joomla.org/component/option,com_mtree/task,writereview/link_id,2421/Itemid,35/ contribution] i...)
 
m (fixing)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
{{review}}
 
== Packaging ==
 
== Packaging ==
 
[http://www.mjaztools.com/ MjazTools] have come up with a [http://extensions.joomla.org/component/option,com_mtree/task,writereview/link_id,2421/Itemid,35/ contribution] including an [http://ant.apache.org/ Ant] build script to package your development result into an archive for distribution.
 
 
 
The script needs to be extended for sorting your files into folders within the archive, which are needed for the Joomla! extension installer API. See the recommended file locations below:
 
The script needs to be extended for sorting your files into folders within the archive, which are needed for the Joomla! extension installer API. See the recommended file locations below:
  
Line 13: Line 11:
 
| <tt>/site/**</tt> (mimic folder structure)
 
| <tt>/site/**</tt> (mimic folder structure)
 
|-
 
|-
| <tt>/adminsitrator/components/com_<component name>/**</tt>
+
| <tt>/administrator/components/com_<component name>/**</tt>
 
| <tt>/admin/**</tt> (mimic folder structure)
 
| <tt>/admin/**</tt> (mimic folder structure)
 
|-
 
|-
Line 42: Line 40:
 
Your component needs an xml-file declaring meta data (author, license, etc.), which files are included and indicates some special files to the installer API, like the included languages and SQL-scripts for (un)installing.
 
Your component needs an xml-file declaring meta data (author, license, etc.), which files are included and indicates some special files to the installer API, like the included languages and SQL-scripts for (un)installing.
  
The most important xml-elements are explained below. For a full syntax refer to [http://dev.joomla.org/xml/1.5/component-install.dtd the manifest's DTD]:
+
The most important xml-elements are explained below. There is a [http://dev.joomla.org/xml/1.5/component-install.dtd manifest DTD for Joomla! 1.5 components] which can be used as a guide to the syntax, but it cannot be used to validate the manifest due to a problem with the 1.5 component installer.  This should be corrected for Joomla! 1.6 onwards.
  
 
=== The root element ===
 
=== The root element ===
Line 71: Line 69:
  
 
  <install>
 
  <install>
     <languages folder="lang/site">
+
     <languages folder="language/site">
 
         <language tag="''en-GB''">en-GB.com_''<component name>''.ini</language>
 
         <language tag="''en-GB''">en-GB.com_''<component name>''.ini</language>
 
         ...
 
         ...
 
   
 
   
 
     <administration>
 
     <administration>
         <languages folder="lang/admin">
+
         <languages folder="language/admin">
 
             <language ...
 
             <language ...
  
Line 107: Line 105:
 
== Custom Installer Code API ==
 
== Custom Installer Code API ==
  
If you need more to be done to the live site upon (un)installation than deploying the files, languages, and executing SQL statements, the installer files are your way. For example, you might need to update existing data entries in the tables during an upgrade installation. The code will be executed after deployment.
+
If you need more to be done to the live site upon (un)installation than deploying the files, languages, and executing SQL statements, the installer files are your way. For example, you might need to update existing data entries in the tables during an upgrade installation. Indicate the scripts in the manifest file (see above), and the code will be executed after deployment.
  
The scrips should have exactly one function:
+
The install script should define exactly one function:
  
 
<source lang=php>
 
<source lang=php>
 
function com_install()
 
function com_install()
 
</source>
 
</source>
 +
 +
The uninstall script, respectively, should also define exactly one function:
 +
 +
<source lang=php>
 +
function com_uninstall()
 +
</source>
 +
[[Category:Development]]

Latest revision as of 21:02, 20 June 2013

Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.


Contents

Packaging

The script needs to be extended for sorting your files into folders within the archive, which are needed for the Joomla! extension installer API. See the recommended file locations below:

Development file Archive folder
/components/com_<component name>/** /site/** (mimic folder structure)
/administrator/components/com_<component name>/** /admin/** (mimic folder structure)
/language/en-GB/en-GB.com_<component name>.ini /language/site (flatten structure: discard language code subfolders)
administrator/language/en-GB/en-GB.com_<component name>.ini /language/admin (flatten structure: discard language code subfolders)
install.<component name>.php /
uninstall.<component name>.php /
install.<component name>.sql /admin
uninstall.<component name>.sql /admin
<component name>.xml The manifest file /

The Component Manifest File

Your component needs an xml-file declaring meta data (author, license, etc.), which files are included and indicates some special files to the installer API, like the included languages and SQL-scripts for (un)installing.

The most important xml-elements are explained below. There is a manifest DTD for Joomla! 1.5 components which can be used as a guide to the syntax, but it cannot be used to validate the manifest due to a problem with the 1.5 component installer. This should be corrected for Joomla! 1.6 onwards.

The root element

<install type="component|module|..." method="upgrade">
    <name>component name</name>
    <version>x.y</version>
...

Enter the type of your extension, and indicate whether the installer shall be able to overwrite existing files. If the method attribute is not given, the installer will quit gracefully when encountering any existing file on the webspace.

The file list

<install>
    <files folder="site">
        <folder>views</folder>
        ...
        <filename>component-name.php</file>
        ...

    <administration>
        <files folder="admin">
            ...

List all files which make up the code of your component, which will later go to the component subfolder of the site. Same for the administration part.

The language files

<install>