Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Apr 8, 2023
1 parent dcd42e0 commit f8e5984
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# About
## About

__PSX is an innovative PHP framework dedicated to build fully typed REST APIs.__

Expand All @@ -16,46 +16,26 @@ It helps to improve the API development process by providing the following featu

More information about PSX at [phpsx.org](https://phpsx.org/).

# Installation
## Installation

To install the framework you can simply install this demo API project.

php composer.phar create-project psx/psx .

# Getting started
## Getting started

This repository contains already a fully working demo API build with PSX which you can use as a starting point and to
better understand how PSX works. In the following we go based on the demo files through the important concepts of PSX.

## Controller

A controller is the entrypoint of your app which gets invoked by the framework. A controller is a simple PHP class which
contains attributes to make specific methods invokable. In the following example we have a simple controller with a
contains attributes to make specific methods invokable. In the following extract we have a simple controller with a
`getAll` and `create` method which gets invoked if a `GET` or `POST` request arrives at the `/population` endpoint s.

```php
<?php

namespace App\Controller;

use App\Model;
use App\Service;
use PSX\Api\Attribute\Path;
use PSX\Api\Attribute\Post;
use PSX\Api\Attribute\Tags;
use PSX\Framework\Controller\ControllerAbstract;

class Population extends ControllerAbstract
{
private Service\Population $populationService;
private Table\Population $populationTable;

public function __construct(Service\Population $populationService, Table\Population $populationTable)
{
$this->populationService = $populationService;
$this->populationTable = $populationTable;
}

#[Get]
#[Path('/population')]
public function getAll(?int $startIndex = null, ?int $count = null): Model\PopulationCollection
Expand Down Expand Up @@ -106,10 +86,7 @@ controller defined above PSX would generate the following client SDK.
const client = new Client(...);
client.population().getAll(startIndex?: number, count?: number);
client.population().get(id: number);
client.population().create(payload: Population);
client.population().update(id: number, payload: Population);
client.population().delete(id: number);
```

The client then contains the same schemas which are also defined at the backend but converted to TypeScript. This means
Expand Down Expand Up @@ -138,7 +115,7 @@ models using the following command s.
php bin/psx generate:model
```

The command then writes all models to the `src/Model` folder. The models are then used at the controller classes.
The command writes all models to the `src/Model` folder. You can then use those models at the controller classes.

## Service

Expand Down Expand Up @@ -201,7 +178,7 @@ public function testGetAll(): void
Through this you can easily build integration tests for every endpoint. Please take a look at the
`tests/Controller/PopulationTest.php` file to see the complete test case.

# Components
## Components

Besides the framework PSX is build on various PHP components. These components are independent of the framework and can
also be used in another context. The following list contains the most notable packages:
Expand Down

0 comments on commit f8e5984

Please sign in to comment.