Skip navigation

Run the Laravel PHP sample app

In this guide, you'll learn how to run a Laravel PHP sample app and see your project's content in your browser. The sample app will show content from a sample project and you'll also get to change a thing or two in the project.

New to Content as a Service?

If you are new to the world of Content as a Service (CaaS), you might want to start by building a Hello world application.

After you grasp the core idea behind CaaS, everything in the sample application will make a lot more sense much faster.

Table of contents

    Sample project for the app

    The sample app displays data from the Sample Project that demonstrates our best practices and features of Kentico Kontent. If you don't have it yet, create your own sample project, it only takes a minute.

    This full-featured project contains marketing content for Dancing Goat – an imaginary chain of coffee shops. Once you run the sample app, you'll see content from the Sample Project displayed in your browser.

    A screenshot of a Kontent sample app

    Running the PHP sample app

    Before going any further, make sure you have the following:

    1. Download the app

    The source code of the sample application lives in a Github repositoryOpens in a new window.

    If you are used to working with GitOpens in a new window, you can clone the repository to your computer by typing the following to your console:

    • shell
    git clone https://github.com/Kentico/kontent-sample-app-php.git
    git clone https://github.com/Kentico/kontent-sample-app-php.git

    If you don't have Git installed, you can directly download the sample application as a ZIP fileOpens in a new window, extract it, and continue from there.

    2. Connect your Kontent project

    By default, the sample app uses a shared sample project. We recommend connecting the app to your own Sample Project so that you can freely make changes and play with it.

    1. In the sample app folder, open the app\Providers\AppServiceProvider.php file.
    2. At the bottom, find the line that ends with new DeliveryClient('975bf280-fd91-488c-994c-2f04416e5ee3');
    3. Replace 975bf280-fd91-488c-994c-2f04416e5ee3 with the ID of your Sample Project.
      • You can find your project ID in > API keys > Delivery API card > Project ID field.
    4. Save the file.

    3. Run the app

    1. In your command line, navigate to the sample app folder.
    2. Run composer install to install the app dependencies.
    3. (Optional) Run 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.
    4. Run php artisan serve to start the app.

    Open 127.0.0.1:8000Opens in a new window in your browser to see the running sample app.

    Now, let's explore the Sample Project and update its content so that you can see the changes reflected in your locally running application.

    Making changes to your project

    After you sign in to Kentico Kontent, you'll see your Sample Project to play around with. We recommend you get familiar with content items and how to find stuff in your projects. It's simple yet powerful.

    Try to edit an article from the sample project:

    1. From the app menu, choose .
    2. Open a published article, for example, the Coffee processing techniques one.
      • Look for items with a green Published label and the word Article in the Type column.
    3. Create a new version to edit the article.
    4. Make a change in the article, for example, edit the Title text or some other element.
    5. Publish the changes to see them in the sample app.

    Voila! You have successfully updated content in your Sample Project. Refresh the browser window with your application to see the changes on the website.

    A screenshot of the updated article.

    Looks like someone changed the title of the article.

    Feel free to further explore how the content in your sample project is structured.

    Exploring content structure

    To see details about the opened content item, go back to Kentico Kontent and click Content details in the top right. Under Content type, notice that the item is based on the Article content type.

    To open the content type for editing, click Article in the content details.

    A screenshot of the Article content type.

    How the Article content type is modeled

    How content is structured in Kentico Kontent

    Content item is any piece of content in your project. It is made up of elements, such as texts, images, files, etc.

    Each content item is based on a single content type. A content type is a template that defines the structure of the content item – which elements it contains, their names, limitations, guidelines, and so on.

    Mix and match the available elements to define your own content types.

    Deploying the PHP sample app

    There several hosting options and ways you can deploy your PHP apps. Here are a few providers and their tutorials on how to use their platform for PHP deployment.

    Summarized

    Kentico Kontent makes no assumptions about how your content is displayed. It simply delivers it via a RESTful Delivery API to any application that asks for it – be it a website, mobile appchatbot, electronic billboard, virtual voice assistant or an internet-enabled toaster.

    We deliver the content, you do whatever you want with it – using the technology of your choice.

    A traditional CMS would force you to put your content into neatly arranged boxes to fit inside a pre-defined template. The power of Kentico Kontent comes from not getting in your way. Content structure and content presentation are truly separated and you have the flexibility to define both according to the needs of your project.

    What's next?