No worries anymore for updated php files when uploading newly generated appgini files.

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
herman
Posts: 5
Joined: 2022-07-31 10:15
Location: New Zealand

No worries anymore for updated php files when uploading newly generated appgini files.

Post by herman » 2022-07-31 21:26

Good morning everybody.
This will be my first post even though I'm using appgini for years, I liked to stay in the background. A few times I communicated with Ahmed and talked about how I secure all my updated files when I update them with the newly generated appgini files.
Let me explain my outlay here first.
On my Windows10 Pro home computer, I run a WAMP stack for testing the appgini generated programs, after which I upload them to my server through FTP. On my live server (Ubuntu 20.04) I run the created programs and the public has access to them. On the server, I make all my updates to the php files, so they suit special needs and layouts. However, each time I make updates to the appgini application on my home computer and generate the new files after which I upload all the files again through FTP to my server, the updated server files are overridden and I have to manually update all the php files again.
Well, I'm lazy, and over time there are so many files that I made upgrades to, that it is hard to keep track of them all, and of what the upgrades were when I edited the file(s).
I explained to Ahmed my solution and he opted for the possibility to share my way with the rest of the appgini community. So here we go.

Let's explain the way I do it using an example.
I want to have a background picture on the login page so I do what is described in another post and edit the "/hooks/footer-extras.php" file and include the code needed to do this. I know that with the next update, this file will be overridden by a new generated appgini php file, so I make a backup copy of the file I altered and name it "footer-extras.php.backup". This backup file is located in the same /hooks folder.
Next I go to my crontab and enter there a line that tells the server to copy the "/hooks/footer-extras.php.backup" and override the "/hooks/footer-extras.php" file. The time setting for this cron job is set to every minute.

So in short......
I changed something to the appgini application on my home computer and generated the new files. I FTP upload these new files to my server and within a minute all my individual file enhancements that I made to the php files on the server are back through my cronjob.

No need to keep track of what files I updated and what updates I had put in them. As this is an automatic cron process that is executed every minute.
This is just the way I do it, and I hope that this trick will help some of you out too.

Cheers
No need to work harder,.... just be smarter....😉😉👍

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: No worries anymore for updated php files when uploading newly generated appgini files.

Post by AhmedBR » 2022-07-31 23:08

I am not sure I understood the purpose of the cron, here are a couple of questions:

Hooks are never overwritten.
Why not just make the files that you do not want overwritten read only and that is it?
Make them three questions:
what about the files you edited and must be overwritten and reedit?
(like home if you add some extra table, otherwise the new table will not appear)
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

herman
Posts: 5
Joined: 2022-07-31 10:15
Location: New Zealand

Re: No worries anymore for updated php files when uploading newly generated appgini files.

Post by herman » 2022-08-24 00:58

The way I understand appgini works is that every time you generate the php files in the appgini application, all the files are generated. That means also all the files in the /hooks/ folder. When you add more tables to your program the new table-specific php files are also generated. There is also a new "empty" footer-extra.php file generated. Now, when I upload all the generated files to the server, I can only do that using the allowed ftp user account.
That means that when my new files arrive on my server, the owner of all the files is the ftp user. For safety reasons the ftp user can not run any script on the server so the folders and all the files belonging to the appgini application have to be CHOWN and CHGRP to the server user "www-data". I have now on the server all the files as generated by the appgini application. That means also the "empty" footer-extra.php file. The old "edited" footer-extra.php files however is still on the server as "footer-extra.php.backup". Within a minute a cron job is running, with the copy command to copy the "footer-extra.php.backup" file on top of the "footer-extra.php" file. This means that all my editing and added extras are back in place.

I have a total of 14 different files in my appgini application that have added features and editions created in them. From all these 14 files i have made a backup copy that is processed as explained above.
In my server's crontab I have a copy command created for each of these files. (14 command lines)
This means for me that extending the functionality of my appgini application can be easily done on my home computer and tested locally on my WAMP stack. Then, when everything works, I upload the whole package to my server and CHOWN CHGRP all the files and folders to www-data. Within a minute all the special files (14 in total) are replaced with their backup copy. This means that background images, table layouts, colors, are all back the way I had them on the server before.

Post Reply