Skip to content
Jeremy D edited this page Jan 29, 2023 · 2 revisions

How it works

This tool makes use of SMF's package manager to assist in developing customizations using the hooks system. One lesser known feature for SMF is you can create a folder in the Packages folder and then with a valid package-info.xml, SMF will see it and allow install/uninstall.

This uses the knowledge of the packages to do safe actions such as removing or installing hooks. As well this can go out to your files and pull them into the package or push them out into the correct locations in your SMF install. By utilizing this, you can have your VCS repo as a folder in your Packages folder. Work can be done directly with your SMF install and using this commands, you can pull your work back into the VCS and use appropriate VCS commands to save your work.

To work with files/folders, your system will have to allow the PHP user executing the software read/write access to the folders/files in both Packages and your SMF install.

SMF does not track what hooks are added, so this tool uses just the matching install hooks to do the work.

As it is a bit complicated to track edits to SMF files, this tool does not currently support this. In the future this feature may be added but at this time it is not supported.

How to get started

To get started start with a creating a new folder in your Packages folder. This is typically named after your customization. After this start with a package-info.xml file. Simple machines wiki contains detailed information about the format and features of the package-info.xml Typically you will want to do 2 things: First, use a action such as require-file (or require-dir for larger customizations) with instructions to save your file to the appropriate location (typically $sourcedir)

Secondly, Use the hook action to define what hook and function to call. SMF supports objects/static classes as well, to use this call it like class::static_method or class::method# respectfully. The tool does have a built in editor for create/modifying hooks on the fly as your testing/expanding your code. This doesn't replace the logic in your package-info.xml, but assists you with developing your code by allowing you to add hooks to your SMF install. You still need to add the correct commands to your package-info.xml

Once you have this, you can "install" the customization. Even if it doesn't do anything yet. It should be noted that if you defined any hooks that are used on typical page loads, SMF will attempt to load the file and hook and if it fails, log a error.

After you have installed the customization, open up the files as they are installed in your SMF directories and begin writing your code. You can use the built in tool to add hooks to assist you with adding code and testing.

When you are ready, use the action "Sync Files to Package", which will use the correct command in your package-info.xml to seek out all files in your SMF install and send a copy of them into the relevant location in your customization folder.

If your developing in a team, you may update your VCS, change branches or tags. When this happens, use the "Sync Files to SMF" command to send a copy of the files in the customization to the correct locations in SMF.

As your developing, you may want to simulate an uninstall by removing all hooks and then installing hooks. You can use the "Uninstall hooks" and "Reinstall" hooks commands to do this. Reinstall will attempt to remove all hooks first prior to attempting to install again. This is an attempt to find hooks that may be corrupted and remove them. If your system is out of sync with hooks, use the hook tools to remove all relevant hooks.

Danger of using the require-dir command

The logic to find the files to sync is done by looking at your for rqeuire-file/dir commands. It is valid in SMF to use something like

<require-dir name="mymodsources/*" destination="$sourcedir" />

However, the logic will reverse this by looking for $sourcedir/* and put it into mymodsources/

It should be fairly obvious that this will pull the entire SMF source directory into your customization. You should avoid this. Instead be very specific about your files you are adding. You can also put all your files into a sub directory and do something like this:

<require-dir name="sd_source" destination="$sourcedir" />

Which will move the folder sd_source into $sourcedir and in reverse move $sourcedir/sd_source into the root of your customization, which will merge the sd_source folder and its contents.

Clone this wiki locally