Download the PHP package renoki-co/laravel-ec2-metadata without Composer

On this page you can find all versions of the php package renoki-co/laravel-ec2-metadata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ec2-metadata

Laravel EC2 Metadata

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Retrieve the EC2 Metadata using Laravel's eloquent syntax.

🤝 Supporting

If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, sponsor our work with Github Sponsors. 📦

🚀 Installation

You can install the package via composer:

🙌 Usage

The package was made to be easier for you to implement your own methods and keep it simple, without hassling too much about requests.

In this brief example, you can calculate the seconds left until the EC2 Spot instance will be terminated.

Setting Version

The default version of the Ec2Metadata class is latest, but to avoid your code to break due to API changes, define the version to run on.

You can see the list of available versions in IMDSv2 documentation, under Get the available versions of the instance metadata:

Calling Custom Endpoints

The IMDSv2 API is pretty complex, and there are some functions you can use from the Ec2Metadata class, just for convenience. When you want to retrieve data from an endpoint that's not implemented, you can either define a macro or use the get() and getJson() functions to retrieve in plain-text or as a JSON-decoded array:

Take this example for retrieving the kernel ID (under /meta-data/kernel-id):

To retrieve JSON values, you may call getJson. This will work properly only if the expected value from the endpoint you call will be a JSON-encoded response.

In the implementation, terminationNotice uses the getJson() to retrieve the response:

Macros

Alternatively to using get() and getJson(), you can define macros:

Testing Your Code

The package is using HTTP Client, a Laravel feature that leverages Guzzle and you can handle requests and test them by mocking responses.

Testing properly your app means you should be fully trained with the AWS EC2's IMDSv2 API, in order to provider appropriate responses.

When pushing the responses in testing, make sure to take into account that the first call would be the token retrieval.

🐛 Testing

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

🎉 Credits


All versions of laravel-ec2-metadata with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
guzzlehttp/guzzle Version ^6.5|^7.0
illuminate/http Version ^9.0
illuminate/support Version ^9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package renoki-co/laravel-ec2-metadata contains the following files

Loading the files please wait ....