How to Deploy a Laravel PHP App to AWS Elastic Beanstalk using CodePipeline
This article demonstrates how to deploy a PHP (Laravel) application to Elastic Beanstalk using AWS CodePipeline. A breakdown of the article is as follows.
Table of Contents
- What is AWS CodePipeline?
- AWS CodePipeline vs. GitHub Actions.
- Deploy PHP Application to Elastic Beanstalk using CodePipeline.
- Deploy from GitHub to Elastic Beanstalk via CodePipeline.
This article is a complete walkthrough; by the end, you’ll have a CodePipeline ready to auto-deploy from GitHub to Elastic Beanstalk.
Before We Deploy to AWS Elastic Beanstalk from GitHub, We Must Have a Laravel App
If you’re replicating the steps of this walkthrough, make sure you do the following.
- Fork or clone this repository from GitHub.
- Deploy the PHP Laravel application to Elastic Beanstalk.
Don’t worry if you are not familiar with Elastic Beanstalk. FuelingPHP’s “Host and Deploy a Laravel PHP App to AWS Elastic Beanstalk” is a complete walkthrough of AWS Elastic Beanstalk and could help you understand deployment to AWS Elastic Beanstalk. This article uses the same linked repository – a sample Laravel application.
This article is a continuation or an extension of the previous article, where we deployed a Laravel application to Elastic Beanstalk. We left a side note about CI/CD pipeline and how that can help us deploy from the GitHub repository whenever there’s a change.
So, let’s build a CI/CD pipeline using AWS CodePipeline.
Background on AWS CodePipeline. What is it?
AWS CodePipeline is an AWS service for continuous delivery. Continuous delivery is a popular concept in agile software development, where code changes are automatically prepared for deployment to a production server. As it is a widespread industry practice, there’s much to expand on CI/CD (Continuous Integration/ Continuous Delivery).
You can learn more about CI/CD in this starter’s blog.
So, AWS CodePipeline will integrate with the Laravel GitHub repository and detect changes. It will deploy the Laravel app changes to AWS Elastic Beanstalk in the last article. Nevertheless, you can also host a sample application from scratch. The walkthrough is equally valid for any scenario.

AWS CodePipleline can integrate with third-party servers like GitHub and Bitbucket, as well as other AWS services, including S3, ECR, and CodeCommit. It offers one active pipeline per month free of cost. AWS charges $1 monthly for every active pipeline, excluding the free tier. Learn more about the price plan here.
Alternative to CodePipeline? GitHub Actions?
CodePipeline is a continuous delivery pipeline from Amazon. GitHub also has a CI/CD platform called GitHub Actions. It is a promising feature from GitHub that comes with many built-in actions from the GitHub marketplace and helps you define an end-to-end deployment and integration pipeline.
Here’s a comparison between CodePipeline and GitHub Actions.
CodePipeline | GitHub Actions |
Supports GitHub, AWS CodeCommit, BitBucket, and Amazon S3 | Supports GitHub only. |
The free tier offers one pipeline with 50 minutes per month | Free for public repositories: 2000 build minutes per month. |
It works best with AWS; in theory, it could deploy to other cloud platforms. | Works with any environment, including AWS. |
IAM role defined. No need to worry about user credentials. | Store IAM user secrets in repository secrets. |
Comes with pre-built integrations provided by AWS. | GitHub marketplace has thousands of integrations available that you can use as actions in your CI/CD. |
Pipeline as Code possible with CloudFormation or Terraform. | Uses Pipeline as Code – a .yml file. |
Interested in GitHub Actions? Learn how to deploy Laravel PHP on AWS Elastic Beanstalk using GitHub Actions at FuelingPHP.
Deploy Our Laravel PHP App from Github to AWS Beanstalk using CodePipeline
1. Click Create Pipeline in the CodePipeline dashboard.

2. Provide a Pipeline name, leaving the rest of the settings as such, and click Next.

3. In the Source Provider drop-down, select GitHub (version 2) and click Connect to GitHub.

4. In the new window, provide a Connection name and click Connect to GitHub.

5. Next, click Install a new app.

6. On the GitHub auth window, click on your GitHub profile.

7. Select the correct repository, then click Install.

8. Back to AWS, select the correct repository and branch, then click Next.

9. Click on Skip Build Stage.

10. Select Elastic Beanstalk as the deploy provider in the deployment stage. Choose the application name and environment. Then click Next.

11. Next, review the details of the pipeline and then click Create Pipeline. The creation will take a while.
12. The pipeline will be created and will start deploying from the source (GitHub) to the destination (Elastic Beanstalk).

Congratulations! We have created a pipeline to auto-deploy from GitHub to Elastic Beanstalk. Let’s put it to the test right away.
Commit and Push to Github to Deploy PHP App to Elastic Beanstalk using CodePipeline
Open your Laravel project locally and run the following command in the local main branch.
git pull origin main
Make a small change – it could be as simple as adding a comment. Afterward, run the following two commands
git commit -am “your commit message”
git push origin main
Switch to the CodePipeline in the AWS, and you’ll see that deployment has been initiated.

Voila! We have successfully tested the pipeline, and it has worked. So, it is time for a goodbye until next time 🙂
Deploy Laravel to Beanstalk Using CodePipline & Github
This article demonstrates how to deploy a PHP Laravel app in Github to AWS Elastic Beanstalk using CodePipeline. AWS CodePipeline is a CI/CD platform from Amazon that helps you readily set up a pipeline from your code repository to Elastic Beanstalk. The article overviews CodePipeline and also discusses an alternative – GitHub Actions.
The last two sections include the bulk of the article as they explore how to create a pipeline and put it to the test by committing to the source repository in GitHub. Hopefully, you’ve enjoyed the article. Stay tuned for more at FuelingPHP.
Hosting Web Applications in AWS
This article is part of our series to make AWS easy. We love AWS, but let’s be honest. It isn’t effortless. Like way too complicated. We’ve created this learning path to help level you up and get your PHP app onboarded fast.
- Is AWS Cloud Services Hard to Learn?
- Why AWS is so Popular
- AWS PHP Website & Application Hosting Options
- Using PHP in AWS Lambda: Comparing Options
- Deploy Laravel to Elastic Beanstalk using GitHub Actions
- Deploy Laravel from Github to Elastic Beanstalk via CodePipeline
- Install LAMP Stack on AWS EC2
- Install AWS SDK for PHP
- Host and Deploy a Laravel PHP App to AWS Elastic Beanstalk
- Amplify vs Elastic Beanstalk
- AWS App Runner Review
- App Runner vs Elastic Beanstalk
- App Runner vs Fargate
- Elastic Beanstalk vs AWS Lightsail
- Elastic Container Service vs Beanstalk
- Setup & Use AWS Parameter Store in PHP
- How to use AWS Secrets Manager with PHP
- PHP & AWS S3