Getting started

To quickly get started with PSX follow this guide which creates a working PSX environment. For more detailed informations please take a look at the offical documentation.


  • PSX requires at least PHP >= 7.0 so you have to check whether you have the right version installed.

    php -v

  • PSX uses also composer as dependency managment tool. With the following command you can see whether composer is correctly installed. In case it is not installed you can use the following guide to setup composer.

    composer --version


  • Install the sample project of PSX with the following composer command. This creates the sample project and installs a stable version of PSX.

    composer create-project psx/sample .

  • Change the file configuration.php so that the following keys are set.

    'psx_url'      => '',
    'psx_dispatch' => '',

  • Start the internal PHP web-server inside the public/ folder with the following command. Note this is only a setup for testing in production you want use a real web-server like Apache or Nginx with a vhost pointing to the public directory.

    php -S server.php


Now you should be able to visit the following endpoints:

  • Welcome

    The welcome API endpoint should given you a welcome message with further links to other endpoints.

  • API

    This is the example API of the project.

  • Documentation

    The automatically generated documentation of the example API. Note there must be a trailing slash at the url.

Source code

In the following a few explanations about the important parts of the sample API.

  • src/Sample/Api/Population/Collection.php

    This is the class which represents the /population endpoint.

  • src/Sample/Service/Population.php

    Service class which contains the business logic of the API.

  • tests/Sample/Api/Population/CollectionTest.php

    Contains the PHPUnit test case for the /population endpoint. If you have phpunit installed you can run the tests in the root of the project with the phpunit command.