Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 354 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AWS SDK with Lumen

#1
I'm trying to install AWS Laravel SDK with lumen.
I could install it with:

{
"require": {
"aws/aws-sdk-php-laravel": "~3.0"
}
}

But then, documentation says:





> Find the providers key in your config/app.php and register the AWS Service Provider.

'providers' => array(
// ...
Aws\Laravel\AwsServiceProvider::class,
)
>Find the aliases key in your config/app.php and add the AWS facade alias.

'aliases' => array(
// ...
'AWS' => Aws\Laravel\AwsFacade::class,
)


Thing is in Lumen, there is no config/app.php

How can I do it???
Reply

#2
You can copy default Lumen Configuration files to override them.

> Configuration Files
>
> You may use full "Laravel style" configuration files if you wish. The
> default files are stored in the vendor/laravel/lumen-framework/config
> directory. Lumen will use your copy of the configuration file if you
> copy and paste one of the files into a config directory within your
> project root.
>
> Using full configuration files will give you more control over some
> aspects of Lumen's configuration, such as configuring multiple storage
> "disks" or read / write database connections.

Reference:

[To see links please register here]

Reply

#3
In bootstrap/app.php, add following:

Provider:
> $app->register(Aws\Laravel\AwsServiceProvider::class);

Facade
>class_alias('Aws\Laravel\AwsFacade','AWS');

* Please note that you have to uncomment $app->withFacades(); in order to work the facade.
Reply

#4
I was a little confused at first too so where's what I ended up doing.

1. Install the AWS Laravel SDK (

[To see links please register here]

) using Composer.
2. Update app.php to include ``$app->register(Aws\Laravel\AwsServiceProvider::class);``
3. Add my AWS credential/region values to my .env file
4. Create a method in one of my helper classes which is defined as follows:

``public static function getS3Instance() {
return new \Aws\S3\S3Client([
'version' => 'latest',
'region' => env('AWS_REGION'),
'credentials' => [
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET')
]
]);
}``

In a model I simply call Util::getS3Instance() and boom I have everything I need to start using S3. This function could be easily adapted to return an instance of any of the AWS clients included in the library.

This is all taking place in a Lumen 5.6 project but I would assume the same approach would work for older versions of Lumen as well. I hope this helps!


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through