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 >= 5.6 so you have to check whether you have the right version installed.
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.
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.phpso that the following keys are set.
'psx_url' => 'http://127.0.0.1:8080', '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 127.0.0.1:8080 server.php
Now you should be able to visit the following endpoints:
The welcome API endpoint should given you a welcome message with further links to other endpoints.
This is the example API of the project.
The automatically generated documentation of the example API. Note there must be a trailing slash at the url.
In the following a few explanations about the important parts of the sample API.
This is the class which represents the /population endpoint.
Service class which contains the business logic of the API.
Contains the PHPUnit test case for the
/populationendpoint. If you have phpunit installed you can run the tests in the root of the project with the