Reputation: 19695
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???
Upvotes: 1
Views: 5167
Reputation: 3917
I was a little confused at first too so where's what I ended up doing.
$app->register(Aws\Laravel\AwsServiceProvider::class);
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!
Upvotes: 1
Reputation: 2365
In bootstrap/app.php, add following:
Provider:
$app->register(Aws\Laravel\AwsServiceProvider::class);
Facade
class_alias('Aws\Laravel\AwsFacade','AWS');
Upvotes: 4
Reputation: 111829
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: http://lumen.laravel.com/docs/installation#configuration-files
Upvotes: 0