Run the Laravel PHP sample app
Run the Laravel PHP sample app and connect it to your Kontent.ai sample project to see how your content is displayed.
A quick checkMake sure you have the following ready:
Prepare your sample project
Kontent.ai comes with a few sample projects to showcase best practices. The PHP sample app is built around one of them.
Here’s how you can create your own sample project:
You now have a project named Sample Project you can use with the sample app!
- In Kontent.ai, click your initials in the bottom left corner.
- Select Projects.
- At the end of the list, click Create complete sample project.
- Select a subscription for the project.
- Click Create project.
Clone the app
Clone the sample app's repository to your device.
Run the app
- In your command line, navigate to the sample app folder.
composer install to install the app dependencies.
composer run prepare-environment to create a sample Laravel environment file.
- Without the environment file present, PHP will throw a warning. However, this doesn’t prevent you from starting the app.
php artisan serve to start the app.
127.0.0.1:8000 in your browser to see the running sample app.
Connect your Kontent.ai project
By default, the sample app uses a shared Kontent.ai sample project.
We recommend connecting the app to your own Sample Project so you can freely make changes and play with it.
Now, let's explore the Sample Project and update its content so that you can see the changes reflected in your locally running application.
- In Kontent.ai > Environment settings > General > Environment ID, copy the Environment ID for Production.
- In your
.env file, set the
PROJECT_ID environment variable to the value of your Environment ID.
- Save the
.env file and restart the server.
Explore your sample project
Let's explore your Kontent.ai sample project and update its content so that you can see the changes reflected in your locally running sample app.
git clone https://github.com/kontent-ai/sample-app-php.git
Tip: We recommend using your own sample project. That way you can freely experiment with content and its model.