Overview
Temporal Integration with Laravel is a guide on how to integrate Temporal, a workflow automation platform, with Laravel, a PHP framework. The article provides step-by-step instructions on installing and setting up the necessary dependencies to use Temporal in a Laravel project.
Features
- Compatibility: Temporal Integration with Laravel requires PHP 7.4 and Laravel 8, or higher.
- Composer Package: The Temporal PHP SDK can be installed as a composer package.
- gRPC Extension: The PHP gRPC engine extension must be installed and activated to communicate with the Temporal Server.
- RoadRunner Application Server: The Temporal PHP SDK requires the RoadRunner 2.0 application server to run Activities and Workflows in a scalable way.
- Temporal Server: The Temporal Server needs to be downloaded and started locally for the samples to work.
- Configuration Update: The temporal address in
.rr.yamlneeds to be updated tolocalhost:7233. - Database Setup: The
.envfile needs to be updated with the database name, username, and password. - Mail Driver Setup: The mail driver needs to be set up according to the application’s needs.
- Migration and App Run: Migration and starting the application are the final steps to complete the setup.
Installation
To install Temporal Integration with Laravel, follow these steps:
Step 1: Make sure you have PHP 7.4 and Laravel 8, or higher, installed.
Step 2: Install the Temporal PHP SDK using the following composer command in the root of your project:
composer require temporal/sdk
Step 3: Install the gRPC PHP extension by following the instructions at this link. Ensure that you perform all the steps to activate the gRPC extension in your php.ini file and install the protobuf runtime library in your project.
Step 4: Download the RoadRunner 2.0 application server, either manually by downloading its binary from the release page or through other means.
Step 5: Download and start the Temporal Server locally. Execute the following commands to start a pre-built image along with all the dependencies. Refer to the Temporal docker-compose repository for more advanced options.
Step 6: Update the temporal address in .rr.yaml to localhost:7233.
Step 7: Start the application using RoadRunner by running the appropriate command in the rr.yaml file.
To complete the local setup of the Laravel application:
Step 1: Install the required Composer dependencies.
Step 2: Install the required Node dependencies to build the JavaScript files and CSS for the app.
Step 3: Set up the database by opening the .env file and updating the DB_DATABASE to the name of your database, as well as setting a username and password if needed.
Step 4: Set up the mail driver according to the application’s needs. For local testing and debugging, the mail driver can be set to log.
Step 5: Run migration to prepare the database.
Step 6: Start the application.
Summary
Temporal Integration with Laravel is a comprehensive guide that walks through the installation and setup process of integrating Temporal with Laravel. It covers the key features required for the integration and provides step-by-step instructions for installing the necessary dependencies and configuring the application. Following the provided guide will allow developers to utilize Temporal’s workflow automation capabilities within their Laravel projects.