Before you begin the integration process, make sure you have the following:
- API Access Token: To authenticate your Laravel application with CommandK, you'll need an API access token. If you haven't obtained one yet, refer to this link for instructions on how to acquire it.
Follow these steps to integrate CommandK with your Laravel application:
If you haven't already created a Laravel application, you can set up a new project using the Laravel CLI or any other preferred method. Here, we'll use the Laravel CLI for demonstration:
Install the Laravel CLI globally if you haven't already:
composer global require laravel/installer
Create a new Laravel project using the following command:
laravel new my-laravel-app
my-laravel-appwith your desired project name.
Navigate to the project directory:
Inside your Laravel application, you can access secrets as environment variables. Open the appropriate file (e.g.,
.env) and add the following code snippet to access an environment variable:
In this code,
COMMANDK_SECRET_KEY is the environment variable that will store your secret.
To run your Laravel application with the CommandK CLI, you can use the following command:
$ cmdk run <application-name> --environment development -- php artisan serve
<application-name> with the actual name of your Laravel application. This command will execute your Laravel application, running the development server.
By following these instructions, you can seamlessly integrate the CommandK CLI with your Laravel application, making it easy to manage secrets and run your application securely.
Updated about 2 months ago