coatimundi Posted October 3 Share Posted October 3 Hey everyone. It's been over a decade since I've worked with PHP's zipping functionality. I did a project in about 2010 that automatically downloaded MLS files from an FTP server and put the info into a database. Since then, I've mostly been in .Net and Golang. I think, at the time, I used the Zlib library. I'm now working on a project where I'm dealing with gz files from a Linux machine, and I don't think Zlib is the way to go. I'd need to download the files, unzip them on the server, do some light parsing, then store them in another location. Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/332088-zip-best-practices/ Share on other sites More sharing options...
gizmola Posted October 3 Share Posted October 3 ZLib is the way to go if you need to uncompress a gzipped file with PHP. See https://www.php.net/manual/en/function.gzdecode.php What you need in order to download the files depends on what the server that is hosting these files supports, but PHP has a full array of client library options, so if you have some more details, we might be able to give you more advice. FTP is certainly considered technology to avoid, with SFTP at the minimum being recommended. A simple secured web application would be preferred, and you could use guzzle to connect and download the files securely so long as the server supplies HTTPS, which absolutely every server should be doing now that we have many options for free SSL certs. An alternative client library that is better equipped to support multiple simultaneous downloads is AMPHP http-client but unless you have a pressing need for that feature, I'd stick with Guzzle. The biggest hurdle in doing something with modern PHP for someone with a decade long gap in their experience with PHP, is in understanding how to set the project up for dependency management under Composer, and understanding PHP namespaces, how to structure your project, and how to use the composer generated autoloader. These are things you want to do, but once in place should make the process of creating this feature easy and effective. Quote Link to comment https://forums.phpfreaks.com/topic/332088-zip-best-practices/#findComment-1661377 Share on other sites More sharing options...
coatimundi Posted October 3 Author Share Posted October 3 Hi there, and thanks for your response. Good to know that ZLib is still the standard, so that will hopefully make it easier. And it was my last project that used FTP. This is a publicly-available site, so will be using HTTPS. It's going to take some work since it's behind a login though. I don't know that it'll end up being a big enough project for Composer, but I'll keep that in my mind. I'll also look into Guzzle, since this is the first I've heard of it. Quote Link to comment https://forums.phpfreaks.com/topic/332088-zip-best-practices/#findComment-1661378 Share on other sites More sharing options...
gizmola Posted October 5 Share Posted October 5 4 hours ago, coatimundi said: And it was my last project that used FTP. This is a publicly-available site, so will be using HTTPS. It's going to take some work since it's behind a login though. I don't know that it'll end up being a big enough project for Composer, but I'll keep that in my mind. I'll also look into Guzzle, since this is the first I've heard of it. Guzzle has no problem handling logins. It's a programmatic HTTP client. I'm not sure what you think composer actually does. For PHP it's the equivalent of using npm with javascript, pip with Python or Cargo for Rust. It's the way you will bring in and utilize libraries in your project. Quote Link to comment https://forums.phpfreaks.com/topic/332088-zip-best-practices/#findComment-1661417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.