PSX Framework



Welcome, PSX is a framework written in PHP which helps you
to build clean and documented REST APIs.




Controller

class Collection extends AnnotationApiAbstract
{
    /**
     * @QueryParam(name="count", type="integer")
     * @Outgoing(code=200, schema="../Resource/schema/collection.json")
     */
    protected function doGet(Version $version)
    {
        $count  = $this->queryParameters->getProperty('count') ?: 8;
        $result = $this->repository->fetchAll($count);

        return [
            'entry' => $result
        ];
    }

    /**
     * @Incoming(schema="../Resource/schema/entity.json")
     * @Outgoing(code=201, schema="../Resource/schema/message.json")
     */
    protected function doPost(RecordInterface $record, Version $version)
    {
        $this->repository->insert('acme_news', [
            'title'      => $record->getTitle(),
            'content'    => $record->getContent(),
            'createDate' => new \DateTime(),
        ]);

        return [
            'success' => true,
            'message' => 'Create successful',
        ];
    }
}

Controller

class Collection extends SchemaApiAbstract
{
    public function getDocumentation()
    {
        return Raml::fromFile(
            __DIR__ . '/../Resource/population.raml', 
            $this->context->get(Context::KEY_PATH)
        );
    }

    protected function doGet(Version $version)
    {
        $count  = $this->queryParameters->getProperty('count') ?: 8;
        $result = $this->repository->fetchAll($count);

        return [
            'entry' => $result
        ];
    }

    protected function doPost(RecordInterface $record, Version $version)
    {
        $this->repository->insert('acme_news', [
            'title'      => $record->getTitle(),
            'content'    => $record->getContent(),
            'createDate' => new \DateTime(),
        ]);

        return [
            'success' => true,
            'message' => 'Create successful',
        ];
    }
}

This was only a short introduction to give you an insight how a PSX application works. If you are excited about the possibilities as we are you can read the about page for more informations or checkout the offical documentation.


Get started Download