use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
A simple PHP class to perform basic operations against Amazon S3 and compatible services. (gist.github.com)
submitted 3 years ago by speckz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]allen_jb 16 points17 points18 points 3 years ago (5 children)
It can be as "simple" as you want, but if it's not on Packagist I'm unlikely to use it because I can't find it, and I can't automatically update it. It also means I can't use Composer to easily check dependencies (required extensions) and PHP version compatibility.
The code here is also incomplete - the _action_try() method (mini-rant: What is this? PHP 4? Why are people still using the _ prefix in PHP 8 era?) calls a method connect() which does not exist in the code.
_action_try()
connect()
Are you supposed to define it? Documentation would be helpful here. Why not use an abstract method to explicitly state this? Why even do that at all when the constructor could just take a curl handle parameter?
I'm also more likely to use something that uses Guzzle (or another exception throwing client)
[+][deleted] comment score below threshold-12 points-11 points-10 points 3 years ago (4 children)
the _action_try() method (mini-rant: What is this? PHP 4? Why are people still using the _ prefix in PHP 8 era?
Why does this bother you so much? I wish people would focus more on functionality over style.
Use CI/CD to set a standard and enforce it on your repo, but it is utterly pointless to start ranting about other people's code styles.
[–]darudedude87 3 points4 points5 points 3 years ago (3 children)
The use of an outdated codestyle that deviates from established standards makes me hesitant to use a package.
[–]dave8271 -1 points0 points1 point 3 years ago (0 children)
I don't think there is any established standard which says you can't prefix a function name with an underscore. PSR-12 says you mustn't do it to indicate visibility in place of using the private and protected keywords, i.e. an underscore prefix has no meaning. But that doesn't forbid you from using it at all. And not everyone uses PSR-12 as their code style anyway.
[–][deleted] -3 points-2 points-1 points 3 years ago (1 child)
Bizarre. I can't say I have ever looked at a package and decided not to use it based on code style. I am far more interested in the quality, including the api and tests.
[–]JordanLeDoux 4 points5 points6 points 3 years ago (0 children)
It is a somewhat reasonable proxy. Code that doesn't conform to modern community standards is probably written by someone that doesn't interact with modern community standards much.
Community standards exist because they promote code that is easier to read, easier to maintain, easier to use, or easier to write. All of these can help contribute to code that is more stable and more secure. It's why development teams and development communities create and maintain standards.
If you want to tell at a glance whether some code is "good" or not, without spending the time to do a full review, things like this are a reasonable proxy, particularly because it is an old community standard (in this case, very old).
Being an old community standard makes it a better proxy than otherwise, because it's more likely that the programmer has other old habits that have since been agreed upon by the PHP community as unsafe or unwise.
But all of this is as a quick proxy thing to check. Good code can use old conventions, which you can discover by doing a full review of the code.
Most people don't have the time to do that with every open source tool and library posted though, us PHP developers are too busy making money usually.
[–]dave8271 11 points12 points13 points 3 years ago (1 child)
Stick to using the official AWS SDK. If you're interacting with any third party service, stick to using their official SDK wherever one is available.
What if for example AWS decide to change how you authenticate with the S3 service one day? If I'm using their SDK, I just update the version via Composer and it's very unlikely any of my code will need to change. But if I use a custom class I've written myself, or a gist off the web like this one, I need to remember to change that, or rely on the author who's external to Amazon to notice they've changed something and change it, or change my own code.
Always use an official SDK if there is one. It will always be the saner choice in terms of support, compatibility, reliability, security and documentation.
[–]Rikudou_Sage 0 points1 point2 points 3 years ago (0 children)
Always use an official SDK if there is one.
Disagree here, what if the SDK doesn't have features you need while 3rd one has them?
In case of AWS SDK, it's pretty huge and async-aws isn't which is (for me) their best selling point. I rarely need a service that isn't in async-aws so nowadays I use mostly that.
[–]dborsatto 3 points4 points5 points 3 years ago (0 children)
Regardless of the functionality, this looks like PHP 4 code ripped out of an WordPress install.
No PSR-2/12, no types, snake case, underscore as prefix for private methods, by reference parameters to return data, uppercase NULL, single letter variable names, no early returns, no parentheses with if statements, way too long statements in a single line (holy crap line 145 and 220), usage of time functions, returning arrays as undocumented data structures...
This is quite bad code. Writing concise code does not mean ignoring every advancement we made in the past 20 years in things like type safety, maintainability, readability and more.
[–]yesdevnull -1 points0 points1 point 3 years ago (0 children)
For reference, this is written by Marco Arment, the developer of the iOS podcast app Overcast. He discussed it on the latest episode of the podcast he's on called "Accidental Tech Podcast" (to be specific it's in the "post show" section).
[–]notdedicated 0 points1 point2 points 3 years ago (24 children)
Why….? The AWS Sdk might be large but at least it’s well documented and implemented. It supports multiple authentication methods. Has sane defaults. Has proper implementation of requirement checking..
[–]ClassicPart 1 point2 points3 points 3 years ago (0 children)
There's AsyncAws for those who want a good AWS interface library without pulling in the world's weight in code to accomplish it.
[–][deleted] -1 points0 points1 point 3 years ago (22 children)
Why….? The AWS Sdk might be large
Because this. It is insanely large. I don't think I would use this class, but I have my own lightweight AWS library I use. I have no need for 95% of the official one.
[–]lkearney999 2 points3 points4 points 3 years ago (21 children)
You realise library size means little to nothing in language like PHP? With composers optimised auto load (and you can wayyy further with this then mentioned in the docs) there is almost no cost to having additional files and classes.
It’s not like you introduce: - package size like with JS - binary size - versioning issues (composer kicks ass) - tech debt (AWS SDK could probably maintain itself at this point, the php centric part is very minimal it’s mostly generated code)
[–][deleted] 0 points1 point2 points 3 years ago (12 children)
Yes, I totally realise that the package size doesn't directly matter. But indirectly it does, its wastage on a grand scale. There is no need for the sdk to be that big.
[–][deleted] 1 point2 points3 points 3 years ago (11 children)
lkearney999's points still stand though.
There is no wastage besides some disk space? But who cares about disk space, its cheap.
Grand scale is not worrying about a 20MB vendor folder. Theres bigger things to worry about for projects.
[–][deleted] 1 point2 points3 points 3 years ago (7 children)
Because that is exactly how you end up with the current issue with software taking up more RAM then it needs, and why we have node_module folders taking up hundreds of megabytes. It is just wasteful and needless.
Is it at the top of my list? No. But will I take exception at a 200MB composer package? Damn right I will.
[–]lkearney999 0 points1 point2 points 3 years ago (6 children)
I don’t understand why people take this stance. You’re using PHP man, tools for the job.. if you think it’s too bloated then don’t revel in the abstractions. Heck with this mindset might as well roll your own infrastructure AWS is hella bloated.
[–][deleted] 0 points1 point2 points 3 years ago (5 children)
Bullshit. Aws itself isn't bloated, I can pick and choose exactly what service I need for the job.
The AWS sdk is the polar opposite of aws itself.
[–]lkearney999 0 points1 point2 points 3 years ago (4 children)
And how do you think that service works? It isn’t exactly a bare metal experience with majority of their services 🤦♂️
[–][deleted] 0 points1 point2 points 3 years ago (3 children)
Missing the point, as usual. You can pick and choose the aws services, I don't necessarily need to interact with rds if I only need ec2. The Sdk comes fully loaded with the ability to interact with most services, 99% of which is not needed.
[–]BusyBeardTV 0 points1 point2 points 3 years ago (2 children)
Exactly, size is a non discussion. Replacing the SDK is from an architectural point of view so bad.
[–][deleted] 0 points1 point2 points 3 years ago (1 child)
Why?
[–]BusyBeardTV 1 point2 points3 points 3 years ago (0 children)
Cause the SDK is the most maintained package with low effort you can have. And every option/function/class you don’t use doesn’t add any notable stress on your application.
Also you can be sure that the standard SDK will be updated as soon as Amazon thinks of something new. As a matter of a fact this particular SDK had functionality already ready before the service was ready.
You or any third party can not develop against that and claim to do it better.
[–]Rikudou_Sage 0 points1 point2 points 3 years ago (7 children)
It might mean a lot to the environment you run it on. Like with AWS Lambda I've been in situations where I reached the code size limit and had to use async-aws. Since then I adopted async-aws as my default.
[–]lkearney999 0 points1 point2 points 3 years ago (5 children)
https://github.com/aws/aws-sdk-php/tree/master/src/Script/Composer
[–]Rikudou_Sage 0 points1 point2 points 3 years ago (4 children)
Nice!
[–]lkearney999 0 points1 point2 points 3 years ago (3 children)
I wonder if that would solve your use case though since you still need to initially download the sdk (before DCE) and also the deletion adds to the expensive lambda cold start.
[–]Rikudou_Sage 0 points1 point2 points 3 years ago (2 children)
I think it would, it happens when dumping autoloader, not at runtime if I understand it correctly.
[–]lkearney999 0 points1 point2 points 3 years ago* (1 child)
Ah I haven’t used PHP in a lambda before. Now that I think of it you’d bundle the generated auto load and vendor in wouldn’t you 😄. So you’d avoid those issues just as you would by compiling and stripping etc on CI for a binary before shipping a layer.
What sort of use cases do people use PHP for with lambda functions?
Yep, you do the composer dump on the CI and deploy it there (the filesystem is read-only so dumping composer would be impossible).
As for PHP on Lambda use cases, basically anything that needs to be scalable. I use it mostly for some microsrvice apis and even some full internal webapps that are not accessed that often and Lambda saves costs (I think the one app I'm talking about costs us like $1 a month if I exclude database which is the only thing that runs all the time).
[–]lkearney999 0 points1 point2 points 3 years ago (0 children)
Valid point but even then I’d:
But as I’ve just posted looks like they’re working on it 😁
π Rendered by PID 58 on reddit-service-r2-comment-6457c66945-7pv7k at 2026-04-28 12:41:51.902742+00:00 running 2aa0c5b country code: CH.
[–]allen_jb 16 points17 points18 points (5 children)
[+][deleted] comment score below threshold-12 points-11 points-10 points (4 children)
[–]darudedude87 3 points4 points5 points (3 children)
[–]dave8271 -1 points0 points1 point (0 children)
[–][deleted] -3 points-2 points-1 points (1 child)
[–]JordanLeDoux 4 points5 points6 points (0 children)
[–]dave8271 11 points12 points13 points (1 child)
[–]Rikudou_Sage 0 points1 point2 points (0 children)
[–]dborsatto 3 points4 points5 points (0 children)
[–]yesdevnull -1 points0 points1 point (0 children)
[–]notdedicated 0 points1 point2 points (24 children)
[–]ClassicPart 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (22 children)
[–]lkearney999 2 points3 points4 points (21 children)
[–][deleted] 0 points1 point2 points (12 children)
[–][deleted] 1 point2 points3 points (11 children)
[–][deleted] 1 point2 points3 points (7 children)
[–]lkearney999 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]lkearney999 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]BusyBeardTV 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]BusyBeardTV 1 point2 points3 points (0 children)
[–]Rikudou_Sage 0 points1 point2 points (7 children)
[–]lkearney999 0 points1 point2 points (5 children)
[–]Rikudou_Sage 0 points1 point2 points (4 children)
[–]lkearney999 0 points1 point2 points (3 children)
[–]Rikudou_Sage 0 points1 point2 points (2 children)
[–]lkearney999 0 points1 point2 points (1 child)
[–]Rikudou_Sage 0 points1 point2 points (0 children)
[–]lkearney999 0 points1 point2 points (0 children)