CodeIgniter Forums
Creating a self updater - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Creating a self updater (/showthread.php?tid=89093)



Creating a self updater - jetspeed - 01-07-2024

Hi guys,
How do you add self updating capabilities to your CI app? Most CMS and web apps notify users there is an update. Click on update and it will copy the files, etc.
Is this possible with CI? If not, how does one go about it?


RE: Creating a self updater - InsiteFX - 01-07-2024

Not sure but this may get you to the right direction.

GitHub-ozzi - php-app-updater


RE: Creating a self updater - kilishan - 01-08-2024

You would need to do a few different steps:

1. Occassionally ping your server/GitHub/whatever to get the latest version. If that's different than the current app's version then notify the user.
3. Create a UI to allow the user to update.
2. Download and install the updates when the user selects the update. This is the tricky portion. If I recall from the WordPress updater I looked at a few years ago, the most server-agnostic version is simply using FTP from the app to grab the files, pull them down the the current server, unzip, and move the files into place.

That works fine for standard hosting platforms, but not great for things that use images, like Kubernets, etc, since the file writes aren't permanent. The user would probably have a different flow at that time, anyway, where they'd do the updates locally, then commit those changes to a repo, which would then get deployed, so probably not a big deal, but something you would need to note in any docs for the project.


RE: Creating a self updater - jetspeed - 01-08-2024

Thanks for the replies. FTP seems a complicated way of doing it! I was hoping the CI had a simple way of downloading a zip and then extracting it, but the Filesystem helper doesn't have any of that.

I might have to play around with PHP's ZipArchive and see if I can build something basic from that.


RE: Creating a self updater - jetspeed - 02-05-2024

For anyone reading this, I was able to get an auto update system working with ZipArchive. Well worth the effort.


RE: Creating a self updater - JustJohnQ - 02-05-2024

Care to share your code?


RE: Creating a self updater - jetspeed - 02-06-2024

(02-05-2024, 11:49 AM)JustJohnQ Wrote: Care to share your code?
It's a working prototype, untidy, and very specific to my use case - so not much use to others. If more people are interested, I might refactor into a class and share it.

But the main purpose of my previous post is ZipArchive is a simple way to extract the files for installation. Have a self updater is also great when you want to quickly test some code changes on a different test environment.