Hi, I want to learn how to create a package system like SMF's package system so that I can release modifications to my script easily.
Does anybody know how the package system in SMF works, and how I could code something similar? It doesn't need to be very advanced, just a simple one will do.
Or, does anybody know of another way in which I can release code modifications easily?
Creating a package system
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: Creating a package system
Check out PEAR and PEAR_PackageFileManager2
Re: Creating a package system
Your system can be incredibly simple. It can be as simple as defining a constant in your package release like so:
Code: Select all
<?php
define('PACKAGE_VERSION', 1.0.11);
?>
And having a text file or something on the central download site with the current version of the package.
Then you'd just need a page or a portion of a page to check against the central download site:
[code="php"]<?php
if ($currentVersion = @file_get_contents('http://www.example.com'))
{
if ($currentVersion > PACKAGE_VERSION)
{
echo 'your package is out of date!';
}
}
This assumes allow_url_fopen in php.ini, but is workable.Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Creating a package system
Um, I have a version constant and a version check in my script, the problem is having the script download a package and automatically patch the files, like in SMF.
I'll take a look at PEAR_PackageFileManager2, but I'm confused about how PEAR works... :/
I'll take a look at PEAR_PackageFileManager2, but I'm confused about how PEAR works... :/
Re: Creating a package system
Okay, I've looked at PEAR_PackageFileManager2, but it seems to be for managing PEAR packages.
I was wondering how I could code something similar, but simple, myself.
I was thinking about SMF as an example. Here's an old type of package file that they used to use:
And to install a package, they'd just have different files that will tell a script what to do.
I'm just stuck on how I could parse this kind of file and then perform the actions. What functions would I use for what?
I was wondering how I could code something similar, but simple, myself.
I was thinking about SMF as an example. Here's an old type of package file that they used to use:
Code: Select all
-- This information needs to be the same as that in the package-info.xml. --
<id>username:testing123</id>
<version>1.0</version>
-- Edit a specific file.. --
<edit file>$sourcedir/Filename.php</edit file>
-- The code to search for. --
<search for>
Search for some code to add stuff after.
</search for>
-- Add this text when we find it, after what we found. -->
<add after>
This is what to add.
</add after>
<search for>
Another search operation?
</search for>
<replace>
Yes, another. This time, replacing!
</replace>I'm just stuck on how I could parse this kind of file and then perform the actions. What functions would I use for what?