You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using [aws/aws-sdk-php](https://github.com/aws/aws-sdk-php/tree/master/src/Script/Composer) or [google/apiclient](https://github.com/googleapis/google-api-php-client#cleaning-up-unused-services)? See the links for reducing deployment size by removing unused services
46
-
</Callout>
47
-
48
44
Now is also the best time to configure your project for production, as well as build any file cache if necessary.
49
45
50
46
Once your project is ready, you can deploy via the following command:
@@ -62,6 +58,46 @@ Once your project is ready, you can deploy via the following command:
62
58
</Tab>
63
59
</Tabs>
64
60
61
+
### Reducing package size
62
+
63
+
AWS Lambda has a **250MB size limit** for deployed applications (unzipped). Large Composer dependencies can push your project over this limit and also lead to slower cold starts.
64
+
65
+
The most common offender is `aws/aws-sdk-php`: it ships clients for **every** AWS service, adding over 100MB to your vendor directory. If you only use a few services (e.g. S3, SQS, DynamoDB), you can remove the rest.
Then run `composer install` (or `composer update`) to apply the changes. Adjust the list to keep only the AWS services your application actually uses. Note: `S3`, `Kms`, `SSO`, and `Sts` cannot be removed as they are required by the SDK core.
88
+
89
+
[Read more in the `aws/aws-sdk-php` documentation.](https://github.com/aws/aws-sdk-php/tree/master/src/Script/Composer)
90
+
91
+
<Callouttype="info">
92
+
As an alternative, you can replace `aws/aws-sdk-php` with [AsyncAws](https://async-aws.com/), a lighter SDK that only installs the services you need.
93
+
</Callout>
94
+
95
+
Using `google/apiclient`? A similar approach is available: [see the documentation to remove unused Google API services](https://github.com/googleapis/google-api-php-client#cleaning-up-unused-services).
96
+
97
+
To further reduce deployment size, exclude non-essential files (tests, assets, node_modules) from the package. [Read more in the serverless.yml exclusions documentation.](environment/serverless-yml.mdx#exclusions)
98
+
99
+
If your application still exceeds the 250MB limit, you can [deploy via Docker images instead](deploy/docker.mdx).
100
+
65
101
## Environments
66
102
67
103
We can deploy the same application multiple times in completely separated environments (also called "stages" by the Serverless CLI).
Copy file name to clipboardExpand all lines: docs/laravel/getting-started.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,10 @@ At the moment, we deployed our local codebase to Lambda. When deploying for prod
76
76
77
77
Follow [the deployment guide](/docs/deploy.md#deploying-for-production) for more details about deploying in general.
78
78
79
+
<Callouttype="warning">
80
+
Most Laravel applications use `aws/aws-sdk-php` (pulled in by packages like SQS queues, S3 storage, etc.). This package is **very large** (100MB+) and can push your deployment over Lambda's 250MB size limit. Make sure to [remove unused AWS services](/docs/deploy.md#reducing-package-size) to reduce the deployment size.
81
+
</Callout>
82
+
79
83
Specifically for Laravel, Bref will automatically cache the configuration on "cold starts". This means that you don't need to run `php artisan config:cache` before deploying.
Copy file name to clipboardExpand all lines: docs/runtimes/function.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,6 +248,10 @@ You first need to install the AWS PHP SDK by running
248
248
$ composer require aws/aws-sdk-php
249
249
```
250
250
251
+
<Callouttype="info">
252
+
The `aws/aws-sdk-php` package is very large (100MB+). To avoid hitting Lambda's 250MB size limit, [remove unused AWS services from the package](/docs/deploy.md#reducing-package-size).
0 commit comments