This blog and video runs through getting started with PHP and S3. The subsequent code is all open source in the GitHub page located at the below link.
https://github.com/JoeMrCoffee/yourS3objects
Previously we looked at MinIO using it's console and UI, as well as quick set up in docker. This is a slightly more advanced look at interacting with object storage from a programmatic standpoint.
PHP has an open SDK to tie in with S3 object storage that is provided by AWS. The video, as well as the source code in GitHub installs the SDK as part of the Docker bring up and build. This is done in the Dockerfile, and is very similar to installing the MongoDB packs required to make a PHP connection to a MongoDB database.
From the code all the connection information to the S3 object store is in the 'header.php' file. If one wanted to use this site, or just its source code, they could also adjust the endpoint to the appropriate values. The 'header.php' file gets included in all the subsequent pages using the PHP include command, so everything else will follow the values in the header.php file.
The video talks a bit about the usefulness of the site. I developed it mostly as a reference for how the SDK could be used, but the actual site might be useful as a quick way for teams to just store and manage files in a particular bucket that only the admin or host could adjust.
Some more useful reference is below:
- MinIO documentation
- Linode AWS SDK for PHP
- PHP manual around file uploads - not about S3, but reinforces how the file upload process is handled with PHP
No comments:
Post a Comment